0
.model small
.stack 100h
.data
num1 db 3
num2 db 5
max db 0
.code
start:
    mov ax, @data
    mov ds, ax

    mov ah, 01h
    int 21h
    mov num1, al

    mov ah, 01h
    int 21h
    mov num2, al

    cmp num1, num2
    jg greater
    mov max, num2
    jmp done
greater:
    mov max, num1
done:
    mov dl, max
    mov ah, 02h
    int 21h

    mov ax, 4c00h
    int 21h
end start

I get this errors:

Error 100.asm(22) Illegal memory reference Error 100.asm(24) Need register in expression Error 100.asm(27) Need register in expression

,mentioning that the name of my file is 100.asm

I wanted to take 2 numbers as input and compare them to find the maximum value but i get this: quick mention is that my file is named 100.asm

andrei
  • 1
  • 2
    I don't know which line is 22, but e.g. `mov max, num2` is not valid - you can't move directly from one memory location to another on x86 - you have to go through a register. – 500 - Internal Server Error Jan 16 '23 at 20:11
  • the lines with the errors are these: mov max, num1 mov dl, max mov ax, 4c00h. Can you kindly tell me how to go through a director in order to make the code to work? – andrei Jan 16 '23 at 20:35
  • `mov ax, 4c00h` is valid syntax for a valid instruction. You have 3 instructions with two memory operands each, enough to account for your 3 error messages, and the line numbers match up with them, not the `mov ax, imm16`. What do you mean "director"? 500-internal said "register". x86 has 7 registers other than the stack pointer; use some of them instead of keeping `max` in memory and then this will just work. – Peter Cordes Jan 17 '23 at 00:58
  • Technically, you haven't even made it to DOSBOX yet. This is the assembler giving you the error. Assembly runtime errors tend to cause unexpected behavior or a crash. – puppydrum64 Jan 18 '23 at 11:12
  • Something like `mov bl, num2` followed by `mov max, bl` would work. – puppydrum64 Jan 18 '23 at 11:13

0 Answers0