Search code examples
assemblyx86-16tasm8-bit

Move an 8 bit register to a 16 bit memory location, how?


I have problem moving 8 bit register to a 16 bit register.

What i'm trying to do is to divide a number repeatedly by 10 til it gets lower than 10, and, within each division time, i try to move out the remained part of the division out from AH register, add 48 to it, then i could have its Ascii code , then i try to show the digit i got , on screen.

 Num1 DW 255
 DIVISION :
        CMP NUM1,10
            Jl DIVEND
            
        MOV AX,10
        DIV NUM1
        MOV NUM1,AL    ;*  Operand types do not match
    
        
        ADD AH,48
        MOV DL,AH; 
        MOV AH,02H
        INT 21H
        
    JMP DIVISION

but , when im trying to assemble it , it says , Operand types do not match on the line indicated by *.

im using turbo assembler V4.1 ...


Solution

  • Did you mean that?

    mov bx, Offset Num1 
    mov [bx], al
    

    The error you get is because you declare a word but adress it as a byte. If you did Num1 db it also works.

    Tested with TASM 4.1