🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.asm.x86
Article #167

Re: Jump table without the table?

#167
From: Vis Mike
Date: Wed, 12 Feb 2003 09:56
51 lines
3726 bytes
I found a nice feature in gcc - -malign-jumps=n

> wcc -O3 -malign-jumps=3 vmtest2.cpp
> a.exe
Testing stack4...
&&addi = 0x401180 +4 +8 +16

0x401180 is the address of the first label, followed by the offset of the
rest of the labels.  So if I can squeeze the code in, all I need is a "jmp
(opcode*4)".  This is sooo unportable :)  I'll just use conditional
compilation.

I don't quite understand gcc's inline assembly syntax, any help for the jmp?
Or am I just going overboard?

Cheers!
Mike

"James Van Buskirk" <not_valid@attbi.com> wrote in message
news:dCk2a.80786$HN5.307889@rwcrnsc51.ops.asp.att.net...
>
> "Matt Taylor" <para@tampabay.rr.com> wrote in message
> news:h2j2a.61691$AQ3.981480@twister.tampabay.rr.com...
>
> > Any good compiler will convert switch/case to a jump table for you. VC
> does
> > this; I'm quite sure that GCC does too. Unless you're writing in
assembly,
> > don't try to pad things out. The compiler should do this for you. I
don't
> > know when specifically VC/GCC do and when they don't.
>
> I think I have a different interpretation of Mike's question than
> you: my take on it is that he has code where all branches are just
> little snippets no longer than some nice easy number of bytes to
> multiply by, e.g. if all his branches were less than 32 bytes
> long and he had 16 possible cases numbered 0:15 he could, assuming
> the branch number were in EAX do something like:
>
> lea EAX, [4*EAX]
> jmp branch_implementation_start[8*EAX]
>
> In this way he could avoid waiting for the address of a previous
> write to memory to be computed before prefetching the code
> following the branch.  Maybe ALIGN directives or ORG
> directives could tell the assembler where to insert padding
> without having to maintain it by hand every time the code
> is modified?
>
>
>
Technical Details
Message-ID: <b2d1sj$8j4$1@bob.news.rcn.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
References: <b2c5s4$p9p$1@bob.news.rcn.net> <h2j2a.61691$AQ3.981480@twister.tampabay.rr.com> <dCk2a.80786$HN5.307889@rwcrnsc51.ops.asp.att.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,d7bccf0f48f83a38,start
X-Google-Attributes: gid11318c,public
X-Google-Thread: 114917,fa3250fb672bd972
X-Google-Attributes: gid114917,public
X-Google-ArrivalTime: 2003-02-12 01:56:27 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!news.crayne.org!clax86!robomod!not-for-mail
From: "Vis Mike" <visionary25@_nospam_hotmail.com>
Newsgroups: comp.lang.asm.x86,gnu.gcc.help
Subject: Re: Jump table without the table?
Approved: CLAX86 Moderators <ccrayne@crayne.org>
Date: Wed, 12 Feb 2003 09:56:10 +0000 (UTC)
Organization: Crayne Consulting
Message-ID: <b2d1sj$8j4$1@bob.news.rcn.net>
Sender: clax86@wotan.asgard
References: <b2c5s4$p9p$1@bob.news.rcn.net> <h2j2a.61691$AQ3.981480@twister.tampabay.rr.com> <dCk2a.80786$HN5.307889@rwcrnsc51.ops.asp.att.net>
X-CLAX86-Policy: http://www.pacificsites.com/~ccrayne/clax86.html
X-CLAX86-Faq: http://www2.dgsys.com/~raymoon/x86faqs.html
X-CLAX86-Info-1: Send submissions to             comp-lang-asm-x86@moderators.isc.org
X-CLAX86-Info-2: Send technical complaints to    ccrayne@crayne.org
X-CLAX86-Info-3: Send complaints about policy to ccrayne@crayne.org
X-Comment: moderators do not necessarily agree or disagree with this article.
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
X-Priority: 3
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MSMail-Priority: Normal
X-Spam-Flag: Spam YES
X-Spam-Level: Level ******
X-MailScanner: Found to be clean
X-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=6,
 required 5, FORGED_HOTMAIL_RCVD, FROM_ENDS_IN_NUMS, NO_MX_FOR_FROM,
 PRIORITY_NO_NAME, QUOTED_EMAIL_TEXT, REFERENCES, SPAM_PHRASE_00_01)
X-UIDL: :GQ!!@mA!!+?(#!"<e"!
X-Complaints-To: abuse@supernews.com
Lines: 54