em dùng p0,p2 để quét cột, p1 xuất dư liệu ra hàng.. giúp dùm em cái sơ đồ giải thuật các bác ơi!
$MOD51
ORG 00
MAIN:
MOV DPTR,#MACHU ; TRO TOI MACHU
MOV R6,#89 ; R6 89 LAN
CHAY:
MOV R7,#10 ; R7 10 LAN
QUET:
MOV R0,#00H ; R0 = 00H
MOV R1,#01H ; R1 = 01H
LAP2:
MOV P0,R1;P0=01H
MOV A,R1;A=01H
RL A; XOAY TRAI THANH GHI A, A=02H
MOV R1,A;R1=02H
MOV A,R0;A=00H
MOVC A,@A+DPTR; NAP VUNG DU LIEU
MOV P1,A;GAN DU LIEU A VAO PORT1
ACALL DELAY
INC R0; R0+1=01H
CJNE R0,#08H,LAP2;SO SANH R0 MA KO =8 THI NHAY VE LAP2
MOV P0,#00H ;P0=00H
LAP:
MOV P2,R1 ; P2=01H
MOV A,R1 ; A=01H
RL A ;XOAY TRAI THANH GHI A, A=02H
MOV R1,A ;R1=02H
MOV A,R0 ;A=00H
MOVC A,@A+DPTR ; NAP VUNG DU LIEU
MOV P1,A ;GAN DU LIEU A VAO PORT1
LCALL DELAY ;DELAY
INC R0 ;R0+1=01H
CJNE R0,#16,LAP ;SO SANH R0 MA KO =16 THI NHAY VE LAP2
MOV P2,#00H ;P2=00H
DJNZ R7,QUET;
INC DPTR
DJNZ R6,CHAY
LJMP MAIN
DELAY:
MOV TMOD,#01H
MOV TH0,#HIGH(-500)
MOV TL0,#LOW(-500)
SETB TR0
JNB TF0,$
CLR TF0
CLR TR0
RET
ORG 500
MACHU:
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH; ma trong
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0E0H,0C0H,0BFH,03FH,03FH,0BFH,0C0H,0E0H ; V
DB 07EH,07EH,07EH,000H,000H,07EH,07EH,07EH ; I
DB 00H,00H,0F9H,0F3H,0E7H,0CFH,00H,00H ; N
DB 00H,00H,0E7H,0E7H,0E7H,0E7H,00H,00H ; H
DB 07EH,07EH,07EH,000H,000H,07EH,07EH,07EH ; I
DB 0FEH,0FEH,0FEH,00H,00H,0FEH,0FEH,0FEH ; T
DB 0FFH,0C3H,099H,03CH,03CH,03CH,03CH,0BDH ; c
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
RET
END
$MOD51
ORG 00
MAIN:
MOV DPTR,#MACHU ; TRO TOI MACHU
MOV R6,#89 ; R6 89 LAN
CHAY:
MOV R7,#10 ; R7 10 LAN
QUET:
MOV R0,#00H ; R0 = 00H
MOV R1,#01H ; R1 = 01H
LAP2:
MOV P0,R1;P0=01H
MOV A,R1;A=01H
RL A; XOAY TRAI THANH GHI A, A=02H
MOV R1,A;R1=02H
MOV A,R0;A=00H
MOVC A,@A+DPTR; NAP VUNG DU LIEU
MOV P1,A;GAN DU LIEU A VAO PORT1
ACALL DELAY
INC R0; R0+1=01H
CJNE R0,#08H,LAP2;SO SANH R0 MA KO =8 THI NHAY VE LAP2
MOV P0,#00H ;P0=00H
LAP:
MOV P2,R1 ; P2=01H
MOV A,R1 ; A=01H
RL A ;XOAY TRAI THANH GHI A, A=02H
MOV R1,A ;R1=02H
MOV A,R0 ;A=00H
MOVC A,@A+DPTR ; NAP VUNG DU LIEU
MOV P1,A ;GAN DU LIEU A VAO PORT1
LCALL DELAY ;DELAY
INC R0 ;R0+1=01H
CJNE R0,#16,LAP ;SO SANH R0 MA KO =16 THI NHAY VE LAP2
MOV P2,#00H ;P2=00H
DJNZ R7,QUET;
INC DPTR
DJNZ R6,CHAY
LJMP MAIN
DELAY:
MOV TMOD,#01H
MOV TH0,#HIGH(-500)
MOV TL0,#LOW(-500)
SETB TR0
JNB TF0,$
CLR TF0
CLR TR0
RET
ORG 500
MACHU:
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH; ma trong
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0E0H,0C0H,0BFH,03FH,03FH,0BFH,0C0H,0E0H ; V
DB 07EH,07EH,07EH,000H,000H,07EH,07EH,07EH ; I
DB 00H,00H,0F9H,0F3H,0E7H,0CFH,00H,00H ; N
DB 00H,00H,0E7H,0E7H,0E7H,0E7H,00H,00H ; H
DB 07EH,07EH,07EH,000H,000H,07EH,07EH,07EH ; I
DB 0FEH,0FEH,0FEH,00H,00H,0FEH,0FEH,0FEH ; T
DB 0FFH,0C3H,099H,03CH,03CH,03CH,03CH,0BDH ; c
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
RET
END
Comment