Re: [Tuxnes-devel] more help w/ asm
Brought to you by:
tmmm
|
From: Eric J. <ea...@ri...> - 2001-04-11 23:41:52
|
"Rigel" <ri...@an...> tapped some keys and produced:
> all right, I think I've got it (all) figured out now (haha). I
> understood mov all along (promise), just not lea. I do like Intel
> syntax much better though, as it's a little more like other *real*
> (RISC) assembly languages.
>
> This whole gaffe of mine just illustrates another reason I don't like
> x86 asm, which is that the instructions are misnamed. I would have
> called lea, cea, for calculate effective addr. or maybe just wpos for
> weird piece of sh**.
The way I think about it is that lea is like taking a C "&" operator
of the corresponding mov
> > movl 4(%ebx),%edi is like edi = *(ebx+4)
> > leal 4(%ebx),%edi is like edi = &(*(ebx+4))
or edi = ebx+4
(Or, perhaps a more exact analogy is that the target register is a
reference variable, C++ style, if you understand that sort of thing.)
BTW, lea exists in Motorola 68K, and is used in much the same way.
>
> I'll definitely look up that Art of Assembly stuff. It should be a good
> reference.
>
> Okay, with the zero and sign flag (edi) you just give it the latest
> result from the ALU, right? But what about the carry flag (ebp) ? do I
> just set it to 1 if there was a carry involved in the most recent
> instruction?
You set it the way that a 6502 would set it, as you should do with Z,
N and V as well. You don't have to set up the register mapping the
same way as it is for the x86; you should use whatever mapping is the
most efficient for your architecture. The 6502 instructions that modify
the carry flag are ADC, SBC, ASL, LSR, ROL, ROR, CMP, CPX, CPY, PLP,
SEC, CLC. (Did I miss any?)
Eric
--
|