Damn clever, that! I was just thinking in more straightforward terms: LD IXh,D/LD D,IXh.arkannoyed wrote: ↑Thu Mar 22, 2018 1:28 pm It could actually be achieved with 1 extra byte thus
RES 2,D
dec D
instead of PUSH DE & POP DE and then no need for the stack any longer, Freeeeeeeedddddoooooooommmmmmmm!!!!!
Compact 64 column print routine
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: Compact 64 column print routine
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: Compact 64 column print routine
Sir Clive gets quite ira–a–ate . . .Morkin wrote: ↑Thu Mar 22, 2018 1:30 pmEvery byte is sacred...!Ast A. Moore wrote: ↑Thu Mar 22, 2018 1:24 pm Yes, when you just need to preserve a single 8-bit register, it seems wasteful.
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
- Einar Saukas
- Bugaboo
- Posts: 3143
- Joined: Wed Nov 15, 2017 2:48 pm
Re: Compact 64 column print routine
Your routine is designed to be accessed with CALL (it exits with RET) so it's implicitly using the stack anyway. I see no advantage spending an extra byte to reduce stack usage.arkannoyed wrote: ↑Thu Mar 22, 2018 1:28 pm It could actually be achieved with 1 extra byte thus
RES 2,D
dec D
instead of PUSH DE & POP DE and then no need for the stack any longer, Freeeeeeeedddddoooooooommmmmmmm!!!!!
- arkannoyed
- Manic Miner
- Posts: 438
- Joined: Mon Feb 05, 2018 9:56 am
- Location: Northamptonshire
Re: Compact 64 column print routine
Very true!
Sometimes we all have pointless goals!
Sometimes we all have pointless goals!
- arkannoyed
- Manic Miner
- Posts: 438
- Joined: Mon Feb 05, 2018 9:56 am
- Location: Northamptonshire
Re: Compact 64 column print routine
Same size (31 bytes), but a little bit faster as I've removed the central loop, where unrolling it is actually the same size!
Code: Select all
start:
ld a,(bc) ;get msg chr byte
ld h,a
inc bc
ld a,(bc)
ld l,a
inc bc
push de
lp0:
inc d
ld a,(de)
add a,a
add hl,hl
adc a,a
add hl,hl
adc a,a
add hl,hl
adc a,a
ld (de),a
bit 2,d
jr z,lp0
pop de
add hl,hl
ret c
bit 1,c
jr nz,start
inc e
jr start
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: Compact 64 column print routine
Now we’re talking!
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.