davidgiven / ack

The Amsterdam Compiler Kit
http://tack.sf.net
Other
416 stars 59 forks source link

how to use the compiler to build bare metal test binary for i80 #281

Open ladmanj opened 1 year ago

ladmanj commented 1 year ago

Hello @davidgiven and others

I would like to try this compiler to build test binary from C code to place it in ROM sitting at 0x0000 in i8080 system. I would like to test the hardware, RAM, ports and so on. Is it possible to place the code right at the reset vector from C function or inline assembly?

Thank you

davidgiven commented 1 year ago

Yes, but no...

So the thing is that with these platforms it's not really possible to separate the platform from the operating system. The 8080 backend, in particular, is expecting to run out of RAM and with RAM at 0x000, and the first thing it will do is to copy a bunch of helper routines into the reset vectors --- look at mach/i80/libem/rst.s. This obviously won't work on your system.

But what you can do is to define a new platform, configured for your system, with startup code which knows about your ROM layout, etc. To do this you'll want to copy plat/cpm. Most of the code in there is for the CP/M system call library and the emulator, neither of which you're using. You'll want a very basic set of system calls for console I/O --- look at plat/pc86/libsys for an example of this (that platform produces bootable PC floppies). It isn't a great deal of work but it is, unfortunately, work!

If you want to go ahead --- and you may not, it could well be more effort than is warranted given that you want to use this for testing --- I'd be happy to assist. That environment would probably be a useful thing to have support for in the compiler.

ladmanj commented 1 year ago

Thanks for the quick response. Yes i want to go ahead, but I can't find any helpful documentation how to start with.