Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port C64 KERNAL source as ultimate test case #19

Open
boeckmann opened this issue Apr 19, 2023 · 9 comments
Open

Port C64 KERNAL source as ultimate test case #19

boeckmann opened this issue Apr 19, 2023 · 9 comments
Assignees
Labels
testing Tasks related to testing

Comments

@boeckmann
Copy link
Owner

The original source can be found at https://github.com/mist64/cbmsrc/tree/master/KERNAL_C64_03

Repository of the port: https://github.com/boeckmann/c64krnl

It does assemble but some adjustments still have to be made, because the original source jumps around in the output file via .org. ASM6502 does not support this. But the changes are minor.

@boeckmann boeckmann added the testing Tasks related to testing label Apr 19, 2023
@boeckmann boeckmann self-assigned this Apr 19, 2023
@boeckmann boeckmann changed the title Port C64 KERNAL source als ultimate test case Port C64 KERNAL source as ultimate test case Apr 19, 2023
@boeckmann
Copy link
Owner Author

I managed to produce a nearly exact replica of the ROM file kernal-901227-03.bin shipped with the Vice emulator. The BASIC code at $E000-$E4D3 is replaced by $AA.

There is one byte of difference at $FF7E. But this is not an assembler error. The code I assembled contains

FF7D  4C 85 EE        42: 	JMP CLKHI       ;RELEASE THE CLOCK LINE***901227-03***

While the ROM code contains

FF7D  4C 8E EE        42: 	JMP CLKLO

Seems some sort of error was fixed in the source code that is not reflected in the VICE ROM, despite being named 901227-03. In the KERNAL V2 source the line is

JMP CLKLO       ;RELEASE THE CLOCK LINE

So either the Vice ROM is not what it pretends to be or the source change did not make it into the original C64 machine ROMS.

@boeckmann
Copy link
Owner Author

Commodore C64 KERNAL v3 and Commodore BASIC v2 are fully ported. The ROMs are operational in the emulator VirtualC64. Apart from the check sum bytes, which I left at value zero, the ROMs are exact replicas of the original ROMs.

@waltje
Copy link

waltje commented Apr 21, 2023 via email

@boeckmann
Copy link
Owner Author

Yes I am considering this but have not yet decided if I should implement it. The question is which checksum algorithms to implement, as there are many :-). It should be somewhat generic. And if I implement multiple algorithms it blows up the code.

Should ideally also be a function to be used within expressions to allow something like this:

sum .byte (0 - .chksum(ADD8, "file"...)) & $ff

At the moment a have no code to support calling functions within expressions. But that is another topic. 1k lines of code :-)

@boeckmann
Copy link
Owner Author

Kernal assembles in ~1 second on my Pentium MMX 166 machine running OS/2, which is not THAT bad I think. There are over thousend global symbols. Like expected, profiling reveals that the majority of time (75%) is spent searching the symbol table if not writing a listing. While this could be improved by changing the symbol table data structure, this test may be the worst case a) regarding the machine it is running on and b) the size of the symbol table. So for simplicity, I think I leave the symbol table structure as it is.

@waltje
Copy link

waltje commented Apr 21, 2023 via email

@boeckmann
Copy link
Owner Author

boeckmann commented Apr 21, 2023

Would be interesting to know how much of a performance improvement that is. Perhaps I will benchmark the two versions when I have time.

If I "enhance" my symtbl I think I will propably implement a hash tbl at the global level, with a fixed prime numbered bucket size of around 100-200. And on collisions do chaining with the current struct, and also for the local labels. Should reduce the strcmps for 1000 global symbols to around 10 for a lookup. Should not be that much code to implement this.

@waltje
Copy link

waltje commented Apr 21, 2023 via email

@waltje
Copy link

waltje commented Apr 23, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Tasks related to testing
Projects
None yet
Development

No branches or pull requests

2 participants