Mail Archives: djgpp/1996/09/18/01:09:21
David Charlton wrote:
>
> Okay, I have a quick question, if it's really easy or stupid
> please don't flame me... anyway, suppose I wanted to add one of the
> 16-bit registers to a 32-bit register (this is for a basic graphics
> routine) -- how would I do that? I've tried "addw %%ax, %%eax", and "addl
> %%ax, %%eax", but it doesn't work. I have a feeling it should be simple,
> but if it's simple it isn't obvious (to me) ;)... so what do I do?
> Thanks in advance...
You can't.
However, you can sign or zero extend the 16 bit reg into a 32 bit reg and add those, or add two
16 bit regs and add the carry by (eg) (numbers in brackets are 486 clock counts)
addw %ax,%dx #(1)add 16 bit reg to lower half of 32 bit reg
jnc 1f #(3/1)overflow?
addl $0x10000,%edx #(1)add carry to upper half of 32 bit reg
1: # more code
Hope this helps
Bill
- Raw text -