friend of mine . learns asm in school
he asked me if mov si,[2000] is legal. i say yes . his teacher says no

who is right?

Posted on 2002-12-13 04:59:31 by eko
if i remember right SI can take up to 2 Bytes of code so that looks right me.

the assembler may not compile it but i know i have seen stuff like the in SoftIce Debugging and i have
used hview to do it to i think. its been a while sence i have needed to use it at all.
Posted on 2002-12-13 05:10:25 by devilsclaw
si is a word-sized register but [2000] is just a memory reference (isn't it?).
so this should be possible (in dos or in windows-ring0)

0434C55F 66:8B35 002000>MOV SI,WORD PTR DS:[2000]
Posted on 2002-12-13 05:13:41 by mob
Your teacher is right.

Since [2000] is a byte, there is no encoding to do mov si, [2000].

mov si, word ptr [2000]
movzx si, [2000] ;if you are dealing with unsigned numbers
movsx si, [2000] ;if you are dealing with signed numbers

*NOTE: I could be wrong by a small syntax error... but to my recollection this is the solution.
Posted on 2002-12-13 14:43:33 by Asm_Freak
I'm not sure I understand, but it depends on what you mean by "legal"

mov si, [2000] by itself is a valid instruction and it will compile and run. It sets si to 7D0h.

mov si, ds:[2000] will also compile and run. It sets si to the word value at address 2000. Windows might complain because it's an illegal address, but for no other reason. In DOS it would work just fine. In Windows try mov si, ds:[400000h] and you shouldn't have a problem.
Posted on 2002-12-13 14:57:49 by iblis
The syntax depends on the assembler,
but it is a valid instruction for FASM.

MASM will except: mov si, WORD PTR 2000

Or the following will assemble to the needed instruction:

ORG 2000
_My_Word dw 0

mov si, _My_Word

p.s. Don't argue with your teacher. :)
Posted on 2002-12-13 15:17:07 by bitRAKE
When in doubt, Start->Run->debug

0E9C:0100 mov si, [2000]
0E9C:0100 8B360020 MOV SI,[2000]
Posted on 2002-12-14 02:17:59 by eet_1024
See follow codes:
mov eax,
mov ,eax
if you use masm6.14, compile will succ.
but when you use masm7.0, a compile error will happen.:rolleyes:
Posted on 2002-12-23 20:58:35 by smallwaves
thats because you dont have a valid addresss that your trying to write to.
Posted on 2002-12-23 21:03:23 by devilsclaw