Social Icons

twitterfacebookgoogle plusrss feedemail

1/01/2010

微處理機(8051)上機考古題 Arithmetic 2-12

12.Write a program to perform the multiplication of a 32-bit unsigned number stored at (20-23H) and a 16-bit unsigned number stored at (24-25H) and put the result as a 48-bit unsigned number at (30-35H). 
For example, if (20-23H)=98765432H and (24-25H)=1234H, then (30-35H)=0x0AD749F49E28H.(2010.01.01.PM03:32將程式碼補上)
本文章題目版權歸屬於朱老師,另外本文所提供答案並不保證其正確性


程式碼如下:
;32*16
source_h equ 20h
source_lm equ 21h
source_rm equ 22h
source_l equ 23h

source_mul_h equ 24h
source_mul_l equ 25h

dest_lh equ 30h
dest_rh equ 31h
dest_lm equ 32h
dest_rm equ 33h
dest_ll equ 34h
dest_rl equ 35h

dest_buf_lh equ 3fh
dest_buf_h equ 40h
dest_buf_lm equ 41h
dest_buf_rm equ 42h
dest_buf_l equ 43h

mov source_h,#98h
mov source_lm,#76h
mov source_rm,#54h
mov source_l,#32h

mov source_mul_h,#12h
mov source_mul_l,#34h

mov r2,source_mul_l  ;time-num
mov r3,source_mul_h  ;time-num

mul_l_x_source:
mov a,dest_rl
add a,source_l
mov dest_rl,a

mov a,dest_ll
addc a,source_rm
mov dest_ll,a

mov a,dest_rm
addc a,source_lm
mov dest_rm,a

mov a,dest_lm
addc a,source_h
mov dest_lm,a

mov a,dest_rh
addc a,#0
mov dest_rh,a


djnz r2,mul_l_x_source

mul_h_x_source:
mov a,dest_buf_l
add a,source_l
mov dest_buf_l,a

mov a,dest_buf_rm
addc a,source_rm
mov dest_buf_rm,a

mov a,dest_buf_lm
addc a,source_lm
mov dest_buf_lm,a

mov a,dest_buf_h
addc a,source_h
mov dest_buf_h,a

mov a,dest_buf_lh
addc a,#0
mov dest_buf_lh,a

djnz r3,mul_h_x_source

add_dest:
mov a,dest_buf_l
add a,dest_ll
mov dest_ll,a

mov a,dest_buf_rm
addc a,dest_rm
mov dest_rm,a

mov a,dest_buf_lm
addc a,dest_lm
mov dest_lm,a

mov a,dest_buf_h
addc a,dest_rh
mov  dest_rh,a


mov a,dest_lh
addc a,dest_buf_lh
mov dest_lh,a

end


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


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

沒有留言:

張貼留言

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

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