CPCWiki forum

General Category => Programming => Topic started by: Bread80 on 17:46, 17 October 21

Title: Unassembled CPC6128 Firmware Now Available
Post by: Bread80 on 17:46, 17 October 21
I've been working recently to 'unassemble' the Amstrad ROMs (firmware and BASIC). 'Unassemble' meaning that I'm taking the existing commented disassemblies and turning them back into source code which can be modified and assembled back into functional code. Including assembly to a different target address.


The firmware portion is now available at https://github.com/Bread80/CPC6128-Firmware-Source


I'm hoping this will be a useful starting point for anyone who wants to build a modified CPC, including support for additional hardware, or to port the CPC's 'OS' to other Z80 based systems.


The BASIC code should be available in the next couple of weeks.
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: m_dr_m on 18:19, 17 October 21
Great work, thanks!


I'm likely to use this very neat modularisation when I'm ready to tackle: https://www.cpcwiki.eu/forum/applications/new-customisable-firmware-(lower-rom)/
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: robcfg on 20:51, 17 October 21
This is great stuff, thank you!
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: abalore on 16:43, 18 October 21
Amazing stuff!
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: Golem13 on 17:14, 18 October 21

Excellent work, very clean, which I applaud.
Thank you! :-*
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: Bread80 on 18:46, 31 October 21

And the BASIC is now uploaded https://github.com/Bread80/Amstrad-CPC-BASIC-Source


There's still much reverse engineering to do, mostly around the memory management and string handling stuff (also memory management  ;) ).


And you can't really expand it because there's no spare bytes in the ROM. So I'd like to split it across two ROMs, which means a lot of disentangling of command prompt and run-time code. But if you want so how BASIC does it's thing then it's worth a look, and I'd added quite a few notes in the readme to guide you.
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: pelrun on 05:37, 01 November 21
No spare bytes in the rom? What about that block of rst 0's hiding at the end of Errors.asm?  ;D
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: Bread80 on 14:28, 01 November 21
Well, yes. I'm not entirely sure if they're there for a reason I've not discovered and they'll break something if I remove them, or if they're just padding so they could say they've filled up the ROM and claim their paycheck  ;D
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: pelrun on 14:55, 01 November 21
If it was filled with literally anything other than the "single byte reset" opcode, I'd agree. But it's the smartest choice for a byte to fill unused ROM space on the CPC, rather than 0x00 (which would act as a NOP-sled, executing whatever random code/data was at the end of the block) or 0xFF (which looks like RST #38, jumping to the interrupt vector instead.)
Any buggy code which manages to jump to that block will immediately reset the machine back to a good state.
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: zhulien on 17:18, 01 November 21
Quote from: pelrun on 05:37, 01 November 21
No spare bytes in the rom? What about that block of rst 0's hiding at the end of Errors.asm?  ;D


If you boot with Amstrad brand, you can likely use those other brand bytes. 
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: Bread80 on 13:09, 02 November 21
The firmware ROM it's easy to free up some space - just delete the printer related stuff  ;D


BASIC ROM isn't so easy. You could delete functions you don't use, but many of the maths one are still used internally anyway.


In either case you could split some stuff off into another ROM, which I want to try and do, but calling between banks adds a lot of complexity.
Title: Re: Unassembled CPC6128 Firmware Now Available
Post by: Bread80 on 00:52, 21 November 21
I've updated the BASIC repository with reverse engineering of the variables, DEF FNs and arrays storage areas plus a few other areas. https://github.com/Bread80/Amstrad-CPC-BASIC-Source
There's now an example program which walks the variables/DEF FNs/arrays storage areas - see the Examples folder.
And I've written an article describing how the variables/DEF FNs/arrays storage areas function at http://bread80.com/2021/11/20/variables-def-fn-definitions-and-arrays-storage-in-amstrad-cpc-locomotive-basic/
Powered by SMFPacks Menu Editor Mod