Date: Wed, 18 Sep 1996 16:51:21 +0000 From: Bill Currie Subject: Re: Quick inline asm question... To: David Charlton Cc: djgpp AT delorie DOT com Message-id: <32402889.744B@blackmagic.tait.co.nz> Organization: Tait Electronics NZ MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit References: <51mrb2$o5f AT news DOT cais DOT com> 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