|Re: code generation on 8086? maccer@MT.net (1995-03-01)|
|Re: code generation on 8086? email@example.com (1995-03-06)|
|Re: code generation on 8086? john_reiser@MENTORG.COM (1995-03-07)|
|From:||john_reiser@MENTORG.COM (John Reiser)|
|Keywords:||386, code, optimize|
|Organization:||Mentor Graphics Corporation|
|Date:||Tue, 7 Mar 1995 20:54:02 GMT|
Paul Rubin (firstname.lastname@example.org) wrote:
: What are the basic techniques for code generation on the 8086?
The first basic technique is, "Let somebody else do it for you."
PowerSoft [Watcom] C/C++ 10.x is under $200 and delivers excellent
code for i286, which needs only minor care to be useful on 8086.
Perhaps there is a 8086 mode. An old version of MetaWare HighC
is good, too. There are others.
A second basic technique is to abstract the peculiarities of the
registers. Once upon a time, I generated code for i286 using
(DX<<16)|AX as the accumulator (32/16/8 bits), (CX<<16)|BX as a second
[rarely-used] accumulator, DS:SI as the source pointer register,
ES:DI as the destination pointer register, BX as the indexing
register, and CL as the shift count register. What would have
been "registers" in a more regular architecture became on-stack
local variables, with the i86 registers caching them in peep-hole
fashion. Static data went into a single 64KB stack segment,
with accesses always requiring an SS: prefix byte and full 16-bit
address. My output from code generation was entire code segments,
with subroutines placed first come, first served. All calls were
long calls written "PUSH CS; CALL NEAR xxx". If the target was
unknown or in another segment, then a 5-byte "JMP FAR" was inserted
at the high end of the current segment, and chained to calls from the
current segment. If the target became defined, then the the 5-byte
trampoline was removed. The non-REP string instructions LODSW/STOSW/
MOVSW become important, as does tracking their side effects on SI and DI.
The XCH instruction does yeoman duty.
Return to the
Search the comp.compilers archives again.