Moving CEGMON to ROM

A project log for OSI SD Card Operating System (OSISDOS)

Ohio Scientific / UK101 SD Card based Operating System under Multicomp FPGA Computer 07/16/2020 at 12:280 Comments
[Path_To_RetroAssembler]/retroassembler.exe -d cegmon.bin cegmonDis.asm

The SD Card uses the following FPGA resources:

The overall resources show 98% of the logic is used. 

It might be worthwhile to free up some of the logic elements so it's not so tight. Part of that is due to Grant placing the CEGMON and character ROMs into logic instead of memory. He did that in order to have a minimal build with 4KB of SRAM available. With external SRAM the SRAM is now available for use by the card. So CEGMON and/or the character ROMs could be put into the FPGA as ROMs.

A better reason to move CEGMON to ROM is it's easier to work on the code if it's more easily assembled and loaded to the FPGA.

Assembler/Compiler Toolchain

I tried using the cc65 toolchain to produce the ROM file but ran into roadblocks. Although cc65 does have a lot of different outputs I couldn't convince it to produce S-Record or Hex output files.

I went to a 6502 group on Facebook and someone suggested retroassembler. It compiled the code and created a binary output. The command line is:

[Path_To_RetroAssembler]/retroassembler.exe cegmon.s -O=bin

I viewed the binary file in HxD and verified that it seemed to match the source file (sampled a few lines). 

retoroassembler even has handy disassembler in which can disassemble source code. The command line to run the disassembler is:

[Path_to_RetroAssembler]/retroassembler.exe -d cegmon.bin cegmonDis.asm

The binary file needs to be converted a .MIF file. I've used the srec_cat utility in my 68000 in an FPGA card design and it does the job nicely. The command line is:

[path_to_srec_utils]\srec_cat.exe cegmon.bin -Binary -o cegmon.mif -MIF

The result didn't run so I compared the code that was generated byte-by-byte against Grant's SEGMON. There were some differences. For instance, there were differences for the NMI and BRK/IRQ vectors at the end of the code:

The CEGMON source has the NMI at 0x0237 but the FPGA ROM file has NMI at 0x0130. 

CEGMON source file has BRK/IRQ at 0x0235 but the FPGA ROM file has BRK/IRQ at 0x01C0.

I found a few other differences and after some messing around was rewarded with the CEGMON display.

I was then able to tweek the source code and re-compile. Here's what I was rewarded with:


The result of the above was also a reduction in logic resources in the FPGA.

Bigger EPROM

I bumped the ROM size to 4KB leaving enough room (hopefully) to create the SD Card OS/driver. This leaves the modified CEGMON from $F800 to $FFFF and adds space for an SD card driver from $F000 to $F7FF. Since there is I/O from $F000-$F0xx, I've further reduced the new space so the new CEGMON ROM replacement goes from $F100-$FFFF.

This results in more space for logic and higher SRAM utilization.

The detailed breakdown by function is:

If I can get the SD Card to work, it could be useful to take the BASIC out of ROM and load it into the external SRAM from the SD Card.