The idea was formed ;)

ZXNet echo conference «code.zx»

From Kirill Frolov To Felix Knajzev 22 August 2000

================================================================================ * Forwarded by Kirill Frolov (2:5030/946.25) * Area : ZX.SPECTRUM (Emulator people hanging out) * From : Aleksandr Majorov, 2:5030/885.6 (22 Aug 00 03:25) *To: Dmitry Naboka * Subj: The idea has formed ;) ================================================================================ Hello Dmitry! 22 Aug 00 01:48, Dmitry Naboka -> Aleksandr Kolotukhin: [skipped] DN> Today my sister had to write this beard, but with the limitation that DN> decimal value in the range 0-127. Execution time is not critical. DN> It turned out something like the following (from memory): DN> ;input: a - code (0-127) DN> ;result: h - hundreds, l - tens, d - units (values #30-#39) [skipped] DN> P.S. Damn, somehow all this can be done in a clever way. I remember division by DN> 10 was done with three shifts and several more commands; Here's something similar, but more universal. In HL, the number that we “decipher”. (0-65535) The result will be in BUF_NUM+1, You can also look at it with BUF_NUM, but there will still be “0” at the beginning :) If necessary, then with a slight movement of the hand the sop turns into turns into a sop... into a "deciphering" 4-byte number :)╒══════════════════════ Hачало golded.txt ══════════════════════════ Pr_NUM LD DE,BUF_NUM+5 Pr_NUM_DEC LD B,3 Pr_N_DEC0 PUSH BC ;выделяем очеpеднyю цифpy LD B,1 XOR A Pr_N_DEC1 ADD HL,HL: ADC A,A: DAA JR NC,$+3: INC HL DJNZ Pr_N_DEC1 ;в [A] word on BCD-background ;Exclusive snowflakes and snowflakes on бyфеp LD C,A AND #0F: CP 10: SBC A,#69: DAA LD (OF),A: DEC OF LD A,C: RRCA: RRCA: RRCA: RRCA AND #0F: CP 10: SBC A,#69: DAA LD (OF),A: DEC OF POP BC DJNZ Pr_N_DEC0 LD HL,BUF_NUM+1 ╘═════════════════════ Конец golded.txt ═════════════════════════╛ Alexander -+- GoldED/386 3.0.1-asa9 SR1 + Origin: Error#014:DOS mounted on the backend (2:5030/885.6) =================================================================================== Thank you for the RESET, Felix! Вот тебе ещё быстpее! * Crossposted in CODE.ZX

From Kirill Frolov To Aleksandr Majorov 24 August 2000

Press RESET immediately, Aleksandr! 23 Aug 00 12:56, Aleksandr Majorov wrote to Kirill Frolov: KF>> Now I have counted the cycles, the result is the fastest program KF>> translation! AM> I know, I use it myself :) I made your program! I'm faster!!! :-) 1621 cycles for me versus 2625 cycles for you!!! But IMHO this is the fastest option! Divides by 10 in BCD. ; hl=bin div10: ld b, 10h exx xor a ld c, a ld e, a ld d,a exx ; 31 @@div: add hl, hl exx ld a, c adc a, a yeah ld c, a ld a, e adc a, a yeah ld e, a ld a, d adc a, a yeah ld d,a exx jr nc, @@nc inc l @@nc: djnz @@div ; ~87 ~1392 exx ld hl, buffer ld a, d or 30h ld (hl), a inc hl ld a, e rra rra rra rra and 0fh or 30h ld (hl), a inc hl ld a, e and 0fh or 30h ld (hl), a inc hl ld a, c rra rra rra rra and 0fh or 30h ld (hl), a inc hl ld a, c and 0fh or 30h ld (hl), aret ; 198 ~1621 Only 1621 clock cycles to translate a number! 2All: Who can do it faster? *Crossposted in CODE.ZX

From Aleksey Malov To Kirill Frolov 26 August 2000

Greetings, Kirill! Thu 24 Aug 2000 at 15:47:48 Kirill Frolov and Aleksandr Majorov were talking on the topic The idea has formed ;). KF> Only 1621 cycles for number translation! KF> 2All: Who can do it faster? I asked for it myself. I have 636 cycles (if I'm not mistaken). ;in: hl - number ;out: at address buffer, representation of the input number as an ascii string (without discarding insignificant zeros) bin2asc ld b,0 ld a,h rlca rlca rlca ld h,a and 7 ;34 rl h adc a,a yeah rl h adc a,a yeah rl h adc a,a yeah ;82 rl h adc a,a yeah rl b rl h adc a,a yeah rl b rl l adc a,a yeah rl b ;154 rl l adc a,a yeah ldc,a ld a,b adc a,a yeah ld b,a ;190 rl l ld a,c adc a,a yeah ldc,a ld a,b adc a,a yeah ld b,a rl l ld a,c adc a,a yeah ldc,a ld a,b adc a,a yeah ld b,a rl l ld a,c adc a,a yeah ldc,a ld a,badc a,a daa ld b,a ;310 rl l ld a,c adc a,a daa ld c,a ld a,b adc a,a daa ld b,a rl d rl l ld a,c adc a,a daa ld c,a ld a,b adc a,a daa ld b,a rl d ;406 rl l ld a,c adc a,a daa ld c,a ld a,b adc a,a daa ld b,a ld a,d rla and 7 ;461 ld de,#0f30 ld hl,buffer add a,e ld (hl),a inc hl ;498 ld a,b rrca rrca rrca rrca and d add a,e ld (hl),a inc hl ld a,b and d add a,e ld (hl),a inc hl ;564 ld a,c rrca rrca rrca rrca and d add a,e ld (hl),a inc hl ld a,c and d add a,e ld (hl),a ret ;636 buffer ds 5 Счастливо, Kirill! С вами был Vivid/Brainwave^X-Project. [ZX] [Sailor Moon]