www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/18/01:09:21

Date: Wed, 18 Sep 1996 16:51:21 +0000
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: Quick inline asm question...
To: David Charlton <charlton AT the-hermes DOT net>
Cc: djgpp AT delorie DOT com
Message-id: <32402889.744B@blackmagic.tait.co.nz>
Organization: Tait Electronics NZ
MIME-version: 1.0
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019