TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

First ROM Shadowing

62 pointsby kencauseyabout 2 years ago

8 comments

rwmjabout 2 years ago
Not used routinely, but it is possible to shadow the BASIC ROM on the Amstrad CPC 464 (1984). That ROM is normally located at C000h, shared with bank-switched RAM storing the display at the same address. You could copy the ROM to the RAM and permanently switch in the RAM. (You had to do another trick to move the display RAM elsewhere too, but it was all possible by writing to the correct gate array registers[1])<p>Which allowed you to do stuff like modifying the error messages in BASIC to say rude words, not that we would have ever done that.<p>[1] <a href="https:&#x2F;&#x2F;www.cpcwiki.eu&#x2F;imgs&#x2F;f&#x2F;f6&#x2F;S968se02.pdf" rel="nofollow">https:&#x2F;&#x2F;www.cpcwiki.eu&#x2F;imgs&#x2F;f&#x2F;f6&#x2F;S968se02.pdf</a>
评论 #35691549 未加载
MBCookabout 2 years ago
Can someone explain why ROM was slower? I would have guessed it was faster.<p>Is there some technical limitation? Or was it more of a “can can shadow the ROM so save the extra few cents on faster ROM” thing? Just that no one was pushing as hard as for faster RAM.
评论 #35671704 未加载
评论 #35671725 未加载
1letterunixnameabout 2 years ago
Let&#x27;s suppose your PC system ROM was 64 KiB F000:0000 to F000:FFFF (F0000 to FFFFF linear). If it wasn&#x27;t a 286 or higher, then it couldn&#x27;t simply use protected&lt;-&gt;real-mode virtual memory tricks to copy ROMs and remap memory pages. Instead, there would need to be a motherboard-assisted hardware mechanism to redirect the decoding of the top 4 bits matching 1111 from ROM to copy to and steal some RAM. It would probably be easiest to do this at boot (during POST) by temporarily mapping future shadow ROM (RAM) to RAM, copy the ROM-&gt;RAM, and then remap that RAM over the ROM. Let&#x27;s borrow A000:0000 since we&#x27;re in text mode 0x3 using 4 KiB of the EGA&#x2F;VGA frame buffer at B800:0000 and assume there&#x27;s no other adapter configured to use this area.<p><pre><code> ; copy 64 KiB from F000:0000 -&gt; A000:0000 ; registered not saved: AX CX SI DI ; registered saved: CS DS ES FLAGS ; 12 bytes of stack required PUSH DS PUSH ES PUSHF CLD ; technically, this isn&#x27;t needed ; we&#x27;re copying all 64 KiB and ; could wrap backwards MOV AX, F000h XOR SI, SI MOV DS, AX MOV AX, A000h XOR DI, DI MOV ES, AX MOV CX, 8000h ; 64 KiB &#x2F; (sizeof(word) == 2) REP MOVSW ; DS:[SI] -&gt; ES:[DI] ; 16 bits at a time until CX == 0 POPF POP ES POP DS </code></pre> segment:offset addressing in real-mode<p>linear address = segment * 16 + offset<p>With the exception of some memory areas are mapped only by hardware decoding the segment but not the offset to where reads beyond offset FFF0 wrap around instead of pointing to adjacent memory.<p>AC00:FFFF (BBFFFh linearly) != B000:BFFF<p>There are variations of real mode on 286+ that use linear flat addressing outside of protected mode (it would be 16 MiB for 286 and 386SX, and 4 GiB max for 386+) by messing with the hidden masks of the segment registers by switching to protected mode temporarily. The downside is all of the system provided (ROM) real-mode interrupt handlers, OS, and drivers would need to be rewritten for this different addressing scheme. It&#x27;s called unreal mode. Hypothetically, you could algorithmically transpile ROM code by parsing instructions and rewriting them. Real-mode interrupt handlers are stored in a table of 256 far pointers at 0000:0000 to 0000:03FFF.
评论 #35675376 未加载
sbissonabout 2 years ago
I had a third-party shadow ROM kit for a BBC Micro in 1984; it let me back-up and load add-on ROMs into its memory and switch between them quickly.
评论 #35675523 未加载
smilesprayabout 2 years ago
The Amiga 1000 had to get the Kickstart ROM from floppy into RAM in 1985.<p>I think that counts.
评论 #35671039 未加载
评论 #35672083 未加载
antijavaabout 2 years ago
The TRS-80 CoCo used ROM shadowing to allow access to all 64K of RAM. The default mode was 32K RAM and 32K ROM.
评论 #35674723 未加载
hyperman1about 2 years ago
While discussing RAM, can someone clear up another minor conundrum for me: How does a current x86 chipset map RAM modules to linear adresses? They can differ in size, so the mapping is probably dynamic? But I suppose an adder causes latency? Or is everything just mapped with big holes between modules, with CPU paging fixing up the mess?
评论 #35678257 未加载
gladiatr72about 2 years ago
Nice write up. Hadn&#x27;t thought about this since I was a kid.