Page 3 of 3

Re: v6502

Posted: 19 Oct 2019, 09:56
by marcelk
Thanks! This was a fun project.

MSBASIC

The attached GT1 file below can be dropped in the online emulator for those who don't want to dig up their Arduino.

Supported are:
  • 9 digit floating point (40 bits) with transcendental functions
  • Pi symbol and constant
  • TIME and TIME$
  • Break with Ctrl-C
  • WAIT-6502 Easter Egg
Restrictions:
  • No file I/O (SAVE, LOAD, VERIFY)
  • Screen shows 11 lines of text
  • No line editing or delete (yet) Edit: shortly after writing this post we added simple line editing
  • Stack space is limited
Micro-Soft 6502 BASIC is a heavy user of both zero page and stack. With both crammed in the remainder of the Gigatron native zero page, don't expect deep recursion or many nested FOR statements. GOSUB calls eat 7 bytes of stack and each FOR loop eats 18(!) bytes. We have less than 60 bytes available, and originally MS even reserves 46 bytes as a safety margin (we reduced that of course). We might have to move CHRGET out of the zero page, but fundamentally the stack will always be small.

Some possible improvements are listed in the source:

Code: Select all

        XXX Win 256 bytes by moving init code to flank of screen
        XXX Fix POS() and TAB() (needs proper POSX system variable)
        XXX No line editting yet (DEL)
        XXX Lower STACK_BOT for more stack (3x nested FOR). Move CHRGET?
        XXX Support 64K Gigatron
        XXX Floating point buffer (STACK2) should move
        XXX TI$ doesn't wrap after "235959"
        XXX Check RND(-1)

v6502

Even with the above open issues in mind, this concludes the v6502 validation: no bugs were found since we hastily included it as an Easter egg(*) in ROMv4. So v6502 has now also become an "official" ROMv4 function and interface.json was updated accordingly.

(*) For those playing along at home or in the online emulator:
  • Force a double reset by holding PageUp for 5 seconds and then release
  • Munching squares appear after the second reset
  • Type Ctrl-C to enter the mockup Apple-1 environment
  • There is a disassembler at $400 and that takes it's address from $44/$45. For example:
To disassemble from address $ff00 (that's wozmon itself):

Code: Select all

44: 0 ff
400R
R
R
To munch squares again:

Code: Select all

280R
There's a really nice tutorial on SB-Projects. The wozmon entry points for ECHO, GETLIN, PRBYTE, PRHEX are in the same memory address as the original. But there are some important differences: our video system and wozmon are using zero page 0..$3f. Location $80 is reserved as well. That means that some classic examples that put something at address $30 will cause trouble. Furthermore, the stack lives in the top of page 0, but usually you won't notice. With all that in mind, you can write a little 6502 program that emits characters to the screen. This is from the original Apple 1 manual, with a bug fixed ("42"):

Code: Select all

40: A9 1 20 EF FF 38 69 0 4C 42 0 R
And here you'll notice another difference with the real system. After one round it halts and waits for a key press. That has to do with the special meaning of character 0 in the mockup.

Next?

A next phase can be to add 65C02 opcodes so we can use the FAT32 library from the SteckSchwein 6502 project. Adding instructions is easy. Adding addressing modes not so much. So we still have to see if this is doable.

Another idea is to hop over to v8080. Combine that with a block device and we have CP/M... and we get the file system with that. The real technical challenge there is the memory layout. And the screen resolution is insufficient for a minimal CP/M terminal.




.