wAxpander with wAx2

Basic and Machine Language

Moderator: Moderators

User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

wAxpander with wAx2

Post by chysn »

Thanks to MCes's super Jolly Cartridge PCB, I can realize a two-year-old ambition of combining wAx and RAM on a single cartridge. This product, called wAxpander, provides 27K RAM and an updated version of the wAx assembler on a single cartridge.

I'm pretty excited about the software updates. The original version of wAx is a BASIC extension with about 20 tools, each of which uses a different character to specify the tool. For example, @ is for Assembly, & is for Copy, period and comma are for Disassembly, etc. The new version consolidates every wAx tool to a single wedge character (the period), with the tool now represented by a letter (in most cases) or a symbol. The commands in wAx2 are usually the same as those of VICmon, so that people familiar with other 6502 monitors don't need to relearn command names. For example

Code: Select all

@1800 LDA #"J"
@1802 "HELLO"
becomes

Code: Select all

.A 1800 LDA #"J"
.A 1802 "HELLO"
To do a search,

Code: Select all

/1800 JSR $FFD2
or
/1800:20 D2 FF
or
/1800 "HELLO"
becomes

Code: Select all

.H 1800 JSR $FFD2
or
.H 1800:20 D2 FF
or
.H 1800 "HELLO"
As you can see, I don't attempt to maintain VICmon's actual syntax, because wAx does almost everything better, but I think there's value to bringing the command names in line with traditional monitors.

Every time a wAx2 command finishes, wAx2 provides a prompt, either for the next address (in the case of assembly or lists), or a simple period prompt. This provides the illusion of staying "in wAx" to execute multiple commands. Or you can press DEL or X/RETURN, or STOP/RESTORE to go back to entering BASIC commands. This makes the extra period much less burdensome, while allowing a developer to use (or build) other BASIC extensions using wAx.

Since wAx2 will occupy Block 5, I can expand the available tools up to 8K. One or more commonly-used plug-ins will be promoted to a full-time tool (disk directory with search, at the very least). Additional plug-ins, including wAxfer--a Bluetooth PC-to-VIC transfer system--will be part of the included software.

My target date for making cartridges available is early March. Revising the printed manual is going to be the hardest thing to do, and that'll take some time. Most other things, like chips and cartridge labels, are already on order.
Last edited by chysn on Wed Feb 23, 2022 5:50 am, edited 3 times in total.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: wAxpander with wAx2

Post by AndyH »

Nice. Wax is an amazing tool and this sounds like a huge step up. What hardware would you need for the Bluetooth support?
--
AndyH
HEWCO | Vic 20 blog
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

AndyH wrote: Mon Jan 17, 2022 1:56 am What hardware would you need for the Bluetooth support?
The problem I'm trying to solve is the annoyance of swapping SD cards to move test builds from my computer to a real VIC-20. Usually this is after the program has been mostly tested in VICE, and I'm making small and frequent changes (for example, things like colors, which behave differently on real VIC+1702, or playability tweaks). It's always "run build script, copy to SD card, unmount SD card, stick in SD2IEC, load, test, pop out SD card, stick in computer, repeat." Ugh.

So wAxfer allows me to use a terminal program on the computer (Decisive Tactics Serial for macOS) to wirelessly load a program to the VIC at 38400 baud (https://www.youtube.com/watch?v=R3R7I1CJTE0&t=22s) with no swapping of physical media.

One of the goals is to have the hardware barrier be as low as possible. It's just an Arduino Nano connected to an HM-10 Bluetooth module, with some Arduino pins connected to the serial port. Here's a picture of the prototype device:
IMG_5067.jpg
The parts cost is less than $20 US, and it takes about 30 minutes to assemble at a deliberate pace. I'm going to see if I can simplify it a bit (I think I can remove the need for the switch). But it's reliable and fast.

This kind of transfer can also be done with just a USB cable and no Bluetooth. But it's way cooler with Bluetooth! Wi-Fi is also on the table, but I think that's beyond the point of diminishing returns...
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: wAxpander with wAx2

Post by AndyH »

Oh wow
--
AndyH
HEWCO | Vic 20 blog
User avatar
mathom
Vic 20 Dabbler
Posts: 80
Joined: Wed Aug 07, 2019 11:37 am
Location: Centennial, Colorado
Occupation: Software Engineer

Re: wAxpander with wAx2

Post by mathom »

Will the transfer just automatically allow for a hardwired usb connection also (as well as the bluetooth)? I already have that but have been struggling with how to quickly get files pushed to the VIC.
...mathom...
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

mathom wrote: Mon Jan 17, 2022 10:42 am Will the transfer just automatically allow for a hardwired usb connection also (as well as the bluetooth)? I already have that but have been struggling with how to quickly get files pushed to the VIC.
Yeah, you can just plug a USB cable right into the Nano. That’s how I proved out the user port code. But, once you use Bluetooth, you won’t go back to USB!
User avatar
mathom
Vic 20 Dabbler
Posts: 80
Joined: Wed Aug 07, 2019 11:37 am
Location: Centennial, Colorado
Occupation: Software Engineer

Re: wAxpander with wAx2

Post by mathom »

Very cool. wAx2 also sounds cool. I got one of the original carts with wAx in block 3. Having it in block 5 along with the new syntax will be a treat. And my birthday is in early March so... 8)
...mathom...
crusti
Vic 20 Drifter
Posts: 27
Joined: Sat Nov 28, 2020 5:22 am
Location: Southampton UK

Re: wAxpander with wAx2

Post by crusti »

The cost of shipping to the UK put me off from buying the wax cart, with all the extras built in I'll be more than tempted.

Any idea of the price?
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

crusti wrote: Mon Jan 17, 2022 5:31 pm Any idea of the price?
I'll know this soon. Just have a couple more unknown costs to get into the spreadsheet.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

You know, I've been putting wAx on 8K cartridges (2764 and 28C64B) for a couple years now, even though the main monitor was 4K. The original plan was to keep it at 4K and use 2732 chips. Why? I don't know. Because VICmon is 4K? Maybe. But it turned out that, in real life, 2732 chips are hard to find, expensive, and unreliable.

And so I'm going nuts. I've got 8K, and I'm going to use it. This means adding a lot of functionality, like help screens, new assembler syntax (arithmetic!), improving list tools with proper ranges.

One of the benefits of moving to VICmon/HESmon-type commands is that it frees up punctuation, so it doesn't need to be overloaded. For example, I've never been happy with - as the label sigil. But what I wanted it to be (@) was already in use. Now, since A is "assemble," I get @ back. And because > and < were in use as "save" and "load," I used H and L (postfix) to specify high and low byte, which felt kind of 8088. Now, since S and L are "save" and "load," I made > and < (prefix) high and low, matching most other 6502 assemblers. Here's a sample of the new assembler syntax:

Code: Select all

.@V 0314 ; IRQ VECTOR
.@C 900F ; SCREEN COLOR
.@D EABF ; DEFAULT IRQ
.
.A 1800    SEI
.A 1801    LDA #<@H
.A 1803    STA @V
.A 1806    LDA #>@H
.A 1808    STA @V+1
.A 180B    CLI
.A 180C    RTS
.A 180D @H LDY #3
.A 180F @@ INC @C
.A 1812    DEY
.A 1813    BNE @@
.A 1815    JMP @D
Note the new label assignment syntax (@{name} {value}). The old assignment syntax (A {value} @{name}) still works, of course. The new version makes constants clearer, I think.

Also note the prefix > and <, and the arithmetic, @V+1, nice for setting vectors and indexing things cleanly.

@ is still permitted as a label name, which I like for simple loops, except it's now @@ instead of -@.
Last edited by chysn on Thu Jan 20, 2022 10:25 am, edited 4 times in total.
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: wAxpander with wAx2

Post by AndyH »

That looks really good - I like the idea of improving features, functionality and help by moving to 8k.
--
AndyH
HEWCO | Vic 20 blog
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

I spent some time this evening working on arithmetic in conjunction with forward references. That is, adding or subtracting addresses when the value of the label isn't known until later. The trick was changing the value of the reference placeholder (which was always 0 in wAx), and then adding the value on resolution (instead of simply setting the value). This needed to support both absolute addressing and zero-page addressing with > and <. (zp),Y and (zp,X) are my next targets.

Arithmetic is simple, allowing addr-F to addr+F, which will handle most use cases, at least for me :D
Screen Shot 2022-01-20 at 10.06.24 PM.png
Update: (zp),Y and (zp,X) are done:
Screen Shot 2022-01-21 at 8.52.56 AM.png
Also, I just noticed that the disassembly range works a little different on VICmon. D 1800 1806 would show the instruction at 1806. I've updated that.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

Here's another thing that I've wanted to do since the beginning. wAx2 now interpolates BASIC single-letter floating-point variables when the variable name is prefixed with apostrophe:
Screen Shot 2022-01-21 at 11.48.34 AM.png
Variable interpolation can be used freely in conjunction with label assignment, arithmetic operations, and more. In fact, interpolation is observed not just in the assembler, but in all commands:
Screen Shot 2022-01-21 at 11.52.25 AM.png
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

Sticking, for now, with the integration-with-BASIC motif, wAx2 now sets the variable CP with wAx's Command Pointer.

Previously, the Command Pointer was called the Persistent Counter, but I wanted to differentiate the acronym PC and CP, as PC is a 6502 thing. The Command Pointer is the address of what will be the next operation, and it is referenced by the * symbol, which can be used almost anywhere. For list commands (like D), if you omit an address, the Command Pointer will be used in its place as an implicit address. The idea is that you can pick up where you left off:
Screen Shot 2022-01-21 at 8.04.23 PM.png
That's how wAx has always worked. The new feature is that now, whenever the Command Pointer is updated while a BASIC program is running, the BASIC variable CP is updated. When the CP is updated in direct mode, the variable is not used. This avoids unintentionally corrupting machine code or data in the BASIC space.
Screen Shot 2022-01-21 at 10.24.59 PM.png
CP-1 is displayed above (as the END), because CP is the next value that would be used had assembly continued.

Also notice that variable interpolation is used for the start address. This allows completely relocating the code via BASIC, even for code that doesn't use relative branching (for example, the text data).

Line 100 clears the symbol table with .@-, which is always a good practice when using wAx with BASIC assembly (if you choose to use labels).
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: wAxpander with wAx2

Post by chysn »

wAx supports multi-pass assembly during BASIC execution. wAx allocates memory for 12 unresolved forward references. If you overflow this space during a BASIC program, wAx will increment the integer variable UR% (Unresolved Reference count). Consider this program:

Code: Select all

10 .@-
15 UR%=0:P=P+1
20 .* 1800
25 FOR I = 1 TO 25
30 .A * LDA @R
35 NEXT I
40 .A * @R RTS
45 IF UR% THEN 15
50 PRINT "DONE:";P;" PASSES"
In the FOR/NEXT loop, 25 references to @R are used before @R is defined. wAx can keep track of the first 12, which are resolved when @R is defined on line 40. So the value of UR% is 13, the number of references that are left unresolved. Line 45 goes back to line 15, which resets UR%. This time, the rest of the references are resolved because @R is now in the symbol table.
Post Reply