Zilog z80 to Motorola 6809 Transcode – Part 009 – Ghosts on screen and some z80 transcode tips

A little more progress…  I still have to make the other coloured ghosts but at least I know where in the code it draws these ghosts so it should be relatively easy to draw the correct one at the correct time.  There is still some weird problem with the fourth character of each name.  This isn’t the character generator but something else is going on in the code as this page takes way too long to load each character.  😦

At least it’s some viewable progress.


I wanted to mention a few of the other gotchas that you will encounter when transcoding z80 to the 6809.

The z80 has instructions for branching that are like branch to subroutines under certain conditions.  The 6809 only does a branch to other routines.  For example:

        LDA     byte_4DCE          ;0348 3ACE4D      LD      A,(byte_4DCE)                     
        BNE    loc_359             ;034B C25903      JP      NZ,loc_359                     
        BITA   $10                 ;034E CB67        BIT     4,A                     
        BNE     >                  ;0350 -
        BSR    sub_369
!       ***     Jump here          ;**** CC6903      CALL    Z,sub_369                      Added for 6809 worakaround
        BEQ     >                  ;0353 -
        BSR    sub_383
!       ***     Jump here          ;**** C48303      CALL    NZ,sub_383                      Added for 6809 worakaround

In the code above the second line on the right the z80 code has a JP   NZ,loc_359 instruction.  This is exactly like the 6809 BNE instruction.  But at the bottom right the z80 instruction CALL   NZ,sub383 is a jump or branch instruction but to a subroutine that will have a return instruction.  So to match these commands function I substitute the opposite command as a branch if equal and jump ahead of the next line of code where I do a BSR (branch to subroutine) command.

Next thing about the above code is the z80 BIT instruction.  This isn’t too complicated but you must substitute the correct 6809 operand to match the bit it is comparing.  For example the z80 BIT    4,A  is looking at 4 so that is the same as doing an BITA   $10 command on the 6809.  Then again the 6809 takes the reverse conditional instruction and jumps forward past the BSR line which matches the CALL address of the z80.

See you in the next post…

This entry was posted in CoCo Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s