🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #945

Re: Large constants in RISC

#945
From: Terje Mathisen
Date: Wed, 25 Nov 2026 11:35
47 lines
3524 bytes
EricP wrote:
> On 2026-Nov-23 05:47, Thomas Koenig wrote:
>> EricP <ThatWouldBeTelling@thevillage.com> schrieb:
>>
>>> As both absolute and PC-rel methods are possible on all cpu's,
>>
>> It is possible in principle for Power previous to version 3.1, but
>> it was painful.  The system has a TOC pointer in r2, which points
>> to local data and the GOT, restricted to 64k.  If you really wanted
>> to do pc-relative, you had to get the PC via a branch and link
>> instruction into the link register, then transfer it from there to
>> a general register.  Power version 3.0 added a add PC immediate
>> + shifted instruction. V3.1 finally allows for pc-relative with
>> 34-bit offset, in a 64-bit instruction.
>>
> 
> The 32b x86 also does not have native PC-rel addressing,
> just absolute, register relative, with optional scaled-index.
> To get the PC into a register one calls a two instruction routine,
> which pushes the incremented PC on the stack, loads the bottom
> of stack dword into a register and returns.
> This routine could be positioned after a basic block near by.
> 
> To make that perform well the core needs store-to-load forwarding
> so it can pull the PC from the store queue and not wait for the
> value to hit memory, and a branch predictor so the call does not
> cause a stall. A "MOVPC Rd" instruction would have been simpler.

We asm programmers didn't use that function call, we just did

  call next
next:
  pop bx

Two instructions, 4 bytes

but when return predictors turned up having a CALL without the expected 
RET caused mispredicts.

Terje

-- 
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
Technical Details
Message-ID: <11e6h61$3mml2$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11d76uq$11cdc$1@paganini.bofh.team> <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team> <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team> <2026Nov14.201017@mips.complang.tuwien.ac.at> <6af911ea.18530156@news.eternal-september.org> <SYScnWsR3rgGWWP3nZ2dnZfqn_WdnZ2d@supernews.com> <jwv1p8hhqmy.fsf-monnier+comp.arch@gnu.org> <4m2MS.132607$Lt64.106487@fx41.iad> <jwvo6bidgit.fsf-monnier+comp.arch@gnu.org> <5yFMS.36883$gOr4.31829@fx08.iad> <11e15kh$1pgpm$1@dont-email.me> <e_%MS.40267$v954.6680@fx47.iad>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Terje Mathisen <terje.mathisen@tmsw.no>
Newsgroups: comp.arch
Subject: Re: Large constants in RISC
Date: Wed, 25 Nov 2026 12:35:29 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <11e6h61$3mml2$1@dont-email.me>
References: <11d76uq$11cdc$1@paganini.bofh.team>
 <11d7ct8$17akn$1@dont-email.me> <11d7ih2$11orr$1@paganini.bofh.team>
 <11d9d0d$1rsce$1@dont-email.me> <11d9tq8$1b9c1$2@paganini.bofh.team>
 <2026Nov14.201017@mips.complang.tuwien.ac.at>
 <6af911ea.18530156@news.eternal-september.org>
 <SYScnWsR3rgGWWP3nZ2dnZfqn_WdnZ2d@supernews.com>
 <jwv1p8hhqmy.fsf-monnier+comp.arch@gnu.org>
 <4m2MS.132607$Lt64.106487@fx41.iad>
 <jwvo6bidgit.fsf-monnier+comp.arch@gnu.org> <5yFMS.36883$gOr4.31829@fx08.iad>
 <11e15kh$1pgpm$1@dont-email.me> <e_%MS.40267$v954.6680@fx47.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Date: Wed, 25 Nov 2026 11:35:30 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3889826"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1++U98hSATD9eTjo7/k5Cc9vAEsYukP18dLMgueZmDwPQ=="; posting-host="7e158577c1a8742330392fe3d47d4c64"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:qFW7lvkGj1Ox1E2NGiRvsQpMjt0= sha256:LZs4z3yWHbbqudxhijSorWV5AwGHiE/ihN8leQzVwaM=
	sha1:1kyr283Jz3MatTw8pEsu567xeCI= sha256:p6YMWodVRLeFGIjBJY0hsZCtjeJHuIJ9bimZF/tIe8o=
In-Reply-To: <e_%MS.40267$v954.6680@fx47.iad>