NASM Assembly 16bit “invalid combination of opcode and operands”

ぃ、小莉子 提交于 2019-12-04 06:57:58

问题


So I'm trying to write a program that creates a file and my name in it. But I get the "invalid combination of opcode and operands" on the mov handle, ax, and I don't know why. I saw here that you can do it so why can't I. Thank you in advance for any help.

org 100h

mov ah, 3ch     ;create a file
mov dx, name    ;file name
mov cx, 0       
int 21h

mov handle, ax ; save handle

mov ah, 40h     ;write to file
mov bx, handle
mov cx, 1000    
mov dx, text    ; what to write
int 21h

mov ah, 3eh     ;close the file
mov bx, handle
int 21h


mov ax, 4C00h ; end 
int 21h

section .data
name db "name.txt", 0
text db "Michal",0ah,0dh,"$"

section .bss
handle resb 2

回答1:


NASM Requires Square Brackets For Memory References. The correct syntax is mov [handle], ax. foo is using the address and [foo] is the content. You might have that mixed up elsewhere too.



来源:https://stackoverflow.com/questions/33136336/nasm-assembly-16bit-invalid-combination-of-opcode-and-operands

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!