print42_a
ZXNet echo conference «code.zx»
From Mihail Zharov → To All 11 March 2001
Hello All!
Is it possible even faster, higher, stronger...
without opening cycles?
╒═══< Begin file: print42a.asm >════════
PR42_Y DB 0 ;Y-print position (0-23)
PR42_X DB 0 ;X print position (0-255)
;************************************************
;print character [A]
PR42_A exx : ld bc,(PR42_Y) ;24
ld d,FONT/256 : ld e,a ;11
;35
;---------------------------------------
ld a,c : and %00011000 ;11
or #40 : ld h,a ;11
ld a,b : and %11111000 ;11
ld l,a ;4
ld a,c : and %00000111 ;11
or l : rrca : rrca : rrca ;16
ld l,a ;4
;---------------------------------------
;68
ld a,b : ld b,8 : rrca ;15
and %00000011 : jr z,PR42_A0 ;14
;137
dec a : jr z,PR42_A2 ;11
;148
dec a : jr z,PR42_A4 ;11
;159
;---------------------------------------
;154
PR42_A6 ld c,%00000011 ;7
PR42_A7 ld a,(de) : rlca : rlca ;15
xor (hl) : and c : xor (hl) ;18
ld (hl),a : inc l ;11
ld a,(de) ;7
rlca: rlca: rrd;26
ld (hl),a : dec l : inc h,d ;19
djnz PR42_A7 ;13
exx : ret ;14
; ----
;7+109*8-5+14 = 888 + 154 = 1042;---------------------------------------
PR42_A4 ld c,%11000000 ;7
PR42_A5 rrd : ld a,(de) ;25
rrca : rrca : rrca : rrca ;16
rld : inc l ;22
xor (hl) : and c : xor (hl) ;18
ld (hl),a : dec l : inc h,d ;19
djnz PR42_A5 ;13
exx : ret ;14
; ----
;7+113*8-5+14 = 920 + 159 = 1079
;---------------------------------------
PR42_A2 ld c,%00111111 ;7
PR42_A3 ld a,(de) : rrca : rrca ;15
xor (hl) : and c : xor (hl) ;18
ld (hl),a : inc h,d ;15
djnz PR42_A3 ;13
exx : ret ;14
; ----
;7+61*8-5+14 = 504 + 148 = 652
;---------------------------------------
PR42_A0 ld c,%11111100 ;7
PR42_A1 ld a,(de) ;7
xor (hl) : and c : xor (hl) ;18
ld (hl),a : inc h,d ;15
djnz PR42_A1 ;13
exx : ret ;14
; ----
;7+53*8-5+14 = 440 + 137 = 577
;---------------------------------------
;min: 577
;max: 1079
;byte: 114
╘═══< End file: print42a.asm >══════════
Счастливо. Михаил.
From Aleksandr Majorov → To Mihail Zharov 13 March 2001
Hello Mikhail!
11 Mar 01 21:21, Mihail Zharov -> All:
MZ> Is it possible to go even faster, higher, stronger...
MZ> without opening cycles?
MZ> ╒═══< Begin file: print42a.asm >════════
MZ> PR42_Y DB 0 ;Y-print position (0-23)
MZ> PR42_X DB 0 ;X-print position (0-255)
MZ> ;************************************************
MZ> ;print character [A]
MZ> PR42_A exx : ld bc,(PR42_Y) ;24
[skipped]
Without even delving into the depth of the code:
PR42_A EXX
LD BC,0
PR42_Y EQU $-2 ;Y-print position (0-23)
PR42_X EQU $-1 ;X-print position (0-255)
Won 3 bytes, and won 10 clock cycles.
Obviously, this is suitable when the printer is in RAM.
Alexand
From Pavel Vasilyev → To Mihail Zharov 14 March 2001
Hello Mikhail!
11 Mar 01 21:21, Mihail Zharov -> All:
MZ> Is it possible even faster, higher, stronger...
MZ> without cycle expansion?
MZ> ╒═══< Begin file: print42a.asm >════════
MZ> PR42_Y DB 0 ;Y-print position (0-23)
MZ> PR42_X DB 0 ;X-print position (0-255)
The least significant bit of the X coordinate is ignored, ^^^^^
i.e. your signet is honorable :)
[--skip--]
MZ> PR42_A6 ld c,%00000011 ;7
MZ> PR42_A7 ld a,(de) : rlca : rlca ;15
MZ> xor (hl) : and c : xor (hl) ;18
MZ> ld (hl),a : incl ;11
MZ> ld a,(de) ;7
MZ> rlca : rlca : rrd ;26
MZ> ld (hl),a : dec l : inc h,d ;19
MZ> djnz PR42_A7 ;13
MZ> exx : ret ;14
MZ> ;---
MZ> ;7+109*8-5+14 = 888
This flow can be speeded up a little.
Here: HL = address on screen
DE = font address
B=8
PR42_A6 LD A,(HL) ;07
RRCA : RRCA : LD C,A ;12LD A,(DE) ;07
RLCA : RL C : RLCA : RL C ;24
LD (HL),C : INC L : RRD ;27
LD (HL),A : DEC L : INC H,D ;19
DJNZ PR42_A6 ;13
EXX : RET ;14
;---
;109*8-5+14 = 881
A total of 7 bars, and for the scorpion - another 15,
by reducing odd-clock instructions in the cycle.
[--skip--]
...
From Aleksandr Majorov → To Mihail Zharov 15 March 2001
Hello Mikhail!
11 Mar 01 21:21, Mihail Zharov -> All:
MZ> Is it possible to go even faster, higher, stronger...
MZ> without opening cycles?
I watched it a little more :)
[skipped]
MZ> ld a,b : ld b,8 : rrca ;15
MZ> and %00000011 : jr z,PR42_A0 ;14
MZ> ;137
MZ> dec a : jr z,PR42_A2 ;11
MZ> ;148
MZ> dec a : jr z,PR42_A4 ;11
MZ> ;159
MZ> ;---------------------------------------
MZ> ;154
MZ> PR42_A6 ld c,%00000011 ;7
[skipped]
This place for choosing the type of print can be optimized a little.
From the first RRCA to the PR42_A marks?
LD A,B: LD B,8 : RRCA
RRCA: JR NC,PR42_A04
RRCA: JR C,PR42_A6
PR42_A2 ........
PR42_A04 RRCA: JR C, PR42_A4
PR42_A0 ..........
PR42_A4 ..........
PR42_A6 ..........
In total, I ended up with one byte less.
Now there are temporary schedules.
We count the cycles spent from the moment after RRCA to the moment
hits on print points depending on content [A]
A old version new version
0 19 27
1 30 222 41 32
3 36 27
Since all 4 types of symbols occur equally, the average
time to transition to the old one = 31.5 cycles, to the new one = 27 cycles.
Total is one byte shorter and about 4.5 clock cycles faster ;-)
Alexand
From Mihail Zharov → To Aleksandr Majorov 18 March 2001
Hello, Alexander!
Saturday 17 March 2001, at 04:17:01,
Aleksandr Majorov -> Mikhail Zharov:
AM>>> Since all 4 types of characters occur equally, then
AM>>> average time for transition according to the old method = 31.5 cycles,
AM>>> new = 27 cycles.
AM>>> Total one byte shorter and about 4.5 clock cycles faster ;-)
MZ>> I did the math and it turned out - you will gain 18 cycles when printing
MZ>> 4 characters in a row... ;)
AM> So everything is correct - 18 / 4 = 4.5
AM> But you counted for “in a row”, and I counted for “on average” - this
AM> IMHO more convenient
AM> :)
Perhaps. But I wanted a more accurate result ;)
Here is the final version(?)
Here two more streams have been reduced by Pavel Vasiliev.
Is there anything else that can be done? ;)
╒═══< Begin file: print42a.asm >════════
;************************************************
;PRINTING SYMBOL (A) IN 6x8 FONT - 42
;************************************************
PR42_A exx ;4
ld bc,#0000 ;10
PR42_Y EQU $-2 ;Y-coordinate (0-023)
PR42_X EQU $-1 ;X-coordinate (0-255)
ld d,FONT/256 : ld e,a ;11
;---------------------------------------
ld a,c : and %00011000 ;11 or #40 : ld h,a ;11
ld a,b : and %11111000 ;11
ld l,a ;4
ld a,c : and %00000111 ;11
or l : rrca : rrca : rrca ;16
ld l,a ;4
;---------------------------------------
ld a,b : ld b,8 : rrca ;15
rrca : jr nc,PR42_A0 ;124
rrca : jr c,PR42_A6 ;135
; ----
; 130
;---------------------------------------
PR42_A2 ld c,%00111111 ;7
PR42_A3 ld a,(de) : rrca : rrca ;15
xor (hl) : and c : xor (hl) ;18
ld (hl),a : inc h,d ;15
djnz PR42_A3 ;13
exx : ret ;14
; ----
;7+61*8-5+14 = 504 + 130 = 634
;---------------------------------------
PR42_A0 rrca : jr c,PR42_A4 ;11
ld c,%00000011 ;7
ex de,hl ;4
PR42_A1 ld a,(de) ;7
and c : or (hl) ;11
ld (de),a : inc h,d ;15
djnz PR42_A1 ;13
exx : ret ;14
; ----
;22+46*8-5+14 = 399 + 124 = 523
;---------------------------------------
PR42_A4 ld c,%11000000 ;7
PR42_A5 rrd : ld a,(de) ;25
rrca : rrca : rrca : rrca ;16
rld : inc l ;22
xor (hl) : and c : xor (hl) ;18
ld (hl),a : dec l : inc h,d ;19
djnz PR42_A5 ;13
exx : network ;14
; ----
;7+113*8-5+14 = 920 + 140 = 1060
;------------------------------------
PR42_A6 ld a,(of) ;7
rlca : rlca : ld c,a ;12
xor (hl) : and %00000011 ;14
xor (hl) ;7
ld (hl),a : inc l ;11
ld a,c : rrd ;22
ld (hl),a : dec l : inc h,d ;19
djnz PR42_A6 ;13
exx : network ;14
; ----
;105*8-5+14 = 849 + 135 = 984
;------------------------------------
;min: 523
;max: 1060
;bytes: 110
╘═══< End file: print42a.asm >══════════
Happily. Michael.