I am trying to copy variables and paste it to my array. The way I am trying to do is following but my emulator is giving me an error saying wrong parameters. How can I do that. Assuming that there are values already in count_a
and count_b
.model
.data
frequency dw dup(0)
count_a dw ?
count_b dw ?
.code
mov bx,[frequency] ;Effective Address of Frequency in bx
mov [bx],count_a
add bx,2
mov [bx],count_b
end
You can't copy memory to memory (one variable to another variable), you will have to use a register in the middle, like this:
.model
.data
frequency dw dup(0)
count_a dw ?
count_b dw ?
.code
mov bx,[frequency] ;Effective Address of Frequency in bx
MOV DX,count_a
mov [bx],DX
add bx,2
MOV DX,count_b
mov [bx],DX
end
It's not allowed to move data from count_a to [bx], so we can use DX (or any other register) to store the value and pass it from one memory location to the other.
By the way, "mov bx,[frequency]" is not the effective address of frequency, this is:
lea bx, frequency
Now BX contains the effective address of frequency, thanks to "lea" instruction. Another way:
mov bx, offset frequency
What you were doing with "mov bx,[frequency]" was transfering the first two bytes of the array frequency to bx.
One last comment: "frequency" doesn't look like an array, it should be:
frequency dw 256 dup(0)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments