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
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
And once again, blogger destroyed the formatting.
ReplyDeleteI haven't seen you on the TRS-80 Discord server when I've been on. That's where I found a link to your blog. I love reading about assembly programming! Keep up the great posts!
ReplyDeleteThanks for the kind words. I haven't been on discord lately.
ReplyDeleteBusy with other things, and needed a break.
This was just one of those little distractions to take my mind off of other things.
It would have been nice if I had added comments. :P
ReplyDeleteHere's a 27 byte Z-80 version. Am pretty sure it is correct but haven't tested it beyond eyeballing the HL and DE addresses it iterates over. I think it is pretty compact but I haven't put in serious effort.
ReplyDeletecross:
ld hl,$400
ld de,$41F
ld b,l
ld c,e
lp:
ld a,$83
ld (hl),a
inc hl
ld (de),a
dec de
ld a,$8c
ld (hl),a
ld (de),a
ex de,hl
add hl,bc
ex de,hl
inc l
ret z
add hl,bc
inc hl
jr lp