I'm new to assembly. I'm trying to move some numbers into the memory locatons starting from 0800:0010 but couldn't figure it out.
Here's the code:
.data
NUM0 DB 00H
NUM1 DB 22H
NUM2 DB 00H
NUM3 DB 35H
NUM4 DB 71H
NUM5 DB 03H
.code
MOV AX, 0800H
MOV DS, AX
MOV AX, 0010H
MOV ES, AX
MOV DS:[0010], NUM1
MOV DS:[0011], NUM2
MOV DS:[0012], NUM3
MOV DS:[0013], NUM4
MOV DS:[0014], NUM5
The code gives an error:
(15) wrong parameters:
MOV [0000], NUM1
So, I tried an alternative code:
.data
NUM0 DB 00H
NUM1 DB 22H
NUM2 DB 00H
NUM3 DB 35H
NUM4 DB 71H
NUM5 DB 03H
.code
MOV AX, 0800H
MOV DS, AX
MOV AX, 0010H
MOV ES, AX
MOV AL, NUM1
MOV DS:[0010], AL
MOV AL, NUM2
MOV DS:[0011], AL
MOV AL, NUM3
MOV DS:[0012], AL
MOV AL, NUM4
MOV DS:[0013], AL
MOV AL, NUM5
MOV DS:[0014], AL
This does not give any error but my desired memory location, 0800:0010 is empty. Also, even though NUM0 is useless, if I don't include it, the NUM1 is changed into 57H. When I include it, the problem seems to go away.
Also, it looks like the DS register seems to start at 0100 then go to 0000 after the line MOV DS, AX.
MOV AL, NUM1in most assemblers tries to load the offset of the byte labeledNUM1(which is 1). If you want to load the contents of this byte, it's always better to writeMOV AL,[NUM1]. Such instruction loads registerALfrom the memory labeledNUM1, and uses default segment registerDSfor memory addressing, because no segment override was specified. Alas, your registerDSis not initialized to point at.datasegment whereNUM1resides. Try another alternative:Or, when the NUM* values are known at write-time, you can use their immediate values:
Another alternative is mem2mem copy using MOVSB: