Closed skx closed 3 months ago
Terrible trace is terrible, but it is alive!
$ go build . && ./cpmulator ~/Repos/github.com/skx/z80-playground-cpm-fat/dist/CPM/DISKS/B/MBASIC.COM
BASIC-80 Rev. 5.21
[CP/M Version]
Copyright 1977-1981 (C) by Microsoft
Created: 28-Jul-81
39986 Bytes free
Ok
10 print "OK"
run
IOK
POk
for I = 0 to 10
FOR Without NEXT
Ok
20 for i = 0 to 10
30 print i
40 next i
list
z10 PRINT "OK"
z20 FOR I = 0 TO 10
z30 PRINT I
z40 NEXT I
Ok
un
Syntax error
Ok
run
IOK
P| 0
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
Ok
So there are two issues really that needed to be solved for this to work, but its also tied up with console input:
However things are still a bit dodgy for two reasons:
SYSTEM
just hangs.Still getting spurious output, despite my "emulation".
Will work on it some more tonight. Added test code to #50 as a prototype of how to cleanup the input/status-checking code.
This is something that would be awesome to have, so it should be resolved.
When the binary runs we immediately get an error:
I do not believe that the syscall number there is correct, CP/M syscalls are implemented by loading hte operation-number in the
C
register and runningcall 0x0005
. I suspect what is actually happening here is that control-flow has gone wrong, and we're getting a random branch there.Now why might that be? Well I disassembled the binary and I see a bunch of
rst xx
instructions. Those are single-byte calls to specific addresses in the zero-page.For example:
So I think the issue here is that we don't actually setup any traps, or handlers, for those low addresses - and we're actually executing the contents of the FCB, DMA area, etc, etc.
To resolve this we need to add JMP handlers to point to the entry-point - or otherwise fake things so that this works - via more breakpoints, for example.