The 6800 processor is the first by Motorola(read about the real first 6800) and it organizes instructions and data using Big-Endian mode (Hi-Byte first) – as opposed to all Intel style processors, which organizes instructions and data in Little-Endian mode (Lo-Byte first).
Below is a short write up on what happens if you use TASM to assemble 6800 assembly code – I’m using version 3.2. Their documents state that it supports the 6800, and it even has a assembler directive in their *.tab file, called “.MSFIRST” to control the Endian mode. Evidently is doesn’t.
FIRST, no Assemblers are created equal.
There have been so many flavors of Assemblers – where the syntax between them can be different even for the same processor. This source code is for the MIKBUG Assembler. If you like to use TASM, then you have to convert many of the Assembler directives and mnemonics used in the code. I suppose you already have the -68 option used in your make file. Then you only need the following files in your project dir.
There is a “moto.h” packaged with TASM which helps to define the mikbug directives to help convert programs. You can use the include directive to help with this. But since half of the problem – and just as big – is that not everyone uses the same assembly mnemonics, which makes it a pain in the ass. You can look up the the conversions for 6800 mnemonics from TASM in the “TASMTABS.HTM” file.
For example, [files attached]
MIKBUG TASM v3.2
ORG .ORG -period before the assembler directive
OFFSET RMB 2 OFFSET .BLOCK 2 -reserves # of memory locations,
FCB $D,$A,0,0 .BYTE $D,$A,0,0 -constants
and the following changes are needed because TASM is just stupid
MIKBUG TASM v3.2
LDA A LDAA
LDA A LDAB
STA A STAA
STA B STAB
LDA B LDAB
CMP A CMPA
EOR A EORA
AND A ANDA
ORA A ORAA
SUB A SUBA
SUB B SUBB
SBC A SBCA
DEC A DECA
DEC B DECB
ASL A ASLA
and here the kicker,
TASM isn’t completely Endian-aware. The 6800 is a big-endian processor (Hi Btye first). It’s only good for instructions , so you can’t use the .WORD directive to store the address – for index address operations. This is the other problem with the “moto.h” header file. Even though the *.tab file for the 6800 has a directive for big-endian, it’s only good for instructions and not constants.
MIKBUG TASM v3.2
FDB .WORD ***does not work***
This is what it would look like in the listing file
0149 7126 42 TABLE FCC “B”
0150 7127 70 20 FDB BURN
0149 7126 42 TABLE .TEXT “B”
0150 7127 20 70 .WORD BURN
So a patch in this section would be needed to use TASM, to convert it to support big-endian for the index addressing with the X.reg
;CONVERT TABLE TO BIG-ENDIAN
;ONLY DONE ONCE IN PROGRAM
LDX #TABLE ;GET POINTER TO TABLE
INX ;INC X TO POINT TO LO-BYTE
CONVRT LDAB 0,X ;GET LO-BYTE
INX ;INC X TO POINT TO HI-BYTE
LDAA 0,X ;GET HI-BYTE
STAB 0,X ;PUT THE LO-BYTE IN BIG-ENDIAN
DEX ;DEC TO POINT TO LO-BYTE
STAA 0,X ;PUT THE HI-BYTE IN BIG-ENDIAN
CPX #TABLAST ;LAST ENTRY ?
BEQ U2708 ;YES, EXIT LOOP
INX ;POINT TO NEXT ENTRY
BRA CONVRT ;LOOP FOR NEXT ENTRY
U2708 LDS #$A042 ;GET STACKED
This line gets a new label
TABLAST .WORD TABEND ; NEW LABEL FOR LAST ENTRY OF TABLE
But you can avoid all this every time you want to use a Cross-Assembler by using a user friendly 6800 Assembler such as AS68 – strange how it’s the programmer who makes it non-user friendly for the same hardware in the first place. This one is almost 95% compatible with the syntax out of the Motorola assembly book. This one is case sensitive, so you have to convert all of the MIKBUG source code to lowercase. But at least it supports big-endian mode !!
I uploaded the AS68 cross-assembler in case you can’t find it online. It was a bit of chore for me to find it and I like to scavenge the Interwebs.
AS68 6800 cross-assembler
The Motorola Assembly workbook is another fine publication written for Motorola in 1977 to teach programmer how to use their 6800 processor. This can be downloaded here too:
Motorola 6800 Programming