Да короче, короче - твоя 21 слово, моя - 18. Но твоя изящнее - ijmp красиво лег, почти как у меня когда-то :)) --> http://caxapa.ru/53279.html
.include "m2561def.inc"
.include "..\macros.inc"
.def tmp = r16
.def r24L = r24
.def r24H = r25
.dseg
.equ buflen = 4096
buf: .byte buflen
.cseg
;----------------------------------------------------------------------------------------------------------------
; UNPACK function test.
; Stuff the input bitstream registers with a 7-bit ASCII coded word "Keyboard" for easy watching in AVR Studio:
;
test_unpack:
outiw SP,RAMEND ; Initialize Stack Pointer
/*
ldi r16,0xFF & ('K'<<1)|('e'>>6)
ldi r17,0xFF & ('e'<<2)|('y'>>5)
ldi r18,0xFF & ('y'<<3)|('b'>>4)
ldi r19,0xFF & ('b'<<4)|('o'>>3)
ldi r20,0xFF & ('o'<<5)|('a'>>2)
ldi r21,0xFF & ('a'<<6)|('r'>>1)
ldi r22,0xFF & ('r'<<7)|('d'>>0)
ldi r23,0 ; needed for CY = 0 rollout from every last iteration in a loop
*/
rcall unpack
rjmp test_unpack ; Loop again
;----------------------------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------------------------
; Recursively unpacks a received contiguous 7-bit per field bitstream to an 8-bit (1 byte) per field data array.
;
; Bitstream as received: aaaaaaabbbbbbbcccccccdddddddeeeeeeefffffffggggggghhhhhhh (xxxxxxx = any bit sequence)
; Input = r16:aaaaaaab r17:bbbbbbcc r18:cccccddd r19:ddddeeee r20:eeefffff r21:ffgggggg r22:ghhhhhhh r23:00000000
; Output= r16:0aaaaaaa r17:0bbbbbbb r18:0ccccccc r19:0ddddddd r20:0eeeeeee r21:0fffffff r22:0ggggggg r23:0hhhhhhh
; 15 code words, 84 cycles (4.2 uS @20 MHZ)
;
unpack:
ldiw Z,iter1 ; Initialize the iteration entry address pointer
ldi r24,low(it_lim) ; Set recursion limit checkpoint
; Iter1: Iter2: Iter3: Iter4: Iter5: Iter6: Iter7: Iter8:
;------------------------------------------------------------------------
iter1: lsr r16 ; 0aaaaaaa Intact Intact Intact Intact Intact Intact Intact
iter2: ror r17 ; bbbbbbbc 0bbbbbbb Intact Intact Intact Intact Intact Intact
iter3: ror r18 ; ccccccdd cccccccd 0ccccccc Intact Intact Intact Intact Intact
iter4: ror r19 ; dddddeee ddddddee ddddddde 0ddddddd Intact Intact Intact Intact
iter5: ror r20 ; eeeeffff eeeeefff eeeeeeff eeeeeeef 0eeeeeee Intact Intact Intact
iter6: ror r21 ; fffggggg ffffgggg fffffggg ffffffgg fffffffg 0fffffff Intact Intact
iter7: ror r22 ; gghhhhhh ggghhhhh gggghhhh ggggghhh gggggghh gggggggh 0ggggggg Intact
iter8: ror r23 ; h0000000 hh000000 hhh00000 hhhh0000 hhhhh000 hhhhhh00 hhhhhhh0 0hhhhhhh
it_lim: adiw Z,1 ; Advance the recursive iteration entry pointer
cpse ZL,r24 ; Check for recursion limit, exit if reached
ijmp ; Do the next iteration (iterN+1) recursively. Hint: iter8 always rolls out CY = 0
ret
;----------------------------------------------------------------------------------------------------------------
-
- Да, я лоханулся - таблицу масок посчитал как 8 слов, а не 4 :(( - 580BM80(05.03.2011 08:22)