[Coco] Assembly .BIN -> .CCC/.ROM = SOLVED!
Johann Klasek
johann+coco at klasek.at
Thu Sep 4 10:31:04 EDT 2014
On Wed, Sep 03, 2014 at 09:47:36PM -0500, Chad H wrote:
> Ahh... when I was looking in the Rainbow IDE HELP > 6809 refernce at the
> opcode table and saw the DECD, I failed to see the note that '*' represented
> a 6309 code...oops. Anywhoo, I FINALLY got this bugger going perfectly!! :)
> Thanks to William Astle, Johann Klasek and Tormod Volden, you guys all made
> points that helped me debug this ..umm..bugger.
>
Just for elegance (efficiency also), if someone bother ... ;)
I would change Y <-> U as William pointed out already:
> org 49152 CoCo and compatibles map in ROM Paks here
>
> * LOADER
> BININ LDX #BINLOD INIT XFER DATA ADDRESS OFFSET
> CHKBLK LDA ,X+ GET BLOCK TYPE BYTE (00 = PREAMBLE,
> 255=POSTAMBLE)
> BNE ENDBIN IF <>0 THEN MUST BE END OF .BIN DATA
> (POSTAMBLE)
> LDU ,X++ GET BLOCK LENGTH(U)
- LDU ,X++ GET BLOCK LENGTH(U)
+ LDY ,X++ GET BLOCK LENGTH(U)
> LDY ,X++ GET BLOCK START ADDRESS(Y)
- LDY ,X++ GET BLOCK START ADDRESS(Y)
+ LDU ,X++ GET BLOCK START ADDRESS(Y)
> XFER LDA ,X+ GET SOURCE BYTE(A) FROM X
> STA ,Y+ PUT BYTE(A) AT Y
- STA ,Y+ PUT BYTE(A) AT Y
+ STA ,U+ PUT BYTE(A) AT Y
> LEAU -1,U MOVED BLOCK?
> CMPU #0
- LEAU -1,U MOVED BLOCK?
- CMPU #0
+ LEAY -1,Y MOVED BLOCK?
> BNE XFER NO
> JMP CHKBLK CHECK NEXT BLOCK
> ENDBIN LDU ,X++ GET BLOCK LENGTH (0000)
> LDU ,X++ GET EXECUTION ADDRESS(U)
Without the skipping read (if X is not expected to point after
the execution address) ...
- ENDBIN LDU ,X++ GET BLOCK LENGTH (0000)
- LDU ,X++ GET EXECUTION ADDRESS(U)
+ ENDBIN LDU 2,X GET EXECUTION ADDRESS(U)
> JMP [,U]
Is this really meant in this way? Register U contains already
the address where the execution should proceed, isn't it?
This would fetch the 2 bytes U is pointing at, which is the
effective address here (which is already the code itself).
If U already contains the address, simply jump there with
JMP ,U
Same as the original implemention does:
LDY ,X++ GET EXECUTION ADRESS(Y)
STY EXECJP
JMP [EXECJP]
or
LDY ,X++
JMP ,Y
or
JMP [,X]
Back to the version above:
This could be shorten further (without reading the block length)
with
ENDBIN JMP [2,X]
(replacing both LDUs and the JMP)
In addition I prefer BRA instead of JMP (to keep it relocatable, just
in case).
Putting altogether:
org 49152 CoCo and compatibles map in ROM Paks here
* LOADER
BININ LDX #BINLOD INIT XFER DATA ADDRESS OFFSET
CHKBLK LDA ,X+ GET BLOCK TYPE BYTE (00 = PREAMBLE, 255=POSTAMBLE)
BNE ENDBIN IF <>0 THEN MUST BE END OF .BIN DATA (POSTAMBLE)
LDY ,X++ GET BLOCK LENGTH(Y)
LDU ,X++ GET BLOCK START ADDRESS(U)
XFER LDA ,X+ GET SOURCE BYTE(A) FROM X
STA ,U+ PUT BYTE(A) AT U
LEAY -1,Y MOVED BLOCK?
BNE XFER NO
BRA CHKBLK CHECK NEXT BLOCK
ENDBIN JMP [2,X] SKIP BLOCK LENGTH (0000)
AND JUMP TO EXECUTION ADDRESS
BINLOD FCB 255
Anything wrong with this?
Johann
More information about the Coco
mailing list