Nguyên văn bởi enter88
Xem bài viết
Thông báo
Collapse
No announcement yet.
Hướng dẫn lập trình ASSEMBLY!
Collapse
X
-
Nguyên văn bởi tc8051 Xem bài viếtThanks bác.
Các chương trình khác thì mình có CLR TR0.Ko hiểu sao tự nhiên ct này thì thiếu nó.(viết lâu rồi,tại hơi lười kiểm tra lại).
Nhưng đối với ứng dụng này thì nó cũng ko ảnh hưởng gì nhiều
;************************************************* *******************************
;**************//////------------ MATRIX 8X8X2 ----------\\\\\\******************
;**------------------------------------------------------------------------------
;**////////////////__ Chuong trinh chay chu tren bo led ___\\\\\\\\\\\\\\\\\\\\\\
;**///////////////__ ma tran 8x8 loai 2 mau ________________\\\\\\\\\\\\\\\\\\\\\
;**//////////////___ Su dung vi dieu khien 89C55 cua ATMEL __\\\\\\\\\\\\\\\\\\\\
;**<<<<<<<<<<<<<---------------------------------------------->>>>>>>>>>>>>>>>>>>
;**\\\\\\\\\\\\\\ __ Thuc hien bien doi du lieu noi tiep ____////////////////////
;**\\\\\\\\\\\\\\\ ___ sang song song roi dua ra day led ___/////////////////////
;**\\\\\\\\\\\\\\\\ ---------- By Le Quoc Khai ---------- //////////////////////
;************************************************* *******************************
;************************************************* *******************************
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ CAC TEN BYTE DUNG TRONG CHUONG TRINH @@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
addrh equ 30H
addrl equ 31H
addrhsource equ 32H
addrlsource equ 33H
addrhend equ 34H
addrlend equ 35H
addrhtemp equ 36H
addrltemp equ 37H
addrhendtemp equ 38H
addrlendtemp equ 39H
chuancolor equ 3AH ;loi:dat ten byte la 40H thi tu dong cac bit dat ben duoi dang le 28H lai chuyen qua 40H va gay loi
speed_value equ 3BH
storage1 equ 20H
storage2 equ 21H
storage3 equ 22H
storage4 equ 23H
storage5 equ 24H
storage6 equ 25H
storage7 equ 26H
storage8 equ 27H
;r4 bank0 dung ho tro delay keo chu
;r5 bank0 chua gia tri du lieu hien tai
;r3 bank0 lam temp de tach byte thanh bit trong che do 8bit
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ CAC TEN BIT DUNG TRONG CHUONG TRINH @@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
col1 bit p2.0
col2 bit p2.1
col3 bit p2.2
fade bit p2.3
mreset bit p2.4
bitdata bit p2.5
gate bit p2.6
clock bit p2.7
sw_up bit p1.0
sw_down bit p1.1
sw_enter bit p1.2
sw_speed bit p1.3
sw_pause bit p1.4
sw_reverse bit p1.5
sw_negative bit p1.6
sw_mode bit p1.7
;40H dia chi bit nam o 28H
bit_sw bit 40H
bit_pause bit 41H
bit_reverse bit 42H
bit_negative bit 43H
bit_mode bit 44H
bit_speed bit 45H
bit_up bit 46H
bit_down bit 47H
bit_change bit 48H
org 00
sjmp begin
org 30h
begin:
mov speed_value,#8
mov TMOD,#11h
mov r5,#0
ljmp begin_binary
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin_binary:
mov p2,#0
mov addrlsource,#low(welcome_binary1)
mov addrhsource,#high(welcome_binary1)
clr c
mov a,#low(welcome_binary2)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary2)
subb a,#0
mov addrhend,a
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
reset_binary:
mov addrl,addrlsource
mov addrh,addrhsource
jnb bit_reverse,keochu_binary
mov a,addrhend
mov addrh,a
mov a,addrlend
mov addrl,a
keochu_binary:
mov r4,speed_value
loop2_binary:
mov TL0,#low(-20000)
mov TH0,#high(-20000)
setb tr0
loop1_binary:
lcall hienthi_binary
jnb tf0,loop1_binary
clr tr0
clr tf0
jnb bit_mode,$+6
ljmp welcome_8bit
jnb bit_change,$+6
ljmp change_binary
djnz r4,loop2_binary
mov a,addrl
clr c
jb bit_reverse,reverse_binary
jb bit_pause,$+5
addc a,#4
mov addrl,a
mov a,addrh
addc a,#0
mov addrh,a
;kiem tra da het chu chua
clr c
mov a,addrh
subb a,addrhend
jc keochu_binary
mov a,addrhend
subb a,addrh
jc reset_binary
mov a,addrlend
subb a,addrl
jc reset_binary
sjmp keochu_binary
reverse_binary:
jb bit_pause,$+5
subb a,#4
mov addrl,a
mov a,addrh
subb a,#0
mov addrh,a
;kiem tra da het chu chua
clr c
mov a,addrhsource
subb a,addrh
jc keochu_binary
mov a,addrh
subb a,addrhsource
jnc $+5
ljmp reset_binary
mov a,addrl
subb a,addrlsource
jnc $+5
ljmp reset_binary
sjmp keochu_binary
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin_8bit:
mov p2,#0
mov addrlsource,#low(welcome_8bit1)
mov addrhsource,#high(welcome_8bit1)
clr c
mov a,#low(welcome_8bit2)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit2)
subb a,#1
mov addrhend,a
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~
reset_8bit:
mov addrl,addrlsource
mov addrh,addrhsource
clr chuancolor
jnb bit_reverse,keochu_8bit
mov a,addrhend
mov addrh,a
mov a,addrlend
mov addrl,a
keochu_8bit:
mov r4,speed_value
loop2_8bit:
mov TL0,#low(-20000)
mov TH0,#high(-20000)
setb tr0
loop1_8bit:
lcall hienthi_8bit
mov a,chuancolor
inc a
cjne a,#15,$+4 ;!!! do sau mau quyet dinh tai day !!!
clr a
mov chuancolor,a
jnb tf0,loop1_8bit
clr tr0
clr tf0
jb bit_mode,$+6
ljmp welcome_binary
jnb bit_change,$+6
ljmp change_8bit
djnz r4,loop2_8bit
mov a,addrl
clr c
jb bit_reverse,reverse_8bit
jb bit_pause,$+5
addc a,#16
mov addrl,a
mov a,addrh
addc a,#0
mov addrh,a
;kiem tra da het chu chua
clr c
mov a,addrh
subb a,addrhend
jc keochu_8bit
mov a,addrhend
subb a,addrh
jc reset_8bit
mov a,addrlend
subb a,addrl
jnc $+5
ljmp reset_8bit
sjmp keochu_8bit
reverse_8bit:
jb bit_pause,$+5
subb a,#16
mov addrl,a
mov a,addrh
subb a,#0
mov addrh,a
;kiem tra da het chu chua
clr c
mov a,addrhsource
subb a,addrh
jc keochu_8bit
mov a,addrh
subb a,addrhsource
jnc $+5
ljmp reset_8bit
mov a,addrl
subb a,addrlsource
jnc $+5
ljmp reset_8bit
ljmp keochu_8bit
;++++++++++++++++++++++++++++++++++++++++++++++
hienthi_binary:
lcall checksw ;kiem tra nut bam sau moi khung hinh
mov DPL,addrl
mov DPH,addrh
mov r6,#0
lcall tachdulieu_binary
setb fade ;tranh lem hinh "do mat" mac du thuc te ko co lem
lcall truyen_col
setb fade
clr col1
clr col2
clr col3
setb gate
clr fade
clr gate
mov r6,#4
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
clr col2
clr col3
setb gate
clr fade
clr gate
mov r6,#8
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
clr col1
setb col2
clr col3
setb gate
clr fade
clr gate
mov r6,#12
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
setb col2
clr col3
setb gate
clr fade
clr gate
mov r6,#16
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
clr col1
clr col2
setb col3
setb gate
clr fade
clr gate
mov r6,#20
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
clr col2
setb col3
setb gate
clr fade
clr gate
mov r6,#24
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
clr col1
setb col2
setb col3
setb gate
clr fade
clr gate
mov r6,#28
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
setb col2
setb col3
setb gate
clr fade
clr gate
ret
;++++++++++++++++++++++++++++++++++++++++++++++
tachdulieu_binary:
;^^^^^^^^^DO^^^^^^^^^
mov a,r6
add a,#34
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage1.7,c
rlc a
mov storage1.5,c
rlc a
mov storage1.3,c
rlc a
mov storage1.1,c
rlc a
mov storage2.7,c
rlc a
mov storage2.5,c
rlc a
mov storage2.3,c
rlc a
mov storage2.1,c
mov a,r6
add a,#35
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage3.7,c
rlc a
mov storage3.5,c
rlc a
mov storage3.3,c
rlc a
mov storage3.1,c
rlc a
mov storage4.7,c
rlc a
mov storage4.5,c
rlc a
mov storage4.3,c
rlc a
mov storage4.1,c
mov a,r6
add a,#2
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage5.7,c
rlc a
mov storage5.5,c
rlc a
mov storage5.3,c
rlc a
mov storage5.1,c
rlc a
mov storage6.7,c
rlc a
mov storage6.5,c
rlc a
mov storage6.3,c
rlc a
mov storage6.1,c
mov a,r6
add a,#3
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage7.7,c
rlc a
mov storage7.5,c
rlc a
mov storage7.3,c
rlc a
mov storage7.1,c
rlc a
mov storage8.7,c
rlc a
mov storage8.5,c
rlc a
mov storage8.3,c
rlc a
mov storage8.1,c
;^^^^^^^^^XANH^^^^^^^^^
mov a,r6
add a,#32
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage1.6,c
rlc a
mov storage1.4,c
rlc a
mov storage1.2,c
rlc a
mov storage1.0,c
rlc a
mov storage2.6,c
rlc a
mov storage2.4,c
rlc a
mov storage2.2,c
rlc a
mov storage2.0,c
mov a,r6
add a,#33
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage3.6,c
rlc a
mov storage3.4,c
rlc a
mov storage3.2,c
rlc a
mov storage3.0,c
rlc a
mov storage4.6,c
rlc a
mov storage4.4,c
rlc a
mov storage4.2,c
rlc a
mov storage4.0,c
mov a,r6
add a,#0
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage5.6,c
rlc a
mov storage5.4,c
rlc a
mov storage5.2,c
rlc a
mov storage5.0,c
rlc a
mov storage6.6,c
rlc a
mov storage6.4,c
rlc a
mov storage6.2,c
rlc a
mov storage6.0,c
mov a,r6
add a,#1
movc a,@a+DPTR
jnb bit_negative,$+5
xrl a,#0ffh
rlc a
mov storage7.6,c
rlc a
mov storage7.4,c
rlc a
mov storage7.2,c
rlc a
mov storage7.0,c
rlc a
mov storage8.6,c
rlc a
mov storage8.4,c
rlc a
mov storage8.2,c
rlc a
mov storage8.0,c
ret
;++++++++++++++++++++++++++++++++++++++++++++++
hienthi_8bit:
lcall checksw ;kiem tra nut bam sau moi khung hinh
mov DPL,addrl
mov DPH,addrh
mov r6,#0
lcall tachdulieu_8bit
setb fade ;giam thoi gian ton tai chua col cuoi cung de chong lem do col cuoi thuong lau hon
lcall truyen_col
setb fade
clr col1
clr col2
clr col3
setb gate
clr fade
clr gate
mov r6,#16
lcall tachdulieu_8bit
; setb fade
lcall truyen_col
setb fade
setb col1
clr col2
clr col3
setb gate
clr fade
clr gate
mov r6,#32
lcall tachdulieu_8bit
; setb fade
lcall truyen_col
setb fade
clr col1
setb col2
clr col3
setb gate
clr fade
clr gate
mov r6,#48
lcall tachdulieu_8bit
; setb fade
lcall truyen_col
setb fade
setb col1
setb col2
clr col3
setb gate
clr fade
clr gate
mov r6,#64
lcall tachdulieu_8bit
; setb fade
lcall truyen_col
setb fade
clr col1
clr col2
setb col3
setb gate
clr fade
clr gate
mov r6,#80
lcall tachdulieu_8bit
; setb fade
lcall truyen_col
setb fade
setb col1
clr col2
setb col3
setb gate
clr fade
clr gate
mov r6,#96
lcall tachdulieu_8bit
; setb fade
lcall truyen_col
setb fade
clr col1
setb col2
setb col3
setb gate
clr fade
clr gate
mov r6,#112
lcall tachdulieu_8bit
; setb fade
lcall truyen_col
setb fade
setb col1
setb col2
setb col3
setb gate
clr fade
clr gate
ret
;++++++++++++++++++++++++++++++++++++++++++++++
tachdulieu_8bit:
mov a,r6
add a,#15
lcall tachbyte_bit
mov a,r6
add a,#14
lcall tachbyte_bit
mov a,r6
add a,#13
lcall tachbyte_bit
mov a,r6
add a,#12
lcall tachbyte_bit
mov storage8,b
mov a,r6
add a,#11
lcall tachbyte_bit
mov a,r6
add a,#10
lcall tachbyte_bit
mov a,r6
add a,#9
lcall tachbyte_bit
mov a,r6
add a,#8
lcall tachbyte_bit
mov storage7,b
mov a,r6
add a,#7
lcall tachbyte_bit
mov a,r6
add a,#6
lcall tachbyte_bit
mov a,r6
add a,#5
lcall tachbyte_bit
mov a,r6
add a,#4
lcall tachbyte_bit
mov storage6,b
mov a,r6
add a,#3
lcall tachbyte_bit
mov a,r6
add a,#2
lcall tachbyte_bit
mov a,r6
add a,#1
lcall tachbyte_bit
mov a,r6
add a,#0
lcall tachbyte_bit
mov storage5,b
;luu tam DPTR de tang len toi gia tri cap ma tran thu 2 tam thoi
mov addrhtemp,DPH
mov addrltemp,DPL
mov a,DPL
clr c
addc a,#128
mov DPL,a
mov a,DPH
addc a,#0
mov DPH,a
;gia tri DPTR bay gio da thay doi can dc phuc hoi lai sau
mov a,r6
add a,#15
lcall tachbyte_bit
mov a,r6
add a,#14
lcall tachbyte_bit
mov a,r6
add a,#13
lcall tachbyte_bit
mov a,r6
add a,#12
lcall tachbyte_bit
mov storage4,b
mov a,r6
add a,#11
lcall tachbyte_bit
mov a,r6
add a,#10
lcall tachbyte_bit
mov a,r6
add a,#9
lcall tachbyte_bit
mov a,r6
add a,#8
lcall tachbyte_bit
mov storage3,b
mov a,r6
add a,#7
lcall tachbyte_bit
mov a,r6
add a,#6
lcall tachbyte_bit
mov a,r6
add a,#5
lcall tachbyte_bit
mov a,r6
add a,#4
lcall tachbyte_bit
mov storage2,b
mov a,r6
add a,#3
lcall tachbyte_bit
mov a,r6
add a,#2
lcall tachbyte_bit
mov a,r6
add a,#1
lcall tachbyte_bit
mov a,r6
add a,#0
lcall tachbyte_bit
mov storage1,b
mov DPL,addrltemp
mov DPH,addrhtemp
ret
;++++++++++++++++++++++++++++++++++++++++++++++
tachbyte_bit:
movc a,@a+DPTR
mov r3,a
anl a,#00001111b
cjne a,chuancolor,$+4
setb c
jb bit_negative,$+4
cpl c
mov a,b
rrc a
mov b,a
mov a,r3
swap a
anl a,#00001111b
cjne a,chuancolor,$+4
setb c
jb bit_negative,$+4
cpl c
mov a,b
rrc a
mov b,a
ret
;++++++++++++++++++++++++++++++++++++++++++++++
truyen_col:
mov a,storage1
lcall truyendata
mov a,storage2
lcall truyendata
mov a,storage3
lcall truyendata
mov a,storage4
lcall truyendata
mov a,storage5
lcall truyendata
mov a,storage6
lcall truyendata
mov a,storage7
lcall truyendata
mov a,storage8
lcall truyendata
ret
;++++++++++++++++++++++++++++++++++++++++++++++
truyendata:
rlc a
mov bitdata,c
setb clock
clr clock
rlc a
mov bitdata,c
setb clock
clr clock
rlc a
mov bitdata,c
setb clock
clr clock
rlc a
mov bitdata,c
setb clock
clr clock
rlc a
mov bitdata,c
setb clock
clr clock
rlc a
mov bitdata,c
setb clock
clr clock
rlc a
mov bitdata,c
setb clock
clr clock
rlc a
mov bitdata,c
setb clock
clr clock
ret
;++++++++++++++++++++++++++++++++++++++++++++++
hienthi_speed:
lcall checksw_speed ;kiem tra nut bam sau moi khung hinh
mov DPL,addrltemp
mov DPH,addrhtemp
mov r6,#0
lcall tachdulieu_binary
setb fade ;tranh lem hinh "do mat" mac du thuc te ko co lem
lcall truyen_col
setb fade
clr col1
clr col2
clr col3
setb gate
clr fade
clr gate
mov r6,#4
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
clr col2
clr col3
setb gate
clr fade
clr gate
mov r6,#8
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
clr col1
setb col2
clr col3
setb gate
clr fade
clr gate
mov r6,#12
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
setb col2
clr col3
setb gate
clr fade
clr gate
mov r6,#16
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
clr col1
clr col2
setb col3
setb gate
clr fade
clr gate
mov r6,#20
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
clr col2
setb col3
setb gate
clr fade
clr gate
mov r6,#24
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
clr col1
setb col2
setb col3
setb gate
clr fade
clr gate
mov r6,#28
lcall tachdulieu_binary
setb fade
lcall truyen_col
setb fade
setb col1
setb col2
setb col3
setb gate
clr fade
clr gate
ret
;++++++++++++++++++++++++++++++++++++++++++++++
speed_mode:
mov p2,#0
mov addrltemp,#low(dulieu_speed)
mov addrhtemp,#high(dulieu_speed)
clr c
mov a,#low(dulieu_speed_end)
subb a,#64
mov addrlendtemp,a
mov a,#high(dulieu_speed_end)
subb a,#0
mov addrhendtemp,a
keochu_speed:
mov r4,speed_value
loop2_speedmode:
mov TL0,#low(-25000)
mov TH0,#high(-25000)
setb tr0
jb bit_sw,loop1_speedmode
jb sw_speed,loop1_speedmode
setb bit_sw
ret
loop1_speedmode:
lcall hienthi_speed
jnb tf0,loop1_speedmode
clr tr0
clr tf0
djnz r4,loop2_speedmode
mov a,addrltemp
clr c
addc a,#4
mov addrltemp,a
mov a,addrhtemp
addc a,#0
mov addrhtemp,a
;kiem tra da het chu chua
clr c
mov a,addrhtemp
subb a,addrhendtemp
jc keochu_speed
mov a,addrhendtemp
subb a,addrhtemp
jc speed_mode
mov a,addrlendtemp
subb a,addrltemp
jc speed_mode
sjmp keochu_speed
ret
;++++++++++++++++++++++++++++++++++++++++++++++
checksw:
jnb bit_sw,checksw_begin ;buong tat ca cac nut moi xet tiep
jnb sw_up,checksw_end
jnb sw_down,checksw_end
jnb sw_enter,checksw_end
jnb sw_speed,checksw_end
jnb sw_pause,checksw_end
jnb sw_reverse,checksw_end
jnb sw_negative,checksw_end
jnb sw_mode,checksw_end
clr bit_sw
checksw_begin:
jb sw_pause,$+7
setb bit_sw
cpl bit_pause
jb sw_reverse,$+7
setb bit_sw
cpl bit_reverse
jb sw_negative,$+7
setb bit_sw
cpl bit_negative
jb sw_enter,$+7
setb bit_sw
cpl bit_change
jb sw_up,$+9
setb bit_sw
setb bit_up
setb bit_change
jb sw_down,$+9
setb bit_sw
setb bit_down
setb bit_change
jb sw_mode,$+7
setb bit_sw
cpl bit_mode
jb sw_speed,$+8
setb bit_sw
lcall speed_mode
checksw_end:
ret
;++++++++++++++++++++++++++++++++++++++++++++++
checksw_speed:
jnb bit_sw,checksw_speed_begin ;buong tat ca cac nut moi xet tiep
jnb sw_up,checksw_speed_end
jnb sw_down,checksw_speed_end
jnb sw_enter,checksw_speed_end
jnb sw_speed,checksw_speed_end
jnb sw_pause,checksw_speed_end
jnb sw_reverse,checksw_speed_end
jnb sw_negative,checksw_speed_end
jnb sw_mode,checksw_speed_end
clr bit_sw
checksw_speed_begin:
jb sw_up,$+15
setb bit_sw
mov a,speed_value
dec a
cjne a,#1,$+5
sjmp $+4
mov speed_value,a
jb sw_down,$+15
setb bit_sw
mov a,speed_value
inc a
cjne a,#50,$+5
sjmp $+4
mov speed_value,a
checksw_speed_end:
ret
;++++++++++++++++++++++++++++++++++++++++++++++
change_binary:
jnb bit_up,$+6
ljmp data_up_binary
jnb bit_down,$+6
ljmp data_down_binary
clr bit_change
cjne r5,#0,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary1)
mov addrhsource,#high(dulieu_binary1)
clr c
mov a,#low(dulieu_binary2)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary2)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#1,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary2)
mov addrhsource,#high(dulieu_binary2)
clr c
mov a,#low(dulieu_binary3)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary3)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#2,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary3)
mov addrhsource,#high(dulieu_binary3)
clr c
mov a,#low(dulieu_binary4)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary4)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#3,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary4)
mov addrhsource,#high(dulieu_binary4)
clr c
mov a,#low(dulieu_binary5)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary5)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#4,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary5)
mov addrhsource,#high(dulieu_binary5)
clr c
mov a,#low(dulieu_binary6)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary6)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#5,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary6)
mov addrhsource,#high(dulieu_binary6)
clr c
mov a,#low(dulieu_binary7)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary7)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#6,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary7)
mov addrhsource,#high(dulieu_binary7)
clr c
mov a,#low(dulieu_binary8)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary8)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#7,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary8)
mov addrhsource,#high(dulieu_binary8)
clr c
mov a,#low(dulieu_binary9)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary9)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#8,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary9)
mov addrhsource,#high(dulieu_binary9)
clr c
mov a,#low(dulieu_binary9)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary9)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#9,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_binary10)
mov addrhsource,#high(dulieu_binary10)
clr c
mov a,#low(dulieu_binary11)
subb a,#64
mov addrlend,a
mov a,#high(dulieu_binary11)
subb a,#0
mov addrhend,a
ljmp reset_binary
ljmp begin
;++++++++++++++++++++++++++++++++++++++++++++++
change_8bit:
jnb bit_up,$+6
ljmp data_up_8bit
jnb bit_down,$+6
ljmp data_down_8bit
clr bit_change
cjne r5,#0,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit1)
mov addrhsource,#high(dulieu_8bit1)
clr c
mov a,#low(dulieu_8bit2)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit2)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#1,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit2)
mov addrhsource,#high(dulieu_8bit2)
clr c
mov a,#low(dulieu_8bit3)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit3)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#2,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit3)
mov addrhsource,#high(dulieu_8bit3)
clr c
mov a,#low(dulieu_8bit4)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit4)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#3,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit4)
mov addrhsource,#high(dulieu_8bit4)
clr c
mov a,#low(dulieu_8bit5)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit5)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#4,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit5)
mov addrhsource,#high(dulieu_8bit5)
clr c
mov a,#low(dulieu_8bit6)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit6)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#5,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit6)
mov addrhsource,#high(dulieu_8bit6)
clr c
mov a,#low(dulieu_8bit7)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit7)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#6,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit7)
mov addrhsource,#high(dulieu_8bit7)
clr c
mov a,#low(dulieu_8bit8)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit8)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#7,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit8)
mov addrhsource,#high(dulieu_8bit8)
clr c
mov a,#low(dulieu_8bit9)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit9)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#8,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit9)
mov addrhsource,#high(dulieu_8bit9)
clr c
mov a,#low(dulieu_8bit10)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit10)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#9,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(dulieu_8bit10)
mov addrhsource,#high(dulieu_8bit10)
clr c
mov a,#low(dulieu_8bit11)
subb a,#0
mov addrlend,a
mov a,#high(dulieu_8bit11)
subb a,#1
mov addrhend,a
ljmp reset_8bit
ljmp begin
;++++++++++++++++++++++++++++++++++++++++++++++
data_up_binary:
clr bit_up
clr bit_change
inc r5
cjne r5,#10,$+5
mov r5,#0
sjmp welcome_binary
;++++++++++++++++++++++++++++++++++++++++++++++
data_down_binary:
clr bit_down
clr bit_change
cjne r5,#0,$+5
mov r5,#10
dec r5
sjmp welcome_binary
;++++++++++++++++++++++++++++++++++++++++++++++
welcome_binary:
cjne r5,#0,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary1)
mov addrhsource,#high(welcome_binary1)
clr c
mov a,#low(welcome_binary2)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary2)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#1,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary2)
mov addrhsource,#high(welcome_binary2)
clr c
mov a,#low(welcome_binary3)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary3)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#2,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary3)
mov addrhsource,#high(welcome_binary3)
clr c
mov a,#low(welcome_binary4)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary4)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#3,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary4)
mov addrhsource,#high(welcome_binary4)
clr c
mov a,#low(welcome_binary5)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary5)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#4,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary5)
mov addrhsource,#high(welcome_binary5)
clr c
mov a,#low(welcome_binary6)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary6)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#5,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary6)
mov addrhsource,#high(welcome_binary6)
clr c
mov a,#low(welcome_binary7)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary7)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#6,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary7)
mov addrhsource,#high(welcome_binary7)
clr c
mov a,#low(welcome_binary8)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary8)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#7,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary8)
mov addrhsource,#high(welcome_binary8)
clr c
mov a,#low(welcome_binary9)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary9)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#8,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary9)
mov addrhsource,#high(welcome_binary9)
clr c
mov a,#low(welcome_binary9)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary9)
subb a,#0
mov addrhend,a
ljmp reset_binary
cjne r5,#9,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_binary10)
mov addrhsource,#high(welcome_binary10)
clr c
mov a,#low(welcome_binary11)
subb a,#64
mov addrlend,a
mov a,#high(welcome_binary11)
subb a,#0
mov addrhend,a
ljmp reset_binary
ljmp begin
;++++++++++++++++++++++++++++++++++++++++++++++
data_up_8bit:
clr bit_up
clr bit_change
inc r5
cjne r5,#10,$+5
mov r5,#0
sjmp welcome_8bit
;++++++++++++++++++++++++++++++++++++++++++++++
data_down_8bit:
clr bit_down
clr bit_change
cjne r5,#0,$+5
mov r5,#10
dec r5
sjmp welcome_8bit
;++++++++++++++++++++++++++++++++++++++++++++++
welcome_8bit:
cjne r5,#0,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit1)
mov addrhsource,#high(welcome_8bit1)
clr c
mov a,#low(welcome_8bit2)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit2)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#1,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit2)
mov addrhsource,#high(welcome_8bit2)
clr c
mov a,#low(welcome_8bit3)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit3)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#2,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit3)
mov addrhsource,#high(welcome_8bit3)
clr c
mov a,#low(welcome_8bit4)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit4)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#3,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit4)
mov addrhsource,#high(welcome_8bit4)
clr c
mov a,#low(welcome_8bit5)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit5)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#4,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit5)
mov addrhsource,#high(welcome_8bit5)
clr c
mov a,#low(welcome_8bit6)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit6)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#5,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit6)
mov addrhsource,#high(welcome_8bit6)
clr c
mov a,#low(welcome_8bit7)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit7)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#6,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit7)
mov addrhsource,#high(welcome_8bit7)
clr c
mov a,#low(welcome_8bit8)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit8)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#7,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit8)
mov addrhsource,#high(welcome_8bit8)
clr c
mov a,#low(welcome_8bit9)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit9)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#8,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit9)
mov addrhsource,#high(welcome_8bit9)
clr c
mov a,#low(welcome_8bit10)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit10)
subb a,#1
mov addrhend,a
ljmp reset_8bit
cjne r5,#9,$+30
setb mreset
mov p2,#0
mov addrlsource,#low(welcome_8bit10)
mov addrhsource,#high(welcome_8bit10)
clr c
mov a,#low(welcome_8bit11)
subb a,#0
mov addrlend,a
mov a,#high(welcome_8bit11)
subb a,#1
mov addrhend,a
ljmp reset_8bit
ljmp begin
;++++++++++++++++++++++++++++++++++++++++++++++
dulieu_speed:
db 11111111b,11111111b,11110000b,01111111b
db 11111111b,10111111b,11110000b,01111111b
db 11111111b,00011111b,11110000b,01111111b
end
Email:
Tel: 0983.497.310
Comment
-
assembly for 89c51
sư huynh nào có phần mềm viết code và debug code assembly cho 8051 k?muạc đích là xem chương trình đó chạy như thế nào và các giá trị thanh ghi cũng như cổng I/O thay đổi như thế nào?
mình đã tìm rất nhiều nhưng chảng thây phần mềm chạy mã .ASM mà toàn mà .HEX!mình cần phần mình chạy trược tiếp mã .ASM!
Comment
-
Nguyên văn bởi deking89 Xem bài viếtsư huynh nào có phần mềm viết code và debug code assembly cho 8051 k?muạc đích là xem chương trình đó chạy như thế nào và các giá trị thanh ghi cũng như cổng I/O thay đổi như thế nào?
mình đã tìm rất nhiều nhưng chảng thây phần mềm chạy mã .ASM mà toàn mà .HEX!mình cần phần mình chạy trược tiếp mã .ASM!
Comment
-
Mình học Khoa Khoa học và kĩ thuật máy tính, ngành khoa học nên chẳng liên quan gì mấy con 8051... sao sao đấy. Thế mà cái môn Kiến trúc máy tính lại bắt học Assembly mới buồn chứ. Thầy thì múa phấn ở trên mà ở dưới SV gục ngã ~_~.
Đang có bài tập lớn: Viết chương trình C hiện thực giải thuật tìm kiếm nhị phân dùng đệ quy, sau đó chuyển chương trình này sang ngôn ngữ Assembly của MIPS ISA. Chương trình được test và chạy được trên MIPS Spim.
Mình trước học C++, giờ học C# không học C nhưng chắc tìm hiểu được. Nhưng còn mấy cái kia thì...mới nghe lần đầu. Bạn nào giúp được mình giải thích cái không? Cảm ơn lắm lắm!!!
Comment
-
Nguyên văn bởi bk_kie Xem bài viếtMình học Khoa Khoa học và kĩ thuật máy tính, ngành khoa học nên chẳng liên quan gì mấy con 8051... sao sao đấy. Thế mà cái môn Kiến trúc máy tính lại bắt học Assembly mới buồn chứ. Thầy thì múa phấn ở trên mà ở dưới SV gục ngã ~_~.
Đang có bài tập lớn: Viết chương trình C hiện thực giải thuật tìm kiếm nhị phân dùng đệ quy, sau đó chuyển chương trình này sang ngôn ngữ Assembly của MIPS ISA. Chương trình được test và chạy được trên MIPS Spim.
Mình trước học C++, giờ học C# không học C nhưng chắc tìm hiểu được. Nhưng còn mấy cái kia thì...mới nghe lần đầu. Bạn nào giúp được mình giải thích cái không? Cảm ơn lắm lắm!!!
Comment
-
Nguyên văn bởi chung1608 Xem bài viếtrất tiếc cho chú là ASM có rất rất nhiều tập lệnh cho rất rất nhiều loại khác nhau .... mà mình ko biết (học ASM 8051 xong tính chơi sang ASM PIC mà đọc xong thấy có thanh ghi F nên làm biếng luôn hohoho)
Comment
-
Nguyên văn bởi chung1608 Xem bài viếtrất tiếc cho chú là ASM có rất rất nhiều tập lệnh cho rất rất nhiều loại khác nhau .... mà mình ko biết (học ASM 8051 xong tính chơi sang ASM PIC mà đọc xong thấy có thanh ghi F nên làm biếng luôn hohoho)
P/S: I am not "chú". I'm a girl
Comment
-
Nguyên văn bởi bk_kie Xem bài viếtNói thế thì cũng như không. Ôi sao cuộc đời nghiệt ngã
P/S: I am not "chú". I'm a girl
Comment
-
Nguyên văn bởi toc_mack Xem bài viếtsao không dung ledimm lap trình có phải dễ hơn không?????????
Comment
-
Nguyên văn bởi toc_mack Xem bài viếtsao không dung ledimm lap trình có phải dễ hơn không?????????
Comment
Bài viết mới nhất
Collapse
-
bởi tmcodonMình thấy diễn đàn có chuyên mục quảng cáo rồi mà. Bạn đóng góp để mở luồng riêng
-
Channel: Hướng dẫn sử dụng diễn đàn
Hôm qua, 13:36 -
-
bởi Nicole08Xin chào mọi người, tôi đã sử dụng Flashforge Inventor 2 được gần 5 năm và rất hài lòng với nó, nhưng tuần trước đã xảy ra sự cố. Có vẻ như động cơ bước đưa sợi in vào đầu nóng đã bị hỏng. Mọi thứ khác có vẻ ổn trên máy...
-
Channel: Điện tử dành cho người mới bắt đầu
Hôm qua, 12:55 -
-
Trả lời cho Hỏi về test hipot cao ápbởi nguyendinhvanCách nghĩ của bạn là theo duy tâm thôi. Còn trong công việc thì phải theo duy lý.
Bạn vào goggle và gõ từ : tiêu chuẩn an toàn cách điện.
Bạn sẽ thấy vô vàn các quy định, VN cũng có , quốc tế cũng có. Mỗi vùng , mỗi khu vực,...-
Channel: Điện tử dành cho người mới bắt đầu
02-11-2024, 20:04 -
-
bởi lamvu0677Chào mọi người, ai làm về điện, đặc biệt biến áp xung, mâý con nho nhỏ gắn vào mạch nguồn, cho e hỏi tí ą, e cũng làm trong ty về biển áp thì đo kiểm thành phẩm sẽ kiểm cao áp, tức là kiểm xem có phóng điện giữa các cuộn dây với...
-
Channel: Điện tử dành cho người mới bắt đầu
01-11-2024, 21:05 -
Comment