-1

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
Community
  • 1
  • 1
  • what happens if you put the definition of handle at the top like in the example you linked to ? – Marged Oct 14 '15 at 22:01

1 Answers1

3

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.

Jester
  • 56,577
  • 4
  • 81
  • 125