v6502

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice.
monsonite
Posts: 62
Joined: 17 May 2018, 07:17

Re: v6502

Post by monsonite » 03 Jul 2019, 16:29

Hi Marcel,

Pleased to see your interest in VTL02.

I first came across this a few years ago when I found the original paper describing this "Very Tiny Language" which appeared initially in 1976 following the introduction of the Altair computer. It was quite an achievement to squeeze a usable, interpreted language into just 768 bytes of 6800 code.

The language was revisited some 30 years later with VTL-2 - here

http://www.altair680kit.com/manuals/Alt ... chable.pdf

Now that it has been ported to the 6502 and with added features it makes it accessible to the Gigatron, and chronologically correct for a machine inspired by mid-1970s TTL technology.

I'm looking forward to seeing it part of a future ROM offering.


regards


Ken

User avatar
marcelk
Posts: 400
Joined: 13 May 2018, 08:26

Re: v6502

Post by marcelk » 11 Jul 2019, 09:51

Testing has progressed. We can run Microchess now. Video: https://youtu.be/KBdDg5JfVs8

Screenshot 2019-07-11 at 17.06.35.png
Screenshot 2019-07-11 at 17.06.35.png (844.87 KiB) Viewed 864 times

Changes are:
  • It runs in full
  • On true TTL :-)
  • Without VGA timing errors
Microchess is about 1K in size and was written in 1976 by Peter Jennings for the KIM-1. The 6-digit hex output represents the KIM-1 LED display output. They give the piece, from-square and to-square. The commands I type:
  • C - Clear position
  • E - Exchange sides
  • P - Start thinking and make a move
  • Q - Quit into wozmon
It runs in "Super Blitz" mode to make it bearable. In the video you can see me change the VGA mode twice to speed up the program more.

I will push it into GitHub later after I have resolved a number of merge conflicts. Surprisingly, none concern the emulator itself.

User avatar
marcelk
Posts: 400
Joined: 13 May 2018, 08:26

Re: v6502

Post by marcelk » 13 Jul 2019, 13:34

Wozniak and Baum's 476-byte disassembler, looking at itself.

Screenshot 2019-07-13 at 15.32.58.png
Screenshot 2019-07-13 at 15.32.58.png (84.25 KiB) Viewed 829 times

monsonite
Posts: 62
Joined: 17 May 2018, 07:17

Re: v6502

Post by monsonite » 13 Jul 2019, 14:45

Marcel,

Another useful tool to make v6502 development easier.

I wrote a Z80 disassembler in BASIC whilst at school - but this is very concise.

Good Work!


Ken

User avatar
marcelk
Posts: 400
Joined: 13 May 2018, 08:26

Re: v6502

Post by marcelk » 01 Aug 2019, 19:28

Despite summer break, there's still some testing on the v6502 mode that crept through: VTL02 now works and is in GitHub. VTL-2 is a cute tiny interactive programming language that has its origins on the Altair 680. VTL02 is Mike Barry's port of it to the 6502. His port is still under 1K!

Screenshot%202019-07-28%20at%2013.51.40.png
Screenshot%202019-07-28%20at%2013.51.40.png (47.53 KiB) Viewed 740 times

It's small yet powerful. Here's a shootout with TinyBASIC in calculating the primes under 1000:

Code: Select all

VTL02 on v6502     TinyBASIC on vCPU
--------------     -----------------
10 N=7             10N=7
20 M=4             20M=4
30 D=5             30D=5
40 E=2             40E=2
50 X=N/D           50IFN%D=0GOTO100
55 #=%]100
60 D=D+E           60D=D+E
70 E=6-E           70E=6-E
80 #=N>(D*D)[50    80IFD*D<=NGOTO50
90 ?=" ";          90?" ";N;
95 ?=N
100 N=N+M          100N=N+M
110 M=6-M          110M=6-M
120 #=N<999[30     120IFN<999GOTO30
#=1                RUN
--------------     -----------------
Elapsed:           Elapsed:
1m14.9s            1m16.0s
v6502 and TinyBASIC nicely balance out their inefficiencies.

The other realisation I had the other day is that we now effectively have a second C compiler to toy with: cc65. This might be a quicker way to get existing SDcard/FAT C libraries running on the platform.

User avatar
marcelk
Posts: 400
Joined: 13 May 2018, 08:26

Re: v6502

Post by marcelk » 07 Oct 2019, 08:00

Next stage of testing v6502 has to be Micro-Soft BASIC with floating point. We're not quite there yet as it goes awry after the memory check. But by reorganising the video indirection table we can squeeze in the entire 8.3 KB BASIC binary and don't have to compromise too much on screen space. We should get 3584 BASIC bytes free on the stock 32K system.
Attachments
Screenshot 2019-10-07 at 09.43.33.png
Screenshot 2019-10-07 at 09.43.33.png (76.41 KiB) Viewed 527 times

User avatar
marcelk
Posts: 400
Joined: 13 May 2018, 08:26

Re: v6502

Post by marcelk » 10 Oct 2019, 17:43

The whole thing is still a bit shaky, but now this significant part already works: we have floating point (just in time for VCF Berlin)!
Attachments
FP.png
FP.png (70.34 KiB) Viewed 498 times

kerouanton
Posts: 19
Joined: 27 Jun 2018, 18:40

Re: v6502

Post by kerouanton » 11 Oct 2019, 09:10

Very impressive! It's very nice to see a Commodore Basic running on the Gigatron ;-)

User avatar
marcelk
Posts: 400
Joined: 13 May 2018, 08:26

Re: v6502

Post by marcelk » 16 Oct 2019, 19:52

Apart from Ctrl-C not yet working, it's otherwise stable. With 3583 bytes free it has the same free memory as the VIC-20. This is really a coincidence.

This is the BASIC that Paul Allen and Bill Gates wrote with Monte Davidoff and Ric Weiland, and for which they started Microsoft, or spelled Micro-Soft back then. They licensed it to many microcomputer builders, amongst others to Commodore. The version we have running is an early one for the Commodore PET.

Although the system can interpret 6502 code, there still was work to do: code, buffers, zero page variables and stack needed relocation. But that wasn't the biggest hurdle as Michael Steil's excellent set of reconstructed assembly sources made that relatively painless. The main problem was to create a sufficiently large continuous memory space. Although the Gigatron has 32K of RAM, 19KB of that is used for screen memory and the remainder is heavily fragmented. For example, by default the largest continuous block we have is just 512 bytes. BASIC itself needs 8KB, plus we need some K's for user program and variables. Ouch...

The first win is to disable the sound channels 2 through 4. That creates a continuous block from $200 to $800. For this trick you need ROM v4.

The next step is to compress the video memory. Our resolution is already nothing, but we can always lower it even more! Of the 120 visible pixel lines, every 8th is always empty. At least, as long as we only use capitals, and for a mid-1970s BASIC that's perfectly acceptable. The empty pixel lines can then be shared for all rows of text. That saves 14*256 = 3585 bytes already.

The last trick is to increase the spacing between text lines from 1 to 4. This reduces the text lines from 15 to 11, but yields 4 * 7 * 256 =7,168 bytes.

Of course we then went overboard and added a flashing cursor, we made sure that the WAIT 6502 Easter Egg works, and that there is a π-symbol. The Gigatron doesn't have that in its font, but it does have T and U.... And... the font is stored without horizontal spacing, so there's our glyph:

Code: Select all

  R         S         T   pi    U
  v         v         v   v     v
  x x x x . . x x x . x x # # # # . . . x
  x . . . x x . . . . . . # . . # . . . x
  x . . . x x . . . . . . # . . # . . . x
  x x x x . . x x x . . . # . . # . . . x
  x . x . . . . . . x . . # . . # . . . x
  x . . x . . . . . x . . # . . # . . . x
  x . . . x x x x x . . . # . . . # x x .
  0 1 2 3 4 5 6 7 8 9 a b c d e f 1 1 1 1
  ^                               0 1 2 3
  font82up
Good enough for me:
Attachments
Screenshot 2019-10-16 at 21.28.41.png
Screenshot 2019-10-16 at 21.28.41.png (33.44 KiB) Viewed 422 times

at67
Posts: 81
Joined: 14 May 2018, 08:29

Re: v6502

Post by at67 » 17 Oct 2019, 14:03

This is very impressive, especially the effort you put into scrounging up as much free available, (and contiguous), RAM as possible.

Post Reply