im using nasm.
if you see anything i can improve on ,please tell me im just learning assembly.

i was told ; this won't be too useful... hex display better?
is it better and how do i display using hex instead?

and is "the art of assembly language" the best book to use?
i cant find anything on whats the best way to copy the mbr to file
thanks all


org 100h                                ;

Start:





;read mbr
        mov    dx,00h                  ;DX Data register  ; read MBR of target drive
                                        ;drive a=ooh,b=01h,80h=first hard drive.81h=second

        mov    cx,1h                  ;CX count register for string operations ; it's always the first sector

        mov    bx, buffer              ;BX index register for MOVE ; point to our buffer

        mov    ax, 0201h              ;AX Accumulator/multiply/divide ; read one sector

        int    13h                    ;13h is Drive Table
;file stuff
       
       
        mov    ah, 3Ch        ;create  the file
        mov    cx, 0       
        lea    dx,   ;Presume DS points at filename
        int    21h            ; segment.
        jc stop                  ; don't continue if create failed!
      mov , ax
       
;put read from buffer here
; "read from"? you mean display it?
; this won't be too useful... hex display better?
      mov dx, buffer
      mov cx, 512
      mov bx, 1 ; stdout
      mov ah, 40h
      int 21h


;put write to file here

        mov dx , buffer
        mov cx, 512
        mov bx,
        mov ah, 40h
        int 21h


        mov    ah, 3eh        ;Close file
        int    21h         
        jmp    stop

stop:

        mov    ax, 0x4C00          ; Terminate program
        int    21h

buffer times 512 db 0                         

Filename        db 'test.txt',0
handle      db  0


Posted on 2011-07-25 11:01:26 by flyhigh427