.EQU DMLZ_DATA =0
.EQU DMLZ_TEMP =1
.EQU DMLZ_TMP2 =2
.EQU DMLZ_TMP3 =3
.EQU DMLZ_XL =4
.EQU DMLZ_XH =5
.EQU DMLZ_JUMP =6
;
;--------------------------------------
;
.DSEG
DMLZ_Z: .BYTE 2
DMLZ_REGS: .BYTE 7
.CSEG
;
;--------------------------------------
;in: Z,RAMPZ == указатель на упакованные данные
DMLZ_INIT:
STSZ DMLZ_Z
LDIZ DMLZ_REGS
LDI TEMP,$80
STD Z+DMLZ_TEMP,TEMP
LDI TEMP,LOW(MEGABUFFER)
STD Z+DMLZ_TMP2,TEMP
LDI TEMP,HIGH(MEGABUFFER)
STD Z+DMLZ_TMP3,TEMP
STD Z+DMLZ_JUMP,FF
RET
;(не менять RAMPZ между вызовами DMLZ_GETBYTE)
;--------------------------------------
;out: sreg.Z == CLR - успешно, SET - конец данных
; DATA == очередной байт
DMLZ_GETBYTE:
LDIZ DMLZ_REGS
LDD DATA,Z+DMLZ_DATA
LDD TEMP,Z+DMLZ_TEMP
LDD TMP2,Z+DMLZ_TMP2
LDD TMP3,Z+DMLZ_TMP3
LDD XL,Z+DMLZ_XL
LDD XH,Z+DMLZ_XH
LDD R0,Z+DMLZ_JUMP
LDSZ DMLZ_Z
TST R0
BRMI DMLZ_MS
BREQ DMLZ_METKA0
RJMP DMLZ_METKA1
;
DMLZ_MS:ELPM R0,Z+
STSZ DMLZ_Z
LDIZ DMLZ_REGS
STD Z+DMLZ_JUMP,NULL
DMLZ_OUT:
STD Z+DMLZ_DATA,DATA
STD Z+DMLZ_TEMP,TEMP
STD Z+DMLZ_XL,XL
STD Z+DMLZ_XH,XH
MOV XL,TMP2
MOV XH,TMP3
ST X+,R0
SUBI XH,HIGH(MEGABUFFER) ;
ANDI XH,DBMASK_HI ;address warp
ADDI XH,HIGH(MEGABUFFER) ;
STD Z+DMLZ_TMP2,XL
STD Z+DMLZ_TMP3,XH
MOV DATA,R0
CLZ
RET
DMLZ_METKA0:
DM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