Read from arg / parameter in tasm

343 views Asked by At

i have color dw ?

and

parm:
mov ah, 62h
int 21h 
mov es, bx  
mov bx, 80h 

mov cl, [es:bx] 
cmp cl, 2 
ret 

mov bx, 82h 
xor ax, ax
xor dx, dx

mov dl, [es:bx]
sub dl, '0'     
mov [col], dl
inc bx

I want read value of parameter, but there are error: operand types do not match. Why this not work?

2

There are 2 answers

0
lurker On

When you have an instruction such as the following in x86 assembly:

mov [col], dl

The dl register is 8 bits, and so this is necessarily an 8-bit data operation. If col is not defined as an 8 bit value, you will get an operand type error. col needs to be defined as an 8-bit value, for example:

col db ?

Since in your code you've cleared the high byte of dx with xor dx, dx before loading dl, you could move a word:

mov [col], dx

Here, the assembler will assume that the data type is necessarily 16 bits, so col must be defined as a word, such as:

col dw ?
0
Fifoernik On

From "i have color dw ?" I get that the variable is word sized.
Since you cleared the DX register beforehand you should change mov [col], dl into mov [color],dx to store the result.

A second problem is that you compare the length of the commandline but fail to jump if there's no argument. You can replace the ret by a jb to a location that exits the application.

mov cl, [es:bx] 
cmp cl, 2
jb NoArg