Assembler for the VIC

Basic and Machine Language

Moderator: Moderators

aussiekraut
Vic 20 Newbie
Posts: 16
Joined: Wed Jan 31, 2018 11:19 pm
Location: Brisbane

Assembler for the VIC

Post by aussiekraut »

I've been dabbling with assembler programming many, many moons ago but never got too far. Every now and then, I drag out the VIC or fire up VICE and have a play with things but I just don't seem to be able to find a decent assembler I can actually get to work. Back in the day I had a VC1213 but used a little program called ISUS. That doesn't seem to be around anymore, so I tried Assembler 20, which doesn't seem to work, I tried Minimon, which when attached as a BIN file, just crashes the VIC when invoked and VICmon doesn't like me either...or me it. So what are others using here? I prefer to keep things to the base VIC though. I do have a 16KB extension card and can configure VICE accordingly but I also have a "TheVic20", which, to my knowledge, only deals with the base configuration. The idea is to write things using VICE and then use them on the others.

I set myself a challenge for a little program on the VIC but without a decent assembler, I won't get very far.
User avatar
Mike
Herr VC
Posts: 5130
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Assembler for the VIC

Post by Mike »

aussiekraut wrote:I tried Minimon, which when attached as a BIN file, just crashes the VIC when invoked [...]
The *.bin file of MINIMON does not feature a load address, it is explicitly intended to be burned on EPROM using a PC.

When you try to attach the file as cartridge in VICE, VICE will use an improper load address ($A000, to be exact).

You can load the pure *.bin file to the correct address, 38912, with the following boot loader:

Code: Select all

1 DN=PEEK(186):Z$=CHR$(0)
2 AD=38912:N$="MINIMON.BIN":GOSUB5
3 SYS38912
4 :
5 OPEN2,DN,2,N$+",S,R":GET#2,A$,B$:POKEAD,ASC(A$+Z$):POKEAD+1,ASC(B$+Z$):CLOSE2
6 SYS57809(N$+",S"),DN,0:POKE782,(AD+2)/256:POKE781,AD+2-256*PEEK(782):POKE780,0
7 SYS65493:RETURN
You'll need to activate RAM in I/O2 and I/O3 in VICE.

Once MINIMON is started up, use the command S "MINIMON.PRG",8,9800,A000 to save MINIMON as normal *.prg file.

Greetings,

Michael
rhurst
Omega Star Commander
Posts: 1375
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Re: Assembler for the VIC

Post by rhurst »

Back in the day, the programmer was the assembler: using a machine language monitor (and paper to track memory locations used) to directly enter opcodes and data into memory, if you were lucky, either in hexadecimal or mnemonic over POKE. Starting off using a VIC tool may be a nostalgic exercise for those that are experienced, but I would not recommend anything requiring LOAD, POKE, or attaching a VIC rom to start your journey. Just like I would not resort to having to also use TAPE SAVE operations off of a VIC. :P

Today, that process is much more convenient with the plethora of tools available, including VICE with its built-in monitor and debugger. But using a modern macro assembler (on Linux, Mac, or Windows) to generate your target 6502 program is ideal and worthy of the small investment to learn how to use any of them. Importantly, macro assemblers can generate a symbol table akin to that paper to track memory locations used, except you get to assign a friendly label like HISCORE, START and RESET to the static (or from dynamically linked) memory locations. Some of those symbol tables can also be used with VICE in conjunction with its debugger to assist with runtime troubleshooting using watch lists, breakpoints, and stepping operations -- sweet!!

I personally use the cc65 suite for its ca65/ld65 tools, because I am a command-line junkie:

Code: Select all

Summary      : A free C compiler for 6502 based systems
URL          : https://cc65.github.io
License      : zlib
Description  : cc65 is a complete cross development package for 65(C)02 systems,
             : including a powerful macro assembler, a C compiler, linker,
             : librarian and several other tools.
             :
             : cc65 has C and runtime library support for many of the old 6502
             : machines, including
             :
             : - the following Commodore machines:
             :   - VIC20
             :   - C16/C116 and Plus/4
             :   - C64
             :   - C128
             :   - CBM 510 (aka P500)
             :   - the 600/700 family
             :   - newer PET machines (not 2001).
             : - the Apple ]\[+ and successors.
             : - the Atari 8 bit machines.
             : - the Atari 2600 console.
             : - the Atari 5200 console.
             : - GEOS for the C64, C128 and Apple //e.
             : - the Bit Corporation Gamate console.
             : - the NEC PC-Engine (aka TurboGrafx-16) console.
             : - the Nintendo Entertainment System (NES) console.
             : - the Watara Supervision console.
             : - the VTech Creativision console.
             : - the Oric Atmos.
             : - the Oric Telestrat.
             : - the Lynx console.
             : - the Ohio Scientific Challenger 1P.
... but there are many others to choose from. Good luck and enjoy your journey! 8)
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
User avatar
Mike
Herr VC
Posts: 5130
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Assembler for the VIC

Post by Mike »

rhurst wrote:[...] I would not recommend anything requiring LOAD, POKE, or attaching a VIC rom to start your journey.
For the most time, using a symbolic (cross-)assembler surely is preferred over using a monitor, that is a given.

However there is the case for using the 'classic' approach, when you are dealing with foreign code: In foreign code, you have no symbols.
Just like I would not resort to having to also use TAPE SAVE operations off of a VIC. :P
Point taken. Me neither. :mrgreen:

Cheers,

Michael
User avatar
Wilson
Vic 20 Devotee
Posts: 250
Joined: Mon Sep 28, 2009 7:19 am
Location: Brooklyn, NY

Re: Assembler for the VIC

Post by Wilson »

Let's not forget that coding with a monitor is cool and fun ;)

I think there's a lot of merit to learning on the "real" machine. The exposure you get to the hardware while learning is valuable in and of itself. There are a lot of things I would probably change in my own programming journey, but I learned on a monitor (even in 2008) and if I were to do it all again I would do the same.

That said, I would probably either get a physical MINIMON cart or choose a monitor cartridge image that VICE currently supports. I think even a simple bootloader would've scared me when I was new to the Vic :P
groepaz
Vic 20 Scientist
Posts: 1265
Joined: Wed Aug 25, 2010 5:30 pm

Re: Assembler for the VIC

Post by groepaz »

I would probably either get a physical MINIMON cart or choose a monitor cartridge image that VICE currently supports.
That leads to the question whether such dedicated "minimon" cartridge actually exists - or was it written to be used with one of the multipurpose cartridges (or an internal ioram expansion)? if it is the former i can add the cartridge type to VICE quickly :)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
tokra
Vic 20 Scientist
Posts: 1185
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: Assembler for the VIC

Post by tokra »

groepaz wrote: Wed Sep 18, 2024 12:25 pm
I would probably either get a physical MINIMON cart or choose a monitor cartridge image that VICE currently supports.
That leads to the question whether such dedicated "minimon" cartridge actually exists - or was it written to be used with one of the multipurpose cartridges (or an internal ioram expansion)? if it is the former i can add the cartridge type to VICE quickly :)
A few prototypes exist. I am a lucky owner. It looks like this:

viewtopic.php?p=115929#p115929

The MINIMON-cartridge is more than just the monitor, basically it can go between the VIC and any other cartridge. It features an EEPROM with memory from $9800-$9fff which can be made visible to the VIC by way of a switch. It also features a reset-button that can circumvent the "A0CBM"-signature of other cartridges if you press it longer, making it a nice tool to dump any game cartridge.

So, the MINIMON-cartridge is much more than just a simple monitor-cartridge, but basically a great hacking tool for the VIC. It even works together with cartridges like MegaCart and Final Expansion that use the $9800-$9fff-area since you can use the switch on the MINIMON-cartridge to flip this memory-area between the host-cartridge or the slave-cartridge.

So, while the MINIMON-software can run as a great machine-language-monitor on its own if you have IO-RAM available, the cartridge can do such much more. Also see the seminar from this years Revision-demoparty on this if you are interested in seeing the cart in action:

https://youtu.be/LiPrL9788wU?si=n6mBwJiIxIod9hUa
groepaz
Vic 20 Scientist
Posts: 1265
Joined: Wed Aug 25, 2010 5:30 pm

Re: Assembler for the VIC

Post by groepaz »

Are the schematics available?
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
aussiekraut
Vic 20 Newbie
Posts: 16
Joined: Wed Jan 31, 2018 11:19 pm
Location: Brisbane

Re: Assembler for the VIC

Post by aussiekraut »

Thanks mate. I'll give it a try.

Cheers
User avatar
Mike
Herr VC
Posts: 5130
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Assembler for the VIC

Post by Mike »

groepaz wrote:Are the schematics available?
Yes they are. See the project's repository at sourceforge, under files/cartridge and files/adapter.
groepaz
Vic 20 Scientist
Posts: 1265
Joined: Wed Aug 25, 2010 5:30 pm

Re: Assembler for the VIC

Post by groepaz »

Cool, thanks, will have a look
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Mike
Herr VC
Posts: 5130
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Assembler for the VIC

Post by Mike »

groepaz wrote:Cool, thanks, will have a look
In the meantime, and with cartconv in GTK3VICE 3.9, I could successfully make a *.crt file out of the raw binary of MINIMON (download):

Code: Select all

cartconv -t rabbit -i monitor.bin -o minimon.crt -n "VIC-2020 MINIMON" -l $9800
At the moment it is sailing under a false flag - the Rabbit Tape accelerator also puts its firmware at $9800 -, but that's fine for now. Main advantage is, the tool now sits write protected in I/O (which is not the case when soft-loading a *.prg to RAM in I/O).

For those interested, don't bother to use the *.crt file with any VICE version older than 3.9!


Edit: as has been noted in another thread, the use of "-l $9800" is incorrect and should be "-l 0x9800" instead. Nevertheless, the *.crt file as downloadable here works fine - internally, cartconv overrode the wrongly parsed load address from an internal table with the correct value. :)
groepaz
Vic 20 Scientist
Posts: 1265
Joined: Wed Aug 25, 2010 5:30 pm

Re: Assembler for the VIC

Post by groepaz »

If the hardware is basically the same, then it would be perfectly normal to re-use that type, of course - same is done with C64 (else the list of types would be really really long :))
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Mike
Herr VC
Posts: 5130
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Assembler for the VIC

Post by Mike »

The firmware chip select logic works quite the same as Rabbit, yes, but the MINIMON cartridge hardware comes with some extras. :)
groepaz
Vic 20 Scientist
Posts: 1265
Joined: Wed Aug 25, 2010 5:30 pm

Re: Assembler for the VIC

Post by groepaz »

ok, noted. So another candidate ... :)
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Post Reply