CODE |
ec1 xor a ld hl,0 ld d,e ld l,h mainloop: ld a,$FF out (1),a ld a,$FE out (1),a nop nop in a,(1) cp '1' call z,is_1 cp '2' call z,is_2 cp '3' call z,is_3 cp '4' call z,is_4 cp '5' call z,is_5 cp 0 jp z,mainloop jp mainloop is_1: ld de,no_label1 ld b,5 call convert_num ret is_2: ld de,no_label2 ld b,5 call convert_num ret is_3: ld de,no_label3 ld b,5 call convert_num ret is_4: ld de,no_label4 ld b,5 call convert_num ret is_5: ld de,no_label5 ld b,5 call convert_num ret convert_num: ld hl,0 conv_loop: ld a,(de) inc de cp '1' ccf adc hl,hl djnz conv_loop ret c2 |
CODE |
ec1 ret c2 |
CODE |
ec1 mainloop: ld a,$FE out (1),a ld a,(de);7 t-state delay in a,(1) cp '1' call z,is_1 cp '2' call z,is_2 cp '3' call z,is_3 cp '4' call z,is_4 cp '5' call z,is_5 jr mainloop is_1: ld de,no_label1 ld b,5 jr convert_num is_2: ld de,no_label2 ld b,5 jr convert_num is_3: ld de,no_label3 ld b,5 jr convert_num is_4: ld de,no_label4 ld b,5 jr convert_num is_5: ld de,no_label5 ld b,5 jr convert_num convert_num: ld hl,0 conv_loop: ld a,(de) inc de cp '1' ccf adc hl,hl djnz conv_loop ret c2 |
CODE |
ec1mainloop2: ld a,$FF mainloop: out (1),a dec a out (1),a ld d,0 in a,(1) dec a jr c,mainloop add a,a ld e,a ld hl,table-(('1')*2)+2 add hl,de ld a,(hl) inc hl ld l,(hl) ld h,a ld b,5 ld a,$FF conv_loop: ld c,(hl) inc hl dec c adc a,a Post by: Halifax on August 28, 2007, 01:13:00 am Post by: Fallen Ghost on August 28, 2007, 02:31:00 pm [Edit]Just took out 17 clocks by using the cpl instead of the ccf Oh, and by most optimized, you talk about speed only or bytes too? [Edit #2]Yeah, well, look at it now Post by: calc84maniac on August 28, 2007, 03:35:00 pm Post by: Fallen Ghost on August 28, 2007, 03:59:00 pm There's none, it's just a piece of code to optimize. If you want my opinion, this routine could be replaced by "ret" and it would output the same, but it seems we have to care about whatever the routine does. Post by: DJ Omnimaga on August 28, 2007, 04:17:00 pm Post by: Halifax on August 28, 2007, 06:18:00 pm @Fallen_Ghost: Obviously yes your routine is the best, and what I consider the most optimized. Fallen_Ghost wins! Post by: DJ Omnimaga on August 28, 2007, 06:21:00 pm |