Monday, August 26, 2019

Someone started sort of a challenge to draw an X on a C64 screen in the least amount of code.
Simon Jonassen posted a 6809 version for a 6847 semi-graphics screen.
Link
This is untested, as in not even passed through an assembler so they probably need work yet, but here's my first crack at the 6803 and Z80 code.

6803, it uses self modifying code.  Length depends on whether you put it on the direct page or not, but it comes in at 28 bytes, or 30.

org $
start:
ldx #screen ;3
lp: ldd #$838C ;3
std 0,x ;2
ldd #$8C83 ;3
smc: std 30,x ;2
ldaa smc1 ;2 or 3
suba #4 ;2
staa smc1 ;2 or 3
ldab #34 ;2
abx ;1
cmpx #$screen+??? ;3
ble lp ;2
rts ;1


Z80.  I haven't been programming on the Z80 lately, so there's probably all sorts of things wrong with the code, including not filling some addresses, and the byte count.  But it looks like 27 bytes here if I didn't leave out something or mess up the count.
org $

start: LD HL,#screen ;3
LD DE,#screen+31 ;3
LP: LD BC,#838C ;3
LD (HL),B ;1
LDD ;1
ADD L,#2 ;2
LD (HL),C ;1
LDD ;1
LD BC,#33 ;3
ADD HL,BC ;1
DEC C ;1
ADD DE,BC ;1
CPHL # ;3
BLE LP ;2
RET ;1