Код: Выделить всё
;dgrett@gmail.com
.equ Hex2PDU_Data=96
.def temp=r16
.def temp1=r17
.def temp2=r18
.def temp3=r19
.def temp4=r20
.def ZLramadr=R30
.def ZHramadr=R31
;==========
;INPUT: temp1 - number of bytes to convert
;Use temp1=8, 16, 24... This might be counted before.
;Bytes in HEX format are stored in SRAM address Hex2PDU_Data.
;
;OUTPUT:
; If temp1=<8 then start of PDU lies on Hex2PDU_Data+1 address
; If 8<temp1=<16 then Hex2PDU_Data+2 etc..
;===========
MakePDU:
mov temp, temp1 ;
clr temp2 ;
clr temp3 ;
M1:
inc temp2
clc
rcall convert0
dec temp
brne M1
rjmp Go_Out
;===========
convert0:
push temp4
ldi ZLramadr,Hex2PDU_Data
clr temp4
M2:
ld temp3,Z
rol temp3
st Z+,temp3
inc temp4
cpse temp2,temp4
rjmp M2
pop temp4
ret
;===========
Go_Out: ; here conversion PDU to HEX goes, then send out everything + ESC sequence ($1A,$0D)