nhờ các cao thủ về asm giúp em vụ này, tình hình là em đang cố tập tành về cái đồng hô, em có tham khảo 1 số code của các bác trên diễn đàn và thử đoạn code này nhưng khi mô phỏng thì nó ko hoạt đông, và cụ thể là nó chớp 1 lần rồi im luôn, hy vọng các bác bớt chút thời gian giúp hộ em, cảm ơn các bác nhiều
GIO EQU 09H
PHUT EQU 0AH
GIAY EQU 0BH
SODIACHI EQU 0CH
CHONHANG EQU P2
RAMHIENTHI EQU 0C0H
RAMTAM EQU 07FH
CON_TRO EQU R0
DIA_CHI EQU R1
SO_COT EQU R2
TOC_DO EQU R3
DICHBIT EQU 08H
SCK BIT P3.1 ;pin 11 74HC595
RCK BIT P3.2 ;pin 12 74HC595
SI BIT P3.0 ;pin 14 74HC595
TAM EQU 0EH
SOLANDICH EQU 0FH
ORG 30H
CUONG:
MOV SP,#50H
;MOV DPTR,#WELLCOME
;CALL DICHRAMLEN
;CALL DICHRAMXUONG
;CALL DICHRAMQUATRAI
;CALL DICHRAMQUAPHAI
JMP CT1
MOV GIO,#4
MOV PHUT,#2
MOV GIAY,#2
CALL LOADDATAVAORAM
JMP CUONG
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CT1:;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
; CALL XOARAMHIENTHI
CALL XOARAMTAM
MOV R5,#30 ; TOCDO
MOV SOLANDICH,#8
MOV GIO,#4
MOV PHUT,#2
MOV GIAY,#2
CALL LOADDATAVAORAM
LAPCT1:
CALL XOARAMHIENTHI
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
DJNZ R5,LAPCT1
MOV R5,#30
CALL DICHDONGHOLEN
DJNZ SOLANDICH,LAPCT1
JMP CT1;RET
XOARAMHIENTHI:
PUSH 00
PUSH 02
PUSH 01
MOV R0,#RAMHIENTHI
MOV R2,#80 ; SO COT
MOV A,#0
LAPXOA:
MOV @R0,A
INC R0
DJNZ R2,LAPXOA
POP 02
POP 01
POP 00
RET
XOARAMTAM:
PUSH 00
PUSH 02
PUSH 01
MOV R0,#RAMTAM
MOV R2,#80 ; SO COT
MOV A,#0
LAPXOA1:
MOV @R0,A
INC R0
DJNZ R2,LAPXOA1
POP 02
POP 01
POP 00
RET
; NAP DL GIO PHUT GIAY VÀO RAM
LOADDATAVAORAM:
MOV R0,#RAMTAM; LAY DIA CHI DAU TIEN
MOV A,GIO
CALL LOADLENCHUC
CALL COTTRONG
MOV A,GIO
CALL LOADLENDONVI
CALL CHAM_N
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
MOV A,PHUT
CALL LOADLENCHUC
CALL COTTRONG
MOV A,PHUT
CALL LOADLENDONVI
CALL CHAM_N
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
MOV A,GIAY
CALL LOADLENCHUC
CALL COTTRONG
MOV A,GIAY
CALL LOADLENDONVI
CALL CHAM_N
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
RET
LOADRAMTAMSANGRAMHIENTHI:
PUSH 00
PUSH 01
PUSH 02
MOV R0,#RAMTAM
MOV R1,#RAMHIENTHI
MOV R2,#80; SO COT
LAPCOP:
MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R2,LAPCOP
POP 00
POP 01
POP 02
RET
LOADLENCHUC:
PUSH 00
PUSH 01
PUSH 02
MOV DPTR,#BANG_SO_NHO
ANL A,#0F0H
SWAP A
MOV B,#6
MUL AB
MOV R1,A
MOV R2,#6 ; SO PHAN TU CAN LAY
LAPCHUC:
MOVC A,@A+DPTR
MOV @R0,A
INC R1
INC DPTR
MOV A,R1
DJNZ R2,LAPCHUC
POP 00
POP 01
POP 02
RET
COTTRONG:
MOV A,#0
MOV @R0,A
INC DPTR
RET
CHAM_N:
PUSH 00
PUSH 01
PUSH 02
MOV DPTR,#BANG_SO_NHO
MOV A,#66
MOV R1,A
MOV R2,#4
LAPCHAM:
MOVC A,@A+DPTR
MOV @R0,A
INC DPTR
INC R1
DJNZ R2,LAPCHAM
POP 00
POP 01
POP 02
RET
DICHDONGHOLEN:
PUSH 00
PUSH 01
PUSH 02
MOV R1,#RAMTAM
MOV R2,#80 ; SO COT CUA BANG
LAPDICH:
MOV A,@R1
;CLR C
RLC A
MOV @R1,A
INC R1
DJNZ R2,LAPDICH
POP 00
POP 01
POP 02
RET
LOADLENDONVI:
PUSH 00
PUSH 01
PUSH 02
MOV DPTR,#BANG_SO_NHO
ANL A,#0FH
SWAP A
MOV B,#6
MUL AB
MOV R1,A
MOV R2,#6 ; SO PHAN TU CAN LAY
LAPDV:
MOVC A,@A+DPTR
MOV @R0,A
INC R1
INC DPTR
MOV A,R1
DJNZ R2,LAPDV
POP 00
POP 01
POP 02
RET
GIO EQU 09H
PHUT EQU 0AH
GIAY EQU 0BH
SODIACHI EQU 0CH
CHONHANG EQU P2
RAMHIENTHI EQU 0C0H
RAMTAM EQU 07FH
CON_TRO EQU R0
DIA_CHI EQU R1
SO_COT EQU R2
TOC_DO EQU R3
DICHBIT EQU 08H
SCK BIT P3.1 ;pin 11 74HC595
RCK BIT P3.2 ;pin 12 74HC595
SI BIT P3.0 ;pin 14 74HC595
TAM EQU 0EH
SOLANDICH EQU 0FH
ORG 30H
CUONG:
MOV SP,#50H
;MOV DPTR,#WELLCOME
;CALL DICHRAMLEN
;CALL DICHRAMXUONG
;CALL DICHRAMQUATRAI
;CALL DICHRAMQUAPHAI
JMP CT1
MOV GIO,#4
MOV PHUT,#2
MOV GIAY,#2
CALL LOADDATAVAORAM
JMP CUONG
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CT1:;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
; CALL XOARAMHIENTHI
CALL XOARAMTAM
MOV R5,#30 ; TOCDO
MOV SOLANDICH,#8
MOV GIO,#4
MOV PHUT,#2
MOV GIAY,#2
CALL LOADDATAVAORAM
LAPCT1:
CALL XOARAMHIENTHI
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
DJNZ R5,LAPCT1
MOV R5,#30
CALL DICHDONGHOLEN
DJNZ SOLANDICH,LAPCT1
JMP CT1;RET
XOARAMHIENTHI:
PUSH 00
PUSH 02
PUSH 01
MOV R0,#RAMHIENTHI
MOV R2,#80 ; SO COT
MOV A,#0
LAPXOA:
MOV @R0,A
INC R0
DJNZ R2,LAPXOA
POP 02
POP 01
POP 00
RET
XOARAMTAM:
PUSH 00
PUSH 02
PUSH 01
MOV R0,#RAMTAM
MOV R2,#80 ; SO COT
MOV A,#0
LAPXOA1:
MOV @R0,A
INC R0
DJNZ R2,LAPXOA1
POP 02
POP 01
POP 00
RET
; NAP DL GIO PHUT GIAY VÀO RAM
LOADDATAVAORAM:
MOV R0,#RAMTAM; LAY DIA CHI DAU TIEN
MOV A,GIO
CALL LOADLENCHUC
CALL COTTRONG
MOV A,GIO
CALL LOADLENDONVI
CALL CHAM_N
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
MOV A,PHUT
CALL LOADLENCHUC
CALL COTTRONG
MOV A,PHUT
CALL LOADLENDONVI
CALL CHAM_N
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
MOV A,GIAY
CALL LOADLENCHUC
CALL COTTRONG
MOV A,GIAY
CALL LOADLENDONVI
CALL CHAM_N
CALL LOADRAMTAMSANGRAMHIENTHI
CALL QUET8HANG
RET
LOADRAMTAMSANGRAMHIENTHI:
PUSH 00
PUSH 01
PUSH 02
MOV R0,#RAMTAM
MOV R1,#RAMHIENTHI
MOV R2,#80; SO COT
LAPCOP:
MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R2,LAPCOP
POP 00
POP 01
POP 02
RET
LOADLENCHUC:
PUSH 00
PUSH 01
PUSH 02
MOV DPTR,#BANG_SO_NHO
ANL A,#0F0H
SWAP A
MOV B,#6
MUL AB
MOV R1,A
MOV R2,#6 ; SO PHAN TU CAN LAY
LAPCHUC:
MOVC A,@A+DPTR
MOV @R0,A
INC R1
INC DPTR
MOV A,R1
DJNZ R2,LAPCHUC
POP 00
POP 01
POP 02
RET
COTTRONG:
MOV A,#0
MOV @R0,A
INC DPTR
RET
CHAM_N:
PUSH 00
PUSH 01
PUSH 02
MOV DPTR,#BANG_SO_NHO
MOV A,#66
MOV R1,A
MOV R2,#4
LAPCHAM:
MOVC A,@A+DPTR
MOV @R0,A
INC DPTR
INC R1
DJNZ R2,LAPCHAM
POP 00
POP 01
POP 02
RET
DICHDONGHOLEN:
PUSH 00
PUSH 01
PUSH 02
MOV R1,#RAMTAM
MOV R2,#80 ; SO COT CUA BANG
LAPDICH:
MOV A,@R1
;CLR C
RLC A
MOV @R1,A
INC R1
DJNZ R2,LAPDICH
POP 00
POP 01
POP 02
RET
LOADLENDONVI:
PUSH 00
PUSH 01
PUSH 02
MOV DPTR,#BANG_SO_NHO
ANL A,#0FH
SWAP A
MOV B,#6
MUL AB
MOV R1,A
MOV R2,#6 ; SO PHAN TU CAN LAY
LAPDV:
MOVC A,@A+DPTR
MOV @R0,A
INC R1
INC DPTR
MOV A,R1
DJNZ R2,LAPDV
POP 00
POP 01
POP 02
RET
Comment