[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Intel Assembly error

On Wed, Aug 16, 2000 at 10:27:45AM +0200, Paul Slootman wrote:
> No, you have AH to access the high 16 bits of EAX, and AL for the low
> 16 bits of EAX. Or was that the high 8 bits of AX etc...

Here's the layout of the EAX register...

|              EAX             |
|               |      AX      |
|               |  AH  ||  AL  |

I do not know if there is a way to access the rest of EAX when accessing
AX, AL, etc.  Not sure how endianness applies to EAX offhand (I've been up
a whole 10 minutes) but given 0x12345678 in EAX, AX may contain 0x5678
which is where the confusion comes from.  I'd have to write some asm to be
sure about that and I haven't done any in more than six years - and then
my assembler didn't have 386 instructions so I was limited to db 66h'ing
my accesses of AX if I wished to access EAX so I didn't use 386
instructions except for memory copying and the like.

> Apart from that, using assembler is evil (if there isn't a C language
> alternative) because then your source will never run on anything
> besides the processor the assembler code is written for.

I think the problem is this is what gcc was doing to the C.  I never
became clear on that.  Sometimes that C alternative is only useful for
porting the asm to a new language because the C would run too slowly for
acceptable results.  (quake for example..)

Joseph Carter <knghtbrd@debian.org>               GnuPG key 1024D/DCF9DAB3
Debian GNU/Linux (http://www.debian.org/)         20F6 2261 F185 7A3E 79FC
The QuakeForge Project (http://quakeforge.net/)   44F9 8FF7 D7A3 DCF9 DAB3

<rcw> dark: caldera?
<Knghtbrd> rcw - that's not a distribution, it's a curse
<rcw> Knghtbrd: it's a cursed distribution

Reply to: