Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Bartc <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: emulating 8086 subset. |
| Date | 2015-07-11 10:38 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <mnqo44$722$1@dont-email.me> (permalink) |
| References | <35f8a764-53e4-4dba-ac10-e9c7dc05727f@googlegroups.com> <cv798iFqn7qU1@mid.individual.net> <eff99871-2640-4e06-ac02-c325722591fb@googlegroups.com> <mmm3a2$564$1@dont-email.me> <2405bb6f-3815-4a55-bb71-e67cf860d86f@googlegroups.com> |
On 11/07/2015 08:51, luser droog wrote:
> On Saturday, June 27, 2015 at 7:02:37 AM UTC-5, somebody wrote:
>>
>> *Lose the macros*.
>
> non-wrapped at:
> https://gist.github.com/luser-dr00g/aef0342cb4a63d682c13
It hasn't really helped! Now there are the pointless typedefs. And (I
haven't followed the thread) presumably the original macros have been
expanded, but resulting in a large, unformatted lines or blocks of code.
Isn't there a tool that can take such code and format it properly? (But
somehow I doubt that will help.)
It's not clear what the aims are here: to make something as fast as
possible or as compact as possible. It's certainly not readability!
> typedef intptr_t I; typedef uintptr_t U;
Nobody uses I or U. Enough people i32, u32 etc that at least it will not
look totally alien.
> typedef signed char C; typedef unsigned char UC;
And here 'byte' is better. At least it looks like a type!
> UC*al;UC*ah;UC*cl;UC*ch;UC*dl;UC*dh;UC*bl;UC*bh;US*ax;US*cx;US*dx;US*bx;US*sp;US*bp;US*si;US*di;US*ip;US*fl;US*cs;US*ds;US*ss;US*es;V init(){I i=0;al=(UC*)(reg+i++);ah=(UC*)(reg+i++);cl=(UC*)(reg+i++);ch=(UC*)(reg+i++);dl=(UC*)(reg+i++);dh=(UC*)(reg+i++);bl=(UC*)(reg+i++);bh=(UC*)(reg+i++);i=0;ax=(US*)(reg+i);i+=2;cx=(US*)(reg+i);i+=2;dx=(US*)(reg+i);i+=2;bx=(US*)(reg+i);i+=2;sp=(US*)(reg+i);i+=2;bp=(US*)(reg+i);i+=2;si=(US*)(reg+i);i+=2;di=(US*)(reg+i);i+=2;ip=(US*)(reg+i);i+=2;fl=(US*)(reg+i);i+=2;cs=(US*)(reg+i);i+=2;ds=(US*)(reg+i);i+=2;ss=(US*)(reg+i);i+=2;es=(US*)(reg+i);i+=2;}
Let me guess, a macro expansion? How would you write it if you had to do
by hand?
My point is that as written, it's not really human readable. I'm not
sure it even counts calling it C, even if it makes legitimate use of the
macro preprocessor.
>ch=(UC*)(reg+i++);dl=(UC*)(reg+i++);dh=(UC*)(reg+i++);bl=(UC*)
>(reg+i++);bh=(UC*)(reg+i++);i=0;ax=(US*)(reg+i);i+=2;cx=(US*)(reg+i);
>i+=2;dx=(US*)(reg+i);i+=2;bx=(US*)(reg+i);i+=2;sp=(US*)(reg+i);i+=2;bp=
>(US*)(reg+i);i+=2;si=(US*)(reg+i);i+=2;di=(US*)(reg+i);i+=2;ip=
>....
This looks like it's crying out for these register variables to be
implemented as arrays (which is how it works on the actual chip;
registers are indexed by 0 to 7). With registers such as AX/AL/AH
implemented as unions... But then as I said I don't know what the aims are.
--
Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-06-27 00:34 -0700
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-06-27 01:18 -0700
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-06-27 01:28 -0700
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-06-28 21:21 -0700
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-06-28 22:50 -0700
Re: GOLFulating 8086 subset. gensym? luser droog <luser.droog@gmail.com> - 2015-07-01 15:36 -0700
Re: GOLFulating 8086 subset. gensym? luser droog <luser.droog@gmail.com> - 2015-07-01 16:02 -0700
Re: GOLFulating 8086 subset. gensym? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-01 16:11 -0700
Re: GOLFulating 8086 subset. gensym? luser droog <luser.droog@gmail.com> - 2015-07-01 16:52 -0700
Re: GOLFulating 8086 subset. gensym? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-01 16:56 -0700
Re: GOLFulating 8086 subset. gensym? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-01 22:12 -0700
Re: emulating 8086 subset. Ian Collins <ian-news@hotmail.com> - 2015-06-27 21:38 +1200
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-06-27 02:51 -0700
Re: emulating 8086 subset. Richard Heathfield <rjh@cpax.org.uk> - 2015-06-27 13:02 +0100
Re: emulating 8086 subset. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-27 14:25 +0100
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-07-11 00:51 -0700
Re: emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-11 01:54 -0700
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-07-11 01:58 -0700
Re: emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-11 01:59 -0700
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-07-11 02:13 -0700
Re: emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-11 02:34 -0700
Re: emulating 8086 subset. Bartc <bc@freeuk.com> - 2015-07-11 10:50 +0100
Re: emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-11 02:58 -0700
Re: emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-11 02:52 -0700
Re: emulating 8086 subset. Bartc <bc@freeuk.com> - 2015-07-11 10:38 +0100
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-07-11 03:16 -0700
Re: emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-11 03:19 -0700
emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-06-27 03:07 -0700
emulating 8086 subset. "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-06-27 03:58 -0700
Re: emulating 8086 subset. luser droog <luser.droog@gmail.com> - 2015-07-10 10:51 -0700
Re: emulating 8086 subset. JohnF <john@please.see.sig.for.email.com> - 2015-07-11 10:07 +0000
csiph-web