Author Topic: Unassembled CPC6128 Firmware Now Available  (Read 936 times)

0 Members and 1 Guest are viewing this topic.

Offline Bread80

  • CPC464
  • **
  • Posts: 19
  • Country: england
    • Bread80.com
    • Awards
Unassembled CPC6128 Firmware Now Available
« 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.
like
24
Members reacted like:
ComSoft6128,HAL 6128,m_dr_m,Gryzor,Arnaud,Joseman,Cwiiis,XeNoMoRPH,
robcfg,BSC,Ast,Urusergi,pelrun,ajcasado,abalore,Golem13,
Alcofribas,Sid_,Nicolas Lecoq,zhulien,genesis8,roudoudou,Nich,menegator,

Offline m_dr_m

  • 464 Plus
  • *****
  • Posts: 327
  • Country: gb
  • http://orgams.wikidot.com/
    • OrgaMS!
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #1 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)/
like
0
No reactions

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.437
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #2 on: 20:51, 17 October 21 »
This is great stuff, thank you!
like
0
No reactions

Offline abalore

  • CPC6128
  • ****
  • Posts: 193
  • Country: es
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #3 on: 16:43, 18 October 21 »
Amazing stuff!
like
0
No reactions

Offline Golem13

  • CPC664
  • ***
  • Posts: 64
  • Country: fr
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #4 on: 17:14, 18 October 21 »

Excellent work, very clean, which I applaud.
Thank you! :-*
like
1
Members reacted like:
roudoudou,

Offline Bread80

  • CPC464
  • **
  • Posts: 19
  • Country: england
    • Bread80.com
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #5 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.
« Last Edit: 00:52, 21 November 21 by Bread80 »
like
8
Members reacted like:
ComSoft6128,roudoudou,Poliander,m_dr_m,pelrun,ajcasado,genesis8,norecess,

Offline pelrun

  • Supporter
  • 6128 Plus
  • *
  • Posts: 810
  • Country: au
    • index.php?action=treasury
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #6 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
like
0
No reactions

Offline Bread80

  • CPC464
  • **
  • Posts: 19
  • Country: england
    • Bread80.com
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #7 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
like
0
No reactions

Offline pelrun

  • Supporter
  • 6128 Plus
  • *
  • Posts: 810
  • Country: au
    • index.php?action=treasury
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #8 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.
like
1
Members reacted like:
Bread80,

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 921
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #9 on: 17:18, 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. 
like
0
No reactions

Offline Bread80

  • CPC464
  • **
  • Posts: 19
  • Country: england
    • Bread80.com
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #10 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.
like
1
Members reacted like:
revaldinho,

Offline Bread80

  • CPC464
  • **
  • Posts: 19
  • Country: england
    • Bread80.com
    • Awards
Re: Unassembled CPC6128 Firmware Now Available
« Reply #11 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/
like
9
Members reacted like:
Urusergi,norecess,Kris,roudoudou,m_dr_m,Nich,ajcasado,Singaja,
menegator,