BBG (Bubugao) Famiclones (BBG- Floppy 1 and BBG-98) were developed and manufactured in the 1990’s. These two machines are 8-bit and support reading and writing data using a inbuilt floppy drive. For more introduction, please visit [here].
The BASM (BBG Assembler) can be used to write *.CMD programs for BBG1 and BBG98. *.CMD are binary small executables (similar to *.COM for MS-DOS). The first two byte of *.CMD specifies the address of the program to start with. From the third byte, all the code and data are put continuously. The CPU of BBG can use address from $6100 to $FFFA, thus, the maximum size of *.CMD is $FFFA-$6100.
The basm.cmd comes with a single file. The assembler can be run under BBGDOS or BBGCDOS (Chinese version). basm.cmd supports compilation of *.asm files into *.cmd and *.obj.
*.obj contain object code but not runnable directly under BBGDOS/BBGCDOS. The basm.cmd does not support compilation of a bigger program *.exc (similar to *.exe on PC).
If you specify /cmd in the command line, the assembler will generate the corresponding *.cmd if you specify /obj it will target corresponding *.obj.
On BBG famicom clones, you can edit/create text files (source files) using WPS.exc (Word Processing System) or (edit.cmd). The edit.cmd is a quick and simple text editor but it can only be run under Chinese mode BBGCDOS and it requires the emm386.cmd resident in memory first.
Let’s create the following 6502 assembly source code that will output a single character to console.
1 2 3 4 5 6 7 8 9 10 | ; http://HelloACM.com include xnrdef.h org $8000 jmp start start: lda #"A" jsr putc lda #$00 jmp exit include tstputc.lnk |
; http://HelloACM.com include xnrdef.h org $8000 jmp start start: lda #"A" jsr putc lda #$00 jmp exit include tstputc.lnk
The org $8000 specifies the address to start assembly. the include will include another source code. Semicolons are used to start comments.
Like MS-DOS assembly, calling functions such as printing a string or reading a input requires calling interrupts and you have to specify which function explicitly to use. For example, the 9-th function of MS-DOS is for outputing a string. In BBG, there is not interrupt (int instruction), instead, you call the sub-routine using jsr and rts or jmp..
The file xnrdef.h (download) defines constants so that you don’t have to remember frequently used function numbers, such as:
DosIOEntry equ $580c
The function putc and exit are defined in tstputc.lnk and as follows:
;************************************************ ; A: char * ;************************************************ putc: tax lda #DosDisplayChar jmp DosIOEntry ;************************************************ ; A : exit mode . (0 or ff) * ;************************************************ exit: tay lda #DosProgramReturn jmp DosIOEntry
tax copies the data in register A to register X and tay copies the data in register A to register Y
We can issue basm /cmd tstputc.asm on BBG-DOS prompt to compile to tstputc.cmd
and similarly, basm /obj tstputc.asm is optional to create the tstputc.obj
During compilation, a map file e.g. sample.map will be generated, which contains the key-value pairs, something like this.
As shown above, the tstputc.cmd is generated and runnable, which will output a single character ‘A’ to console.
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: C/C++ Coding Exercise - Minimum Path Sum - Online Judge - Dynamic Programming - LeetCode
Next Post: PI Computation on BBG Famiclone using BASIC