Social Icons

twitterfacebookgoogle plusrss feedemail

12/31/2009

微處理機(8051)上機考古題 data move-1-7

7.Move data from external data RAM 1000H-1FFFH by the following rules
甲、If it is an even number, move to external data RAM starting from 2000H
乙、If it is an odd number, move to external data RAM starting from 3000H.
(2009.12.31.PM02:35將程式碼重新寫過)

本文章題目版權歸屬於朱老師,另外本文所提供答案並不保證其正確性


程式碼如下:
source equ 1000H
even equ 2000H
odd equ 3000H
source_last equ 1fffH

source_dph equ 30H
source_dpl equ 31H
even_dph equ 32H
even_dpl equ 33H
odd_dph equ 34H
odd_dpl equ 35H
source_last_dph equ 1FH

mov source_dph,#10H
mov source_dpl,#00H
mov even_dph,#20H
mov even_dpl,#00H
mov odd_dph,#30H
mov odd_dpl,#00H

L1:
mov dph,source_dph
mov dpl,source_dpl
movx a,@dptr
inc dptr
mov source_dph,dph
mov source_dpl,dpl
mov r0,a
rrc a
mov a,r0
jc odd1
jnc even1

even1:
mov dph,even_dph
mov dpl,even_dpl
movx @dptr,a
inc dptr
mov even_dph,dph
mov even_dpl,dpl
mov a,source_dph
cjne a,#20H,L1
JMP over

odd1:
mov dph,odd_dph
mov dpl,odd_dpl
movx @dptr,a
inc dptr
mov odd_dph,dph
mov odd_dpl,dpl
mov a,source_dph
cjne a,#source_last_dph+1,L1
JMP over

over:
nop

end

如果要複製上方程式碼,請點擊程式碼上方的    圖示會跳出一個視窗,複製即可

如果發現文章有錯誤,歡迎留言告知~謝謝指教!

沒有留言:

張貼留言

俗話說
凡走過必留下痕跡,凡住過必留下鄰居
凡爬過必留下樓梯,凡來過必留下IP
看過文章之後歡迎留下您寶貴的意見喔!

 
 
无觅相关文章插件,迅速提升网站流量