Page 2 of 3

Re: Updated BASIC and KERNAL disassembly

Posted: Fri Nov 04, 2016 6:41 am
by Bobbi
The disassembly is a fascinating read!

Re: Updated BASIC and KERNAL disassembly

Posted: Fri Nov 04, 2016 7:17 am
by Bobbi
Incidentally, it doesn't assemble using xa65 for Linux (my usual asm.)

Here is the error log if you are interested. The -M flag tells the assembler to allow colons within comments, which is otherwise an error.

Looking at this closer it seem the lines that fail have a colon literal (for example

Code: Select all

SBC #':'
) so I am going to guess this is actually a bug in how xa65 handles colons in the input!

The branch out of range errors are more interesting. I will have to look at those and see if they are false positives.

I will have to see who, if anyone, maintains xa65. It seems the package has a Debian maintainer.

Code: Select all

bobbi@fluffy:~/VIC20$ xa -M -o foo combined_ROMs.asm 
 SBC #':'   ; subtract ":"
combined_ROMs.asm:line 2204: c5d6:Syntax error
combined_ROMs.asm:line 2204: c5d6:Syntax error
 CMP #TK_DATA-':'  ; compare with the token for DATA-':'
combined_ROMs.asm:line 2208: c5da:Syntax error
combined_ROMs.asm:line 2208: c5da:Syntax error
 SBC #TK_REM-':'  ; subtract the token for REM-':'
combined_ROMs.asm:line 2216: c5e1:Syntax error
combined_ROMs.asm:line 2216: c5e1:Syntax error
 CMP #':'   ; compare with ":"
combined_ROMs.asm:line 2710: c809:Syntax error
combined_ROMs.asm:line 2710: c809:Syntax error
 LDX #':'   ; set look for character = ":"
combined_ROMs.asm:line 2980: c908:Syntax error
combined_ROMs.asm:line 2980: c908:Syntax error
 LDA #':'   ; set ":"
combined_ROMs.asm:line 3774: cc6d:Syntax error
combined_ROMs.asm:line 3774: cc6d:Syntax error
 ADC #':'   ; add character ":" ($30+$0A, result is 10 less that value)
combined_ROMs.asm:line 8061: def6:Syntax error
combined_ROMs.asm:line 8061: def6:Syntax error
 CMP #':'   ; compare with ":"
combined_ROMs.asm:line 8955: e392:Syntax error
combined_ROMs.asm:line 8955: e392:Syntax error
combined_ROMs.asm:line 4058: cdd1:Branch out of range error
combined_ROMs.asm:line 4062: cdd5:Branch out of range error
combined_ROMs.asm:line 4844: d0fc:Branch out of range error
combined_ROMs.asm:line 5041: d1c2:Branch out of range error
Break after 20 errors
EDIT: Reported the bug to the maintainer. BTW, the website for this assembler is http://www.floodgap.com/retrotech/xa/.

Re: Updated BASIC and KERNAL disassembly

Posted: Fri Nov 04, 2016 7:37 am
by Bobbi
If I replace all instances of ':' by $3a, then it assembles fine.

Code: Select all

sed s/\':\'/\$3a/g <combined_ROMs.asm >combined_ROMS2.asm
xa -M -o rom.img combined_ROMS2.asm
So that was the only issue.

Re: Updated BASIC and KERNAL disassembly

Posted: Fri Nov 04, 2016 7:42 am
by groepaz
andre fachat is the author of xa, you should be able to contact him via 6502.org or sth

Re: Updated BASIC and KERNAL disassembly

Posted: Fri Nov 04, 2016 7:55 am
by Bobbi
The maintainer email address I have is ckaiser@floodgap.com.

I don't know whether Andre still maintains it (it dates back to the 90s I believe, or even 80s).

Re: Updated BASIC and KERNAL disassembly

Posted: Fri Nov 04, 2016 12:25 pm
by srowe
I use xa and have already reported the issue. I run with a local patch but I think it caused a unit test to fail so hasn't been included.

Code: Select all

--- xa-2.3.6/src/xa.c.org       2014-07-10 20:22:32.000000000 +0100
+++ xa-2.3.6/src/xa.c   2014-08-14 21:01:33.757777896 +0100
@@ -1056,7 +1056,7 @@
           do {
                c=s[j]=l[i++];
 
-               if (c=='\"')
+               if (c=='"' || c=='\'')
                     hkfl^=1;
                if (c==';' && !hkfl)
                        comcom = 1;

Re: Updated BASIC and KERNAL disassembly

Posted: Sat Apr 22, 2017 4:24 am
by srowe
I've been steadily working through the remaining gaps in this, there are major updates to the RS-232 and screen routines. There's still some work to do, I could do with a maths wizard taking a look at some of the BASIC floating point routines and the low-level tape routines are incomplete.
basic_kernel.zip
(145.39 KiB) Downloaded 93 times
The latest copy is always available here http://eden.mose.org.uk/gitweb/?p=rom-r ... ;a=summary

Re: Updated BASIC and KERNAL disassembly

Posted: Sat Apr 22, 2017 1:04 pm
by Bobbi
Thank you so much for this!

I refer to your annotated disassembly quite a bit!!

Has anyone ever done this for the C64 ROMs? I am guessing they are not that different, but it would be interesting to compare and account for the differences.

Re: Updated BASIC and KERNAL disassembly

Posted: Sat Apr 22, 2017 1:32 pm
by srowe
There's some on GitHub

https://github.com/mist64/c64rom

Re: Updated BASIC and KERNAL disassembly

Posted: Sat Apr 22, 2017 3:55 pm
by sjgray
Here's another version with combined VIC/64 source:

https://github.com/sjgray/cbm-edit-rom/ ... rtKirk.asm

My site, but contributed by Edilbert. Included in one of my github projects.

Steve

Re: Updated BASIC and KERNAL disassembly

Posted: Sat Apr 22, 2017 4:25 pm
by Bobbi
Thank you --- I have some reading for the weekend now!!

Re: Updated BASIC and KERNAL disassembly

Posted: Sun Apr 23, 2017 12:37 am
by srowe
sjgray wrote:Here's another version with combined VIC/64 source:
This is very useful for comparing VIC vs C64 code. Any ideas which C64 ROM version this is?

Simon

Re: Updated BASIC and KERNAL disassembly

Posted: Sun Apr 23, 2017 8:37 am
by sjgray
srowe wrote:
sjgray wrote:Here's another version with combined VIC/64 source:
This is very useful for comparing VIC vs C64 code. Any ideas which C64 ROM version this is?

Simon
It's version 3 as seen at line 17283.

Steve

Re: Updated BASIC and KERNAL disassembly

Posted: Thu Jul 06, 2017 1:47 pm
by srowe
Just a note that there is a new release of xa that fixes the issue mentioned above.

Re: Updated BASIC and KERNAL disassembly

Posted: Wed Jan 03, 2024 8:05 am
by Mike
Hi, Simon,

in line 263 of your (at the time I write this most recent) Super Expander source, it reads:

Code: Select all

263         JMP (CBINV)             ; ?? handle restore via BRK vector ??
Some time ago I also had stumbled across this, as that one leads to unexpected behaviour of the [RESTORE] key with MINIMON. MINIMON itself plays nice as it checks for the A0CBM signature and lets a cartridge take precedence, however the BRK vector is also diverted and tapping [RESTORE] on its own now breaks into the monitor. :(

In the original course of action, the KERNAL BRK routine calls the lead out of the KERNAL NMI routine to do the BASIC warmstart, not the other way round. One can only think that indirect JMP in the SE code is a brainf*rt ... it really should have been JMP $A2C2 instead:

Image

(... of course fixing it that way is only possible with a soft loaded copy of SE ...)

...

On a related note, I have a suggestion for your latest RS 232 fix (the one in BLK5). You set the warmstart entry to point to $0000, ...

Code: Select all

*	=	$A000

	.WORD	RSCOLD
	.WORD	0			; unused
	.BYT	"A0",'C'+$80,'B'+$80,'M'+$80
... as some software could however divert the NMI vector or re-initialise it to the KERNAL default, you should rather point that entry to $FEC7 instead.

This continues the original NMI code after $FEC4 JMP ($A002), so when the KERNAL or some other program (like MINIMON) checks for the A0CBM signature, the KERNAL vectors are reset but at least it does not crash.

Greetings,

Michael