0
;the code read 4 bytes from file and print it on screen
bits 16

org 100h

jmp start 

filename db 'example.file',0

handle dw 0

buffer db 255

start:

    mov ah,3dh
    mov al,0
    mov dx,filename
    int 0x21
    mov handle,ax

    mov ah,3fh
    mov cx,4
    mov dx,buffer
    mov bx,handle
    int 21h

    mov dx,buffer
    add dx,ax

    mov bx,dx
    mov byte[bx],'$'

    mov dx,buffer
    mov ah,9
    int 21h
    mov ah,4ch
    int 21h
4

1 に答える 1

0

バッファは 1 バイトのようです。本当に必要なものが 255 バイトの配列である場合は、次を使用する必要があります (これが NASM 用であると仮定します)。

buffer: times 255 dup 0

また、前述のように、アドレスが指す値にアクセスするには、NASM コードで括弧を使用する必要があります。mov ax,foo そのアドレスに格納されている値ではなく、単に foo のアドレスを ax に入れます。

于 2012-07-14T17:00:00.723 に答える