0

I'm trying to put my .asm (version x8086) file in the nasm And I get

nums.asm:7: error: invalid combination of opcode and operands
nums.asm:9: error: invalid combination of opcode and operands
JMP MAIN
ADDRESS_MEMORY dw 0
JUMPS dw 0
DIVIDE equ 50

MAIN:
    mov ADDRESS_MEMORY, ax ; <- Error
    JMP RANDOM_NUMBER              
    mov JUMPS, cx ; <-    Error

What is the issue? Help. I really need to use this like that. How can I move the value to the global variables without error?

Ziv Sion
  • 424
  • 4
  • 14
  • ADDRESS_MEMORY and JUMPS are both defined as dw (double-word) which is 4 bytes, while registers ax and cx are both word-size (2 bytes) – Kermit the Frog Dec 13 '22 at 21:36
  • But if I change it I get an error. The d doesn't mean double – Ziv Sion Dec 13 '22 at 21:37
  • NASM syntax is different from EMU8086. In NASM syntax, `ADDRESS_MEMORY` is an immediate constant (the address), so it can't be the destination. You left out the []. – Peter Cordes Dec 13 '22 at 21:38
  • @KermittheFrog: No, `dw` is Data Word, 16 bits. `dd` is 32-bit data double-word. And NASM doesn't magically associate symbol names with sizes the way MASM/TASM and EMU8086 do. This code is actually correct for EMU8086, missing square brackets for NASM. – Peter Cordes Dec 13 '22 at 21:39
  • @PeterCordes So ```mov [ADDRESS_MEMORY], ax``` ? – Ziv Sion Dec 13 '22 at 21:40
  • ok. sorry. i dont know much about nasm – Kermit the Frog Dec 13 '22 at 21:40
  • But it will insert the address that is the value. If ADDRESS_MEMORY = 10, so it will put in address number 10 the value of ax – Ziv Sion Dec 13 '22 at 21:41
  • 1
    No, `mov [ADDRESS_MEMORY], ax` is a store, a mov with a memory destination. If that's not what you wanted, write `mov ax, ADDRESS_MEMORY` to put the address in AX or `mov ax, [ADDRESS_MEMORY]` to load from it. The linked duplicate has examples. – Peter Cordes Dec 13 '22 at 22:22

0 Answers0