0 Members and 1 Guest are viewing this topic.
ld a,10 ;48 ten digits to look after. 1.000.000.000DSBDECSCOLP: ex af,af' ;52 62 pop bc ;62 72 pop de ;72 82 ld a,(iy+0) ;91 101 out ($11),a ;11 ld a,$FF ;18 inc a ;22 add ix,bc ;37 adc hl,de ;52 jr c,$-5 ;59 ld c,a ;63 ld a,(iy+1) ;82 out ($11),a ;11 pop de ;21 add ix,de ;36 pop de ;46 ld a,(iy+2) ;65 arghamahblabbles! nop ;69 BAD CODE! WORST ENEMY! *rolls newspaper* WHAP WHAP WHAP out ($11),a ;11 adc hl,de ;26 ld a,c ;30 add a,a ;34 add a,a ;38 ld c,a ;42 ld b,0 ;49 ld a,(iy+3) ;68 out ($11),a ;11 ld iy,NumberTable ;25 add iy,bc ;40 ex af,af' ;44 dec a ;48 jp nz,DSBDECSCOLP ;58 ld sp,(itemp1) ld iy,myflags jp DSBSCORCOLL
workonthisrow: call leftiter call centeriter call fourthiter ld a,10Workonthisrowsub: push af call firstiter call centeriter call fourthiter pop af dec a jr nz,Workonthisrowsub call firstiter call centeriter call rightiter ret;External setup:;HL = LUT for bit comparison;HL'= LUT for result testing; Two LUTs are indexed by HL by incrementing and decrementing H (256 byte wide tables);IX = pointer to buffer 1 (reading);IY = pointer to buffer 2 (writing);;Internal setup:;D= row above;E= row below;C= current position;B= temporary variable;B'=center byte storage;;Registers used so far:; AF, BC, DE, HL, AF', BC', HL', IX, IY;;Free registers:; DE';firstiter: ld d,(ix-12) ld e,(ix+12) ld c,(ix+00) ld a,(ix-13) rrca ld a,d rra and 11101110b ld l,a ld b,(hl) ld a,(ix+11) rrca ld a,e rra and 11101110b ld l,a ld a,(hl) ex af,af' ld a,(ix-01) rrca ld a,c rra and 10101010b ld l,a ld a,c ex af,af' add a,(hl) add a,b exx ld l,a ex af,af' ld b,a and (hl) \ dec h or (hl) \ inc h and 10001000b ld c,a exx ret centeriter: ld a,d and 11101110b ld l,a ld b,(hl) ld a,e and 11101110b ld l,a ld a,(hl) ex af,af' ld a,c and 10101010b ld l,a ex af,af' add a,(hl) add a,b exx ld l,a ld a,b and (hl) \ dec h or (hl) \ inc h and 01000100b or c ld c,a exx ld a,d and 01110111b ld l,a ld b,(hl) ld a,e and 01110111b ld l,a ld a,(hl) ex af,af' ld a,c and 01010101b ld l,a ex af,af' add a,(hl) add a,b exx ld l,a ld a,b and (hl) \ dec h or (hl) \ inc h and 00100010b or c ld c,a exx retfourthiter: ld a,(ix-11) rlca ld a,d rla and 01110111b ld l,a ld d,(hl) ld a,(ix+13) rlca ld a,e rla and 01110111b ld l,a ld e,(hl) ld a,(ix+01) rlca ld a,c rla and 01010101b ld l,a ld a,(hl) add a,e add a,d exx ld l,a ld a,b and (hl) \ dec h or (hl) \ inc h and 00010001b or c ld (iy+0),a exx inc ix inc iy ret;=============== side of screen routinesleftiter: ld d,(ix-12) ld e,(ix+12) ld c,(ix+00) ld a,(ix-01) rrca ld a,d rra and 11101110b ld l,a ld b,(hl) ld a,(ix+23) rrca ld a,e rra and 11101110b ld l,a ld a,(hl) ex af,af' ld a,(ix+11) rrca ld a,c rra and 10101010b ld l,a ld a,c ex af,af' add a,(hl) add a,b exx ld l,a ex af,af' ld b,a and (hl) \ dec h or (hl) \ inc h and 10001000b ld c,a exx retrightiter: ld a,(ix-23) rlca ld a,d rla and 01110111b ld l,a ld d,(hl) ld a,(ix+01) rlca ld a,e rla and 01110111b ld l,a ld e,(hl) ld a,(ix-11) rlca ld a,c rla and 01010101b ld l,a ld a,(hl) add a,e add a,d exx ld l,a ld a,b and (hl) \ dec h or (hl) \ inc h and 00010001b or c ld (iy+0),a exx inc ix inc iy ret;;Subroutine code end;======================================
Not entirely sure this counts as "just an extra HL"
When reading the asm output for GlaßOS, I noticed that it uses a standard way of passing parameters to functions. Push variables, then use IX like hell. Yes, SDCC has a drink..,er, IX problem. I know that index registers add an extra byte or so to op sizes, and are slow. I can see a lot of tios asm programmers not liking that variables, even one byte, aren't passed by register but by the stack. What about IY? Its dedicated for the interrupt, just like IX.
Another hack I recently figured out is that (iy - 3) is the end of plotSScreen. This means you can have your own set of flags that are guaranteed to be free to use. And since it uses the location that IY is already at, you're not even giving up a register.
Another hack I recently figured out is that (iy - 3) is the end of plotSScreen.
Personnaly, i often use ix half registers as 8-bit backups.In this case, saving|restoring a value is twice as big than using the stack but when speed is the desired criteria, saving 5 t-states can definitely matter.
Actually, using 8-bit backups uses an average of 8 t-states when it comes to half registers.