NAME TEST4
#include <reg52.inc>
?PR?scan_dats?TEST4 SEGMENT CODE
?C_INITSEG SEGMENT CODE
?CO?TEST4 SEGMENT CODE
?DT?TEST4 SEGMENT DATA
PUBLIC position
PUBLIC data1
PUBLIC group
PUBLIC DAT_DIM
PUBLIC shift_code
PUBLIC scan_dats
RSEG ?DT?TEST4
DAT_DIM: DS 16
group: DS 1
data1: DS 1
position: DS 1
RSEG ?CO?TEST4
shift_code:
DB 0FEH
DB 0FDH
DB 0FBH
DB 0F7H
DB 0EFH
DB 0DFH
DB 0BFH
DB 07FH
DB 0FEH
DB 0FDH
DB 0FBH
DB 0F7H
DB 0EFH
DB 0DFH
DB 0BFH
DB 07FH
RSEG ?C_INITSEG
DB 010H
DB DAT_DIM
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 000H
DB 088H
;
; typedef unsigned char uchar;
;
; uchar group, position,data1;
;
; uchar code shift_code[16]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //128
; uchar DAT_DIM[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88}; //16
;
; void scan_dats(void)
RSEG ?PR?scan_dats?TEST4
scan_dats:
USING 0
;---- Variable 'j?041' assigned to Register 'R7' ----
;---- Variable 'temp?042' assigned to Register 'R6' ----
; {
; uchar i,j,temp ;
; P1 = 0xff;
MOV P1,#0FFH
; P2 = 0xff;
MOV P2,#0FFH
; for(i=0; i<8; i++)
;---- Variable 'i?040' assigned to Register 'R5' ----
CLR A
MOV R5,A
?C0001:
; {
; P1 = shift_code;
MOV A,R5
MOV DPTR,#shift_code
MOVC A,@A+DPTR
MOV P1,A
; DAT_DIM = ~P3;
MOV A,P3
CPL A
MOV R4,A
MOV A,#LOW (DAT_DIM)
ADD A,R5
MOV R0,A
MOV @R0,AR4
; P1 |= 0xff;
MOV P1,#0FFH
; if(DAT_DIM!=0xff)
MOV A,#LOW (DAT_DIM)
ADD A,R5
MOV R0,A
MOV A,@R0
MOV R4,A
CPL A
JZ ?C0003
; {
; temp = DAT_DIM;
MOV R6,AR4
; group = i;
MOV group,R5
; for(j=1; j<9; j++)
MOV R7,#01H
?C0005:
; {
; if((temp & 0x01) == 0)
JB ACC.0,?C0008
; {
; position = j;
MOV position,R7
; break;
SJMP ?C0003
; }
?C0008:
; else temp = temp >> 1;
MOV A,R6
CLR C
RRC A
MOV R6,A
; }
?C0007:
INC R7
CJNE R7,#09H,?C0005
; }
; }
?C0003:
INC R5
CJNE R5,#08H,?C0001
?C0002:
; for(i=8; i<16; i++)
MOV R5,#08H
?C0010:
; {
; P2 = shift_code;
MOV A,R5
MOV DPTR,#shift_code
MOVC A,@A+DPTR
MOV P2,A
; DAT_DIM = ~P3;
MOV A,P3
CPL A
MOV R4,A
MOV A,#LOW (DAT_DIM)
ADD A,R5
MOV R0,A
MOV @R0,AR4
; P2 |= 0xff;
MOV P2,#0FFH
; if(DAT_DIM!=0xff)
MOV A,#LOW (DAT_DIM)
ADD A,R5
MOV R0,A
MOV A,@R0
MOV R4,A
CPL A
JZ ?C0012
; {
; temp = DAT_DIM;
MOV R6,AR4
; group = i;
MOV group,R5
; for(j=1; j<9; j++)
MOV R7,#01H
?C0014:
; {
; if((temp & 0x01) == 0)
MOV A,R6
JB ACC.0,?C0017
; {
; position = j;
MOV position,R7
; break;
SJMP ?C0012
; }
?C0017:
; else temp = temp >> 1;
MOV A,R6
CLR C
RRC A
MOV R6,A
; }
?C0016:
INC R7
CJNE R7,#09H,?C0014
; }
; }
?C0012:
INC R5
CJNE R5,#010H,?C0010
?C0011:
; data1 = group*8+position;
MOV A,group
MOV B,#08H
MUL AB
ADD A,position
MOV data1,A
; }
RET
; END OF scan_dats
END