-
Notifications
You must be signed in to change notification settings - Fork 0
Assembly Language
Given an assembly langue program called "bubble_sort.asm" you can compile it into a binary called "sort.bin" with the lwtools
lwasm bubble_sort.asm --6809 --list --symbols --6800compat --output=sort.bin --format=decb
You can create a new coco2 disk using the imgtool command that is part of MAME.
imgtool create coco_jvc_rsdos 180K-RS.DSK
Next you can write "sort.bin" to the newly created disk.
imgtool put coco_jvc_rsdos 180K-RS.DSK sort.bin sort.bin
Finally you can run coco2 with access to the new disk under MAME:
mame64 coco2 -skip_gameinfo -window -flop1 ~/projects/coco2/asm/bubble_sort/180K-RS.DSK
Once the coco2 boots under MAME, you can get a list of the contents of the disk.
DIR
Now load "SORT.BIN" to address location 4000 dec = $0fa0
LOADM "SORT.BIN",4000
The SORT.BIN program sorts the characters that are on the text display. The text display is memory mapped to $400. The text display is 32 chars across and 16 lines for a total of 512=$200 characters. Thus the character in the upper left hand corner of the display is at $400, and the bottom right hand character is at $400+$200-1 = $5FF.
To limit the number of characters that are on the screen type:
CLS
Now to run the SORT.BIN program type:
EXEC 4000
So the characters on the screen that will be sorted are:
OK
EXEC 4000
The output after running SORT.BIN is
CEEKOX
0004
Where "CEEKOX" is in the upper left hand corner and "0004" is in the bottom right.
The last instruction jumps to itself in an endless loop. So the coco2 machine freezes up at this point.
We can start up coco2 under MAME with the -debug flag
mame64 coco2 -skip_gameinfo -window -debug -flop1 ~/projects/coco2/asm/bubble_sort/180K-RS.DSK
This will pop up the debug window. In this window we can see the registers, memory contents, and disassembled source. In the command box in the bottom of the window you can type "help" to get information about the debug commands that are available.
We will load our program to location 4000 dec = $0fa0 so lets set a breakpoint there
bp fa0
Now lets start the machine running.
go
Now we can repeat the commands we did before to load and run our SORT.BIN assembly language program.
LOADM"SORT.BIN",4000
CLS
EXEC 4000
Now the debugger should be halted at $fa0 (4000 dec). We can step through assembly instructions with the 's' command.
If we want we can execute to the end of the program which is a $0fc8:
go fc8
The last instruction jumps to itself in an endless loop. If you want to do a soft reset of the machine, in the debugger you can type
go
softreset
The SORT.BIN will still loaded at 4000.
Here is a list of resources for Assembly Language programming for the coco2.
6809 Assembly Language Programming on the Color Computer Using MAME! This Youtube video gives a good overview on how to use the MAME debugger on your 6809 assembly language programs compiled with the lwtools.
TRS-80 Color Computer Assembly Language Programming This book has a copyright of 1983 and was published by Radio Shack. It covers assembly language programming on the coco using the EDTASM+ program.
TRS-80 Assembly Language Subroutines
Assembly Language Programming for the TRS-80 COLOR COMPUTER
LWTOOLS The main website for the LWTOOLS.
LWTOOLS manual A HTML version of the LWTOOLS manual.
imgtool doc imgtool is part of the mame distribution. It is used to create coco2 disk images.
imgtool doc More imgtool documentation. Seems to have info on --ascii flag the other link did not.
Disk Basic Commands Used to load a program into memory from disk.