wAx: Wedge Assembler/Disassembler

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

Re: wAx: Wedge Assembler/Disassembler

Post by chysn »

Nothing new today (remember, I'm "done"). So, a tip.

wAx doesn't include a memory fill tool. It's something that I've never once used with VICmon, so there were other priorities.

Edit: srowe pointed out a technique below that's way better than using BASIC, and pretty much makes this post obsolete. You can repeat a pattern with the Copy tool, like this:

Code: Select all

@start "PATTERN"
&start end *
But, with wAx's "hermit crab" syntax (@*), you can use a FOR/NEXT loop in BASIC. To fill an area with a hex byte pattern:

Code: Select all

10 *A000 ; INITIAL ADDRESS
20 FOR I=1 TO 100
30 @*:1122334455667788
40 NEXT I
This takes only about a second to execute, whereas the same thing with pure BASIC would take two iterators (loops or counters) and about twelve seconds.

You can also, of course, fill with text

Code: Select all

30 @* "ALL WORK NO PLAY"
or code

Code: Select all

30 @* NOP
or single binary bytes

Code: Select all

30 @* %11110000
Last edited by chysn on Fri Jun 19, 2020 7:44 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
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: wAx: Wedge Assembler/Disassembler

Post by srowe »

chysn wrote: Thu Jun 18, 2020 6:44 am wAx doesn't include a memory fill tool. It's something that I've never once used with VICmon, so there were other priorities.
Do you have a memory move tool? If so that can be (mis)used to do a fill. This is the definition of FILL in FIG FORTH

https://github.com/larsbrinkhoff/forth- ... .TXT#L3852

It performs a 'move' forwards by one byte after first setting the content of the start address to the fill byte.
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

srowe wrote: Thu Jun 18, 2020 7:05 am
chysn wrote: Thu Jun 18, 2020 6:44 am wAx doesn't include a memory fill tool. It's something that I've never once used with VICmon, so there were other priorities.
Do you have a memory move tool? If so that can be (mis)used to do a fill. This is the definition of FILL in FIG FORTH

https://github.com/larsbrinkhoff/forth- ... .TXT#L3852

It performs a 'move' forwards by one byte after first setting the content of the start address to the fill byte.
Indeed, there is a copy tool (I'll probably spend the weekend getting documentation up to date). Its syntax is

&start end dest

It can be "(mis)used" in exactly the same way. It would look like this for a 4K fill. Good tip, thanks!

Code: Select all

@A000 "PATTERN"
&A000 AFFF *
And you can also use the asterisk as multiple parameters for the Copy tool, like this:

Code: Select all

10 @A000 "MY TEXT"
30 FOR I=1 TO 4
40 &A000 * *
50 NEXT I
Here we have a block of text that doubles in size with each iteration (it's copying the full range of text, to the location after the last copy ended, so the first copy is A000 A007 A007, the next copy is A000 A00E A00E, then A000 A014 A014, and so on).
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
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

Although wAx is not necessarily designed for standalone development of big assembly language projects, it provides a way to overcome the limited size of its symbol table.

The default configuration provides for 18 user labels, one "special" re-usable loop label (@), and 12 unresolved forward references. The forward reference records are de-allocated when resolved, but it's still possible to overflow them if the program is big enough. Yesterday I realized that I had made a design mistake, in that wAx threw a ?TOO MANY FORWARDS error if unresolved references exceeded 12 at any time. This was a mistake because it placed a pretty hard limit on the complexity of a program loaded from BASIC.

The better approach was to provide a way for the user to detect if there were too many forward references during assembly, and to go back and resolve them. This is done by checking location 767 after assembly, and making a second pass if it's set:

Code: Select all

10 *-
15 *A000
20 @* LDA #-0L ; 1ST FORWARD
25 @* LDY #-0H ; 2ND
30 ... and on and on...
120 @* ORA -J  ; 16TH FORWARD
125 @* -0      ; SET ALL THE LABELS
130 ...and on and on...
200 IF PEEK(767) THEN 15
210 PRINT "DONE!"
Location 767 holds the number of unresolvable forward references since the last counter set (*nnnn). Line 200 checks this counter, and goes back to the beginning of the code for another pass. On the second pass, it has a complete symbol table, so all the outstanding forward references will be set as though they were regular references. After the second pass, 767 will be 0 and the assembly will end.

Note that if you're entering code in direct mode, you will get an error if you run out of references.

I was originally setting a BASIC variable U% for the number of unresolved references, but this was memory-heavy relative to its utility. You can't really set a variable with less than like 23 bytes of code, and just using a memory location leaves room for better things. I expect multi-pass assembly to be uncommon, but I want it to be possible.
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
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

I've completed the wAx documentation on the GitHub wiki:

http://beigemaze.com/wax
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
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: wAx: Wedge Assembler/Disassembler

Post by beamrider »

Good job. Very professional!
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

Here's the world's first wAx cartridge. I tried out the The Future Was 8-Bit PCBs and cases, with a socketed 2764. I'm not at all happy with the label. I'd like to get it on vinyl, at the right size.
IMG_3731.png
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
Kweepa
Vic 20 Scientist
Posts: 1315
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Re: wAx: Wedge Assembler/Disassembler

Post by Kweepa »

Looking good!
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

Kweepa wrote: Sat Jun 27, 2020 8:39 pmLooking good!
Thanks! I want to have the experience of releasing a VIC-20 cartridge, no matter how small the scale. So I'm getting some coated labels produced, and I'm having a really nice 7.5"x7.5" printed manual done. At least, it should be really nice, with the glossy soft cover, binding, and premium paper :) It'll be done around mid-July. The manual is a free PDF, of course, but it will also be available separately in its hopefully-awesome printed form.
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
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: wAx: Wedge Assembler/Disassembler

Post by Noizer »

chysn wrote: Wed Jul 01, 2020 3:44 pm
Kweepa wrote: Sat Jun 27, 2020 8:39 pmLooking good!
Thanks! I want to have the experience of releasing a VIC-20 cartridge, no matter how small the scale. So I'm getting some coated labels produced, and I'm having a really nice 7.5"x7.5" printed manual done. At least, it should be really nice, with the glossy soft cover, binding, and premium paper :) It'll be done around mid-July. The manual is a free PDF, of course, but it will also be available separately in its hopefully-awesome printed form.
I have no idea how else we can appreciate your fantastic performance than buying your product 👍
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

Noizer wrote: Wed Jul 01, 2020 4:15 pm
chysn wrote: Wed Jul 01, 2020 3:44 pm
Kweepa wrote: Sat Jun 27, 2020 8:39 pmLooking good!
Thanks! I want to have the experience of releasing a VIC-20 cartridge, no matter how small the scale. So I'm getting some coated labels produced, and I'm having a really nice 7.5"x7.5" printed manual done. At least, it should be really nice, with the glossy soft cover, binding, and premium paper :) It'll be done around mid-July. The manual is a free PDF, of course, but it will also be available separately in its hopefully-awesome printed form.
I have no idea how else we can appreciate your fantastic performance than buying your product 👍
I appreciate that! I'd like to take this opportunity mention that everything I do (that's not related to my actual job) is released under permissive licenses (M.I.T. for software, and one of the Creative Commons levels for everything else) as free open-source software. It's a movement I believe in, and I back it up with my time. So don't feel like you have to buy anything if you find this project worthwhile. I like cartridges myself, and I wanted to get experience with finding the parts I need, and coordinating things to have a reasonable cost. But that project is mostly about recouping costs. I refuse to clear a profit because filing small business taxes in the U.S. is a miserable slog. It's easy when all the numbers are 0. :D
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
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

For unexpanded VIC,
A Stupid wAx Trick!

Code: Select all

10 &1E01 1FF8 1E00
20 &00A1 00A2 9600
30 &9600 97F8 *
40 GOTO 10
or

Code: Select all

10 &9600:06
20 &9600 97F8 9601
30 &1E00 1E15 1FE4
40 &1E16 1FF9 1E00
50 GOTO 30
You're welcome. :)
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
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

The wAx manuals are here!
IMG_3745.jpg
Unfortunately, they were misprints, so they have to go back and be reprinted. But the quality is otherwise high, with a glossy cover, durable binding, and thick paper.

The cartridge labels should be here in a day or two.

Feature-wise, I added a user tool command vector so that you can add whatever kinds of tools you want to wAx. It's convenient because various command-line parsing resources are available within the tools. The manual will include a wAx API reference, formatted in a similar way as the KERNAL reference in the Programmer's Reference Guide. More about this in the next post.
Last edited by chysn on Wed Jul 15, 2020 9:50 pm, edited 1 time 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
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: wAx: Wedge Assembler/Disassembler

Post by chysn »

This is a post about how wAx's functionality can be extended with user tools. wAx doesn't have a diff tool built-in. But it has a vector to "plug in" new code and use it as a wAx tool. So I wrote a diff tool, which can be loaded from disk and installed. First, here's the installation process and example usage:
Screen Shot 2020-07-15 at 11.48.11 PM.png
The < tool is used to load the code, with the load tool telling you where the code starts and ends. The vector at $0005/$0006 is then set to point to the loaded tool at $7900. Then I set up a test case (two lines of text) and invoke the tool. This tool takes an address range, and then a target address. It compares the range byte-for-byte with the target, and tells you where the matches (in green) and differences (in red) start, and how many bytes long they are.

The code for this plug-in is below. The PDF manual documents the wAx API, the subroutines used in the tool. For the most part, they're very simple input/output routines for adding text, advancing pointers, parsing parameters, converting bytes to hex output.

I'll have a variety of examples on the Wiki. Also, several of these tools will be included in the cartridge version, since I'm only using half of a 2764 for wAx itself. It's not likely that I'm going to develop 4K of tools, but there will be some useful easter eggs.

Code: Select all

; wAx Diff Tool
; 'start end target
; Compares bytes from start to end of range (inclusive) and reports
; each byte that does not match the same offset in target.

; wAx API
EFADDR      = $a6               ; Effective Address
X_PC        = $03               ; External Persistent Counter
RANGE_END   = $0254             ; End of range
Buff2Byte   = $7000             ; Get 8-bit hex number from input buffer to A
CharGet     = $7003             ; Get character from input buffer to A
CharOut     = $7006             ; Write character in A to output buffer
Hex         = $7009             ; Write value in A to output buffer 8-bit hex
IncAddr     = $700c             ; Increment Effective Address, store value in A
IncPC       = $700f             ; Increment Persistent Counter
Lookup      = $7012             ; Lookup 6502 instruction with opcode in A
PrintBuff   = $7015             ; Flush output buffer to screen
ResetIn     = $7018             ; Reset input buffer index
ResetOut    = $701b             ; Reset output buffer index
ShowAddr    = $701e             ; Write Effective Address to output buffer
ShowPC      = $7021             ; Write Persistent Counter to output buffer

; Diff tool workspace
STATUS      = $0247             ; $00 = Non-Matching, $80 = Matching
COUNT       = $0248             ; Count of unmatched/matched bytes so far

*=$7900
Main:       bcc error           ; Error if the first address is no good
            jsr Buff2Byte       ; Get high byte of range end
            bcc error           ; ,,
            sta RANGE_END+1     ; ,,
            jsr Buff2Byte       ; Get low byte of range end
            bcc error           ; ,,
            sta RANGE_END       ; ,,
            jsr Buff2Byte       ; Get high byte of compare start
            bcc error           ; ,,
            sta X_PC+1          ; ,,
            jsr Buff2Byte       ; Get low byte of compare start
            bcc error           ; ,,
            sta X_PC            ; ,,
            lda #$00            ; Reset status and counter
            sta STATUS          ; ,,
            sta COUNT           ; ,,
            sta COUNT+1         ; ,,
            bcs Start           ; Setup OK, do compare
error:      jmp $cf08           ; ?SYNTAX ERROR, warm start

; Start comparison
Start:      jsr StartLine       ; Start address line
            inc RANGE_END       ; Increase the range by 1 for
            bne compare         ;   the comparison
            inc RANGE_END+1     ;   ,,
compare:    lda EFADDR+1        ; Is the effective address in 
            cmp RANGE_END+1     ;   the compare range?
            bcc in_range        ;   ,,
            lda EFADDR          ;   ,,
            cmp RANGE_END       ;   ,,
            bcc in_range        ; If so, check for byte match
done:       jsr Toggle          ; Toggle to show the right color
            jsr EndLine         ; Show the last result count
            rts                 ; Done!
in_range:   ldx #$00            ; Compare EA to PC
            lda (EFADDR,x)      ; ,,
            cmp (X_PC,x)        ; ,,
            bne differs
matches:    lda STATUS          ; If the byte matches, and the previous byte
            beq show_last       ;   differed, then toggle the status and reset
            bne next
differs:    lda STATUS          ; If the byte differs, and the previous byte
            bne show_last       ;   matched, then toggle the status and reset
            beq next
show_last:  jsr Toggle            
            jsr EndLine         ; Show the count
            lda #$00            ; Reset the counter
            sta COUNT           ; ,,
            sta COUNT+1         ; ,,
            jsr StartLine       ; Start a new line
next:       inc COUNT           ; Increment the count of match/unmatch
            bne inc_mem         ; ,,
            inc COUNT+1         ; ,,
inc_mem:    jsr IncPC           ; Increment the comparison counters
            jsr IncAddr         ; ,,
            jsr $ffe1           ; Check STOP key
            beq done            ; End the comparison if STOP
            jmp compare         ; Do the next comparison

Toggle:     lda STATUS
            bne toggle_off
            lda #$80
            .byte $34           ; DOP (skip byte)
toggle_off: asl
            sta STATUS
            rts

; Start Line
; Reset the output buffer, and add the addresses
StartLine:  jsr ResetOut
            lda #"$"
            jsr CharOut
            jsr ShowAddr
            lda #","
            jsr CharOut
            jsr ShowPC
            lda #":"
            jsr CharOut
            rts

; End Line
; Complete the line by showing the count in red (differences) or
; green (matches)            
EndLine:    lda COUNT           ; If the count is zero, don't
            bne report          ;   finish the buffer, because it's
            lda COUNT+1         ;   probably the first group of bytes
            bne report          ;   ,,
            rts                 ;   ,,
report:     lda $0286           ; Store current color
            pha                 ; ,,
            lda STATUS
            beq green
red:        lda #$1c            ; Red
            .byte $3c           ; TOP (skip word)
green:      lda #$1e            ; Green
            jsr CharOut
            lda COUNT+1         ; Show number of matches/no matches
            jsr Hex             ;   before the change
            lda COUNT           ;   ,,
            jsr Hex             ;   ,,
            jsr PrintBuff       ;   ,,
            pla                 ; Restore original color
            sta $0286           ; ,,
            rts

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
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: wAx: Wedge Assembler/Disassembler

Post by Noizer »

I will check it asap :wink:
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
Post Reply