asm routine

OP (Firma: ZeuSWarE GmbH) #590578
Lesenswert?

Jo hi, ich habe hier ein teil einer asm routine von mir,
welche eine datenmatrix transponiert;
Meine creative phase is gerade weg, daher könnt ihr mir vlt
schnell sagen wie ich das in eine schleife umwandle, ohne hyper viel
cycles dazu zubekommen,... thx
1
;first row of the 8x5
2
ld r1,z+
3
ld r22,y
4
sbrc r1,7
5
ori r22,0b00010000
6
st y+,r22
7

8
ld r22,y
9
sbrc r1,6
10
ori r22,0b00010000
11
st y+,r22
12

13
ld r22,y
14
sbrc r1,5
15
ori r22,0b00010000
16
st y+,r22
17

18
ld r22,y
19
sbrc r1,4
20
ori r22,0b00010000
21
st y+,r22
22

23
ld r22,y
24
sbrc r1,3
25
ori r22,0b00010000
26
st y+,r22
27

28
ld r22,y
29
sbrc r1,2
30
ori r22,0b00010000
31
st y+,r22
32

33
ld r22,y
34
sbrc r1,1
35
ori r22,0b00010000
36
st y+,r22
37

38
ld r22,y
39
sbrc r1,0
40
ori r22,0b00010000
41
st y+,r22
42
;end of first row

grüüße
OP (Firma: ZeuSWarE GmbH) #590590
Lesenswert?

Die eignen sich gerade nicht für einen vergleich auf einen bit,
da brne auf das Z flag abgleicht das nur mit cp, cpi, sub, subi erzeugt 
wird
breq, brlo ähnlich, ...

wenn ich mich irre bitte ein source beispiel,..

ich habe zwar jetzt ein ART Lösung, aber die cycles vervierfachen sich 
wenn ich mich nicht irre,. und das gilt es noch zu vermeiden:
1
ldi r23,7
2
testloop2:
3
ld r22,y+
4

5
;lsr the bit from position to carry
6
mov r24,r23
7
mov r25,r1
8
testloop3:
9
lsr r25
10
dec r24
11
brne testloop3
12

13
brcc carry_is_clear
14
ori r22,0b00010000
15
st y,r22
16

17
carry_is_clear:
18
dec r23
19
brne testloop2

grüüße und danke
OP (Firma: ZeuSWarE GmbH) #590633
Lesenswert?

Ich glaube zwar nicht das es jemanden interressiert,
aber hier eine Komplette routine zur Transponierung
einer 8x5 zu 5x8 Matrix:
1
;#######################################################################################################
2
;Routine Reorder_Graph_data
3
;Transposes the graphic data from 8x5 to 5x8
4
;(c) Kai Scheddin
5
; uses follow registers
6
;ZH,ZL = r31:r30
7
;YH,YL = r29:r28
8
;r24 as bitmask for column mask of 5x8 matrix
9
;r1 as row of 8x5 matrix (also counter or rather rowindex, cause of postinc)
10
;r23 as counter for row index of 5x8 matrix
11
;r22 as overlay of stored data and seted element of 5x8 matrix
12
;#######################################################################################################
13
Reorder_Graph_data:
14
.dseg
15
graph_matrixBW: 
16
BW1: .byte 5
17
BW2: .byte 8 
18
.cseg
19
;#bw2 has to be completly cleared b4
20
push r31
21
push r30
22
push r29
23
push r28
24
push r24
25
push r23
26
push r22
27
push r1
28

29
ldi r30,low(bw1)
30
ldi r31,high(bw1)
31
ldi r28,low(bw2)
32
ldi r29,high(bw2)
33

34

35
ldi r24,0b00010000          ;# bitmask and counter
36
testloop2:
37
ld r1,z+                    ;# takes row of bw1 and postinc Z pointer
38
ldi r23,7                   ;# set counter to 7
39
tesloop3:
40
ld r22,y                    ;# loads bw2 
41
lsl r1                      ;# shift r1 left, puts msb to carry
42
brcc carry_is_clear         
43
or r22,r24                  ;# sets bitmask to r22
44
carry_is_clear:
45
st y+,r22                   ;# store r22 to bw2, and postinc
46
dec r23                     ;# dec counter
47
brne testloop3              ;# if NOT bw2 row 7 to 0 is set reloop else...
48
lsr r24                     ;# shift bitmask to right
49
brcc testloop2              ;# if carry is set end routine
50

51
pop r1
52
pop r22
53
pop r23
54
pop r24
55
pop r28
56
pop r29
57
pop r30
58
pop r31
59

60
ret
61
;#######################################################################################################
62

63
;#######################################################################################################

grüüüße
#591154
Lesenswert?

Kai Scheddin wrote:
> eine korrektur noch:
>
1
> ldi r28,low(bw2)
2
> ldi r29,high(bw2)
3
>
> muss unter
>
1
> ld r1,z+
2
>
> und
> anstatt:
>
1
> ldi r23,7
2
>
> muss es
>
1
> ldi r23,8
2
>
> heißen,...
> grüüße

Warum benutzt Du eigentlich nicht die übliche Namen (yl, yh) der 
Pointer-Register?

...

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren