flat assembler
Message board for the users of flat assembler.
Index
> DOS > what is wrong with using [es:cx] ? |
Author |
|
tantrikwizard 11 Mar 2007, 14:29
You cannot use every register as a displacement in 16 bit code, only in 32 bit code can you do this. Displacement registers in 16 bit code are BX, SI, DI, SP and BP. This is not a DOS limitation, it's by design of the processor when not running in protected mode.
|
|||
11 Mar 2007, 14:29 |
|
dvlfrnd 11 Mar 2007, 14:41
i see,
Thank you very much for your explanation tantrikwizard |
|||
11 Mar 2007, 14:41 |
|
LocoDelAssembly 11 Mar 2007, 15:59
Code: mov ax, [bx+bx] Error reported by fasm: "invalid address" Code: mov ax, [es:cx] Error reported by fasm: "reserved word used as symbol" Why fasm doesn't report "invalid address" for the last one too? |
|||
11 Mar 2007, 15:59 |
|
tantrikwizard 11 Mar 2007, 16:15
LocoDelAssembly wrote: Why fasm doesn't report "invalid address" for the last one too? Not sure, its something to do with the stage of compilation that produces the error. In either case it's invalid in 16 bit code. Code: mov ax, [bx+bx] This is using Index+Displacement addressing, it can be achieved in 16 bit code using: Code: add bx, bx mov ax, [bx] valid 16 bit addressing modes are (from intel manual): [BX + SI] [BX + DI] [BP + SI] [BP + DI] [SI] [DI] disp16 [BX] [BX+SI]+disp8 [BX+DI]+disp8 [BP+SI]+disp8 [BP+DI]+disp8 [SI]+disp8 [DI]+disp8 [BP]+disp8 [BX]+disp8 [BX+SI]+disp16 [BX+DI]+disp16 [BX+SI]+disp16 [BX+DI]+disp16 [SI]+disp16 [DI]+disp16 [BP]+disp16 [BX]+disp16 I erronously said SP could be used as an addressing mode in 16 bit code in the previous post. |
|||
11 Mar 2007, 16:15 |
|
Goplat 11 Mar 2007, 16:42
dvlfrnd: Your two code samples are not equivalent, the first one fills addresses 0 to 63999, the other does 1 to 64000.
|
|||
11 Mar 2007, 16:42 |
|
dvlfrnd 11 Mar 2007, 17:06
Quote: dvlfrnd: Your two code samples are not equivalent, the first one fills addresses 0 to 63999, the other does 1 to 64000. oh,yes i haven't noticed it,thanks |
|||
11 Mar 2007, 17:06 |
|
LocoDelAssembly 11 Mar 2007, 17:57
tantrikwizard, both codes was just an example to trigger the error messages, I'm not really needing "mov ax, [bx+bx]" to get working
I'll not tell that reporting "reserved word used as symbol" when things like [bx+cx] (no need for segment override to trigger the same error message) appears, but I think that it misguide the unprevented programmer. A "invalid address" or "invalid addressing" are more appropiate IMHO. |
|||
11 Mar 2007, 17:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.