🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #431

Re: interrupt handling latency and weird register use (was Re: OT: Epic RISC-V rant)

#431
From: BGB
Date: Wed, 28 Oct 2026 20:52
109 lines
5972 bytes
On 10/28/2026 7:33 AM, Waldek Hebisch wrote:
> MitchAlsup <user5857@newsgrouper.org.invalid> wrote:
>> anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
>>
>>> makendo <makendo@makendo.invalid> writes:
>>>> The case where division is implemented but
>>>> multiplication is not does not have a name assigned -- it is pretty
>>>> well known that hardware designers, compiler writers and low-level
>>>> programmers hate division far more than multiplication, so I doubt
>>>> if divison-only hardware is even out in the wild for any ISA...
>>>
>>> I don't think that "hate" is the right concept.  Division is costly:
>>
>> But "lack of division" is also costly !! especially if some future
>> implementation will have division {which it will} and then you have
>> no direct means to make the dusty decks fast.
> 
> You assume binaries or assembler code.  In microcontroller world
> programs are frequently compiled for one specific CPU model.
> And in case of microcontrollers savings due to ommision of
> divide circuit can be significant.  I know you do not like
> Risc-V, but one small model (CH32V003) even skips multiplication.
> IIUC even smallest Arm-s have multiplication (which theoretically
> can be slow, but on all small models that I know it 32 bit
> multiplication executes in 1 cycle).
> 

Yeah.

Ironically, the smallest microcontroller style core I did was using a 
very limited subset of the SuperH ISA.

But, in this case, can note:
   16-bit instructions;
   No multiply or divide;
   No general-purpose shift;
     Would use "shift slides".
   No auto-increment (was present in normal SH);
   Not pipelined and would do an I$ miss every 8 instrs;
     Also no real D$ either, would miss nearly every access;
     And memory access was not pipelined.
   ...

This whole thing kind of died off, ironically, because I didn't have 
much particular use for cheap-but-slow cores.

A small RISC-V core would cost more, but be a little more useful.
For a microcontroller use-case, RV32I is actually pretty sane; though 
RV32IMC or RV32IC is more industry-standard here.

There is RV32E (with 16 registers), but it seems relatively few people 
want to limit the register space that bad.

Main "cheapening" would be to only allow X0 and X1 as destinations for 
JAL and JALR, and requiring that Rs2 for Bcc ops is X0.


>> Note to µArchitects, put the instruction in even if you are going to
>> TRAP to SW emulation. Later on when DIV is implemented it just runs
>> faster and you had to do nothing (but put it in).
> 
> You need to make it fast enough so that compilers are not tempted
> to call software emulation.  Also beware of interrput latency,
> if division is slow microcontroller probably should allow
> interrupts in the middle of division.
> 

Yeah.


Fast interrupt handling is always a long standing issue.

Seemingly, there is a multi-way split:
   Require ISR to spill/reload registers manually;
     Looks bad on paper, but often cheaper/faster in practice.
   Register Banks:
     Looks fast, but there are a lot of "hidden gotchas" here.
   Automatic spill/reload to/from memory contexts:
     Seems clever, but likewise comes with a lot of "gotchas".


Half tempting is to provide some way to allow the ISRs to patch 
instructions directly to a handler sequence.
This makes a problem though mostly for things like addressing.

Say, in many cases, something like a RISC-V JAL doesn't reach far enough 
to be able to put a patched-in handler in-range.

So, one almost needs something like a hidden architectural jump table, 
say and special instructions to jump via this jump table.


For BGBCC, I had taken a different option:
The PE/PEL loading is handled by the kernel;
The PE read-only sections, data/bss, and stack, are unrelated;
The compiler counts up how many "potentially trapping" instructions are 
used and explicitly leaves space for basic patch handling (enough pad 
space for encode an Abs64 branch).

For RV64, this pad space would need to be within 1MB of the offending 
instruction, but for XG3 can be within 16MB.


There is still a little more complexity if dealing with Linux ELF-PIE 
binaries (and dealing with glibc's "ld.so" behavior), but there are 
possible options that could be tried (to maybe provision for providing 
free space near the ".text" sections).

Technical Details
Message-ID: <11btne6$2pjou$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <87qzk0nejz.fsf@nightsong.com> <116d89d$27baf$1@paganini.bofh.team> <87ecfcagiw.fsf_-_@debian> <2026Sep1.225146@mips.complang.tuwien.ac.at> <11bpfm8$190ap$1@dont-email.me> <2026Oct27.171414@mips.complang.tuwien.ac.at> <1793120789-5857@newsgrouper.org> <11bsq36$36q1t$3@paganini.bofh.team>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: BGB <cr88192@gmail.com>
Newsgroups: comp.arch
Subject: Re: interrupt handling latency and weird register use (was Re: OT:
 Epic RISC-V rant)
Date: Wed, 28 Oct 2026 15:52:00 -0500
Organization: A noiseless patient Spider
Lines: 109
Message-ID: <11btne6$2pjou$1@dont-email.me>
References: <87qzk0nejz.fsf@nightsong.com>
 <116d89d$27baf$1@paganini.bofh.team> <87ecfcagiw.fsf_-_@debian>
 <2026Sep1.225146@mips.complang.tuwien.ac.at> <11bpfm8$190ap$1@dont-email.me>
 <2026Oct27.171414@mips.complang.tuwien.ac.at>
 <1793120789-5857@newsgrouper.org> <11bsq36$36q1t$3@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 28 Oct 2026 20:54:31 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2936606"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19TbB8HBMezKAE/dzRRtOokRoT/CCZRJeE="; posting-host="609a946c24bef645c99bfc2af666679f"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Yx1FXqati4sv06+nrfsxcOxD0vM= sha256:4MI5f7vE9b+GzOMe9hlUXP2FyMip5esYhCaGbXwIJ6M=
	sha1:+w5r0B49svE7Q2HkIDbXcGsq7TM= sha256:o2PF5wmlrTJUAsSGQtRNqp/Ki3eecaIhQoQFUekBKgE=
Content-Language: en-US
In-Reply-To: <11bsq36$36q1t$3@paganini.bofh.team>