home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
archives
/
i8051.tar.gz
/
i8051.tar
/
i51ncod.asm
< prev
next >
Wrap
Assembly Source File
|
1996-06-30
|
862b
|
35 lines
; encode the character A into the global data array P2/R0
; r0 is size pointer
;
encode: mov r4,a ; store char
mov dptr,#param + P_qctl
movx a,@dptr ; get Qctl from parameter table
mov r2,a ; r2 has control prefix to use
mov a,r4 ; get char
anl a,#127 ; mask out hi bit
mov r1,a ; A7
cjne r1,#32,ncod1 ; if A7 < 32 ?
sjmp ncod2 ; is equal
ncod1: jc ncod3 ; is less
ncod2: cjne r1,#127,ncod4 ; or A7 = 127 ?
ncod3: mov a,r2 ; get quote
movx @r0,a ; insert control quote
inc r0 ; size++
mov a,r4 ; get char
tuctl ; + 32
mov r4,a ; store char
sjmp ncod5 ; done
ncod4: mov a,r1 ; get A7
cjne a,2,ncod5 ; if char = control prefix
mov a,r2 ; get quote
movx @r0,a ; insert control quote
inc r0 ; size++
ncod5: mov a,r4 ; get char
movx @r0,a ; insert character
inc r0 ; size++
clr a
movx @r0,a ; terminate string
ret
;