
Scramble EQU   030h   ;-33h
;... other variables here
SrcBuf   EQU   040h   ;-5Fh
DstBuf   EQU   060h   ;-7Fh

;at start, r0 contains pointer to SrcBuf
;          b  contains message length
   mov   r1,0
   anl   r1,#03h          ;first, calculate pointer into Scramble
   orl   r1,#Scramble
Loop:
   mov   a,@r0            ;get data from SrcBuf
   xrl   a,@r1            ;perform scramble
   xrl   0,#SrcBuf XOR DstBuf     ;get pointer to DstBuf
   mov   @r0,a            ;store scrambled data
   xrl   0,#SrcBuf XOR DstBuf     ;restore pointer to SrcBuf
   inc   r1               ;increment Scramble pointer
   anl   1,#0FBh          ;wrap around Scramble pointer
   inc   r0               ;increment SrcBuf pointer
   anl   0,#0DFh          ;wrap around SrcBuf pointer
   djnz  b,loop
