Virtual 6502 Suite Update

So, another update:

At last, the assembler got a button for downloading binary object files (this button is revealed as soon as there is a successful assembly). In a dialog, you may select either a standard binary file format or a Commodore PRG-file and then generate the respective binary file for download.

Speaking of PRG-files, this time it’s the Commodore machines that receive some love and extra care, more specifically a pseudo instruction to generate a BASIC preamble to the file. There’s .PETSTART for the PET and a BASIC start at 0x0401 and .C64START for the C64 and a BASIC start address of 0x0801. Both take an optional numeric argument for the line number of the SYS command (default is the current year) and a string or a list of strings for any line of REM text to go before this. (REM lines always start at line number “0”.)

This must be the first instruction before any “real” assembler instruction, since this will initialize the program counter to the respective BASIC start address, generate the BASIC preamble, which jumps to the first address available immediately following the BASIC text and picks up “regular” assembly there.

Here a small example using .PETSTART and 2 lines of REM-text, specifying “2021” as the line number for the SYS command (the current year would have been the default anyway):

.PETSTART 2021 "*** my amazing prg ***", "by me, 2021"
LDA #0
RTS

This results in the following listing,

pass 1

LINE  LOC          LABEL     CARD

   1  0401                   .PETSTART 2021 "*** my amazing prg ***\nby me, 2021"
   2  043D                   LDA #0
   3  043F                   RTS

pass 2

LOC   CODE         LABEL     INSTRUCTION

0401                         .PETSTART 2021 "*** my amazing prg ***\nby me, 2021"
>>>>  COMPILING BASIC PREAMBLE...
0401  1E 04                  $041E ;LINE LINK
0403  00 00                  $0000 ;LINE NO. ("0")
0405  8F 20                  ;"REM "
0407  2A 2A 2A               ;...
040A  20 4D 59               ;...
040D  20 41 4D               ;...
0410  41 5A 49               ;...
0413  4E 47 20               ;...
0416  50 52 47               ;...
0419  20 2A 2A               ;...
041C  2A                     ;.
041D  00                     $00   ;EOL
041E  30 04                  $0430 ;LINE LINK
0420  01 00                  $0001 ;LINE NO. ("1")
0422  8F 20                  ;"REM "
0424  42 59 20               ;...
0427  4D 45 2C               ;...
042A  20 32 30               ;...
042D  32 31                  ;..
042F  00                     $00   ;EOL
0430  3B 04                  $043B ;LINE LINK
0432  E5 07                  $07E5 ;LINE NO. ("2021")
0434  9E 20                  ;"SYS "
0436  31 30 38               ;TEXT "108
0439  35                     ;TEXT "5"
043A  00                     $00   ;EOL
043B  00 00                  $0000 ;END OF BASIC TEXT (EMPTY LINK)
>>>>  START OF ASSEMBLY AT $043D ("SYS 1085")
043D  A9 00                  LDA #$00
043F  60                     RTS

done (code: 0401..043F).

(Mind the educational aspects of the listing for pass 2! :slight_smile: )

…and in this object code:

0400: .. 1E 04 00 00 8F 20 2A
0408: 2A 2A 20 4D 59 20 41 4D
0410: 41 5A 49 4E 47 20 50 52
0418: 47 20 2A 2A 2A 00 30 04
0420: 01 00 8F 20 42 59 20 4D
0428: 45 2C 20 32 30 32 31 00
0430: 3B 04 E5 07 9E 20 31 30
0438: 38 35 00 00 00 A9 00 60
                     ↑
            assembly starts here

If, we down load this file (using the button “Download Binary” and selecting the “PRG” option) and drop it on a PET emulator, we’ll get:

### COMMODORE BASIC ###

 7167 BYTES FREE

READY.
LIST

 0 REM *** MY AMAZING PRG ***
 1 REM BY ME, 2021
 2021 SYS 1085
READY.
█

(This is a feature, I’ve been looking for for a long time in assemblers. – ACME has something similar, but this is a rather quirky macro and setting up a seamless start immediately after the BASIC text is somewhat difficult and you have to jump through some hoops to generate the ASCII codes for the SYS-address. In contrast, this is meant to work with as little hassle as possible on your side and out of the box.)

P.S.: Sorry for the lack of support for the VIC-20. This is mostly for my lack of knowledge regarding the various memory layouts of the machine (and also, how we may support this best). Any suggestions are welcome.

1 Like