0

I'm having an error message in line 12 mov dx, var1. It says "FileName.ASM(12) Operand types do not match".

Here's my code:

.model small
.stack 100h
.data
var1 db 65
var2 db 1
.code
m       proc
        mov ax, @data
        mov ds, ax
        mov cx, 5          
     x:                     
        mov dx, var1         
        mov ah, 2             
        int 21h
        mov dl, var2          
        add dl, 48            
        mov ah, 2              
        int 21h
        inc var1
        inc var2        
        mov dx, 10            
        mov ah, 2
        int 21h        
        mov dx, 13
        mov ah, 2
        int 21h
        loop x             
  
        mov ah, 4ch          
        int 21h
m       endp
end     m

Screenshot of error message:

enter image description here

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 2
    Looks like you wanted to pass the address. In tasm I believe you write that as `mov dx, offset var1`. Or use `lea dx, var1`. – Jester Aug 31 '21 at 14:46
  • 2
    `int 21h` with `ah=2` takes a character in `dl`, not an address in `dx`. So it probably is supposed to be a byte load from memory, and should have just been `mov dl, var1`. Probably clearer to write as `mov dl. [var1]`, see https://stackoverflow.com/questions/25129743/confusing-brackets-in-masm32. – Nate Eldredge Aug 31 '21 at 16:50
  • 2
    You got it right the second time through so I guess this is just a typo. The reason for the message is that `var1` was declared `db` so the assembler knows it's meant to be a byte, but `dx` is a 16-bit register. So the assembler sees you are doing a 2-byte load of a 1-byte object, and warns you that this is probably wrong. If you really did want a 2-byte load of `var1` and the following byte, you'd do `mov dx, word ptr [var1]`. – Nate Eldredge Aug 31 '21 at 16:53

0 Answers0