www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/15/03:42:47

Date: Wed, 15 Jul 1998 10:42:08 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Jedediah Smith <jedediah AT interlog DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: How to use 32 bit regs in 16 bit C prog?
In-Reply-To: <35AC4574.2A32@interlog.com>
Message-ID: <Pine.SUN.3.91.980715103514.10743U-100000@is>
MIME-Version: 1.0

On Tue, 14 Jul 1998, Jedediah Smith wrote:

> I need to optimize a little inner loop in a 16 bit C prog and I want to
> use the 32 bit general purpose registers (EAX,EBX,ECX,EDX). I don't need
> to do any flat memory addressing or anything like that, just use those 4
> regs to temporarily store data and do arithmetic. I can stick the
> machine code into the C source using the _emit_ macro but I want to know
> what I have to do to the CPU state before I can use the registers.

Use the GCC inline assembly facilities.  They allow you to explain to the 
compiler which registers does your assembly fragment use, and the 
compiler will then take care of saving and restoring these registers.

The inline assembly facilities are described in the GCC on-line docs.  
From the DOS prompt, type this:

	 info gcc "C Extensions" "Extended Asm"

(note the quotes: they are important) and read there.

- Raw text -


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