Such operation isn't allowed in asm x86. You can't move data directly from one memory cell to another. In order to do that you need to go through a register, e.g.:
mov al, byte ptr[di]
mov byte ptr[si], al
Question
I'm a beginner in the Assembly Language
trying to Implement STRCPY
My Assembler "TASM" returns an " Illegal Memory Reference" Error.. and tried to read about the error but couldn't find anything.
Here's ma Code.
include inout.asm
.Model Small,c
.486
.STACK 200h
.DATA
Arr1 DB "ABCD$"
Arr2 DB "EFGHIJ$"
.CODE
StART: MOV AX, @DATA
MOV DS, AX
LEA Si,Arr1
LEA Di,Arr2
again: cmp Byte PTR [Si], "$"
JNE Ite ; Iterate
JMP Done
Ite: MOV Byte PTR[ Di ],[Si] ; Error Here
Inc Si ; One Byte though
Inc Di ; One Byte though
JMP again
Done: MOV Byte PTR [Di], "$"
call puts, offset Arr2
Call puts, offset Arr1
MOV AH,04CH
MOV AL,0
INT 21h
END START
and here's what the Assembler says..
C:\TASM\BIN>tasm /zi /z third
Turbo Assembler Version 3.1 Copyright (c) 1988, 1992 Borland International
Assembling file: third.ASM
Ite: MOV Byte PTR[ Di ],[Si] ; Error Here
**Error** third.ASM(18) Illegal memory reference
Error messages: 1
Warning messages: None
Passes: 1
Remaining memory: 415k
btw I tried
MOV Byte PTR[DI],BYTE PT[SI]
but didn't work
Solution
Such operation isn't allowed in asm x86. You can't move data directly from one memory cell to another. In order to do that you need to go through a register, e.g.:
mov al, byte ptr[di]
mov byte ptr[si], al
OTHER TIPS
As icepack points out, what you have there is not a valid instruction.
Check out the movs
instruction, though, which will move the byte from [si] to [di] and also increment both index counters.