Last active
February 26, 2016 02:37
0123H存於RAM:31H 30H(30H為低位元組),求某數的6.5倍,其結果存於31H~30H
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;0123h存於ram:31h 30h(30h為低位元組),求某數的6.5倍,其結果存於31h~30h | |
; | |
;==============主程式============= | |
org 00h | |
mov sp,#5fh | |
;----------------初始直設定------------- | |
mov 30h,#23h | |
mov 31h,#01h | |
;----------------30h 31h複製到40h 41h------------- | |
mov r0,#30h | |
mov r1,#40h | |
mov b,#2 | |
call movloop | |
;----------------30h 31h複製到42h 43h------------- | |
mov r0,#30h | |
mov r1,#42h | |
mov b,#2 | |
call movloop | |
;----------------30h 31h乘四倍------------- | |
mov r0,#30h | |
mov b,#2 | |
call l_shift | |
mov r0,#30h | |
mov b,#2 | |
call l_shift | |
;----------------40h 41h乘兩倍------------- | |
mov r0,#40h | |
mov b,#2 | |
call l_shift | |
;----------------42h 43h除兩倍------------- | |
mov r0,#43h | |
mov b,#2 | |
call r_shift | |
;----------------四倍加兩倍------------- | |
mov r0,#30h | |
mov r1,#40h | |
mov b,#2 | |
call add_loop | |
;----------------再加1/2倍------------- | |
mov r0,#30h | |
mov r1,#42h | |
mov b,#2 | |
call add_loop | |
jmp $;主程式最後面通常加上jmp $ | |
;================================ | |
;------------副程式------------ | |
l_shift: clr c | |
rl_loop: mov a,@r0 | |
rlc a | |
mov @r0,a | |
inc r0 | |
djnz b,rl_loop | |
ret | |
r_shift: clr c | |
rr_loop: mov a,@r0 | |
rrc a | |
mov @r0,a | |
dec r0 | |
djnz b,rr_loop | |
ret | |
add_loop clr c | |
add_lp mov a,@r0 | |
addc a,@r1 | |
mov @r0,a | |
inc r0 | |
inc r1 | |
djnz b,add_lp | |
ret | |
movloop: mov a,@r0 | |
mov @r1,a | |
inc r0 | |
inc r1 | |
djnz b,movloop | |
ret | |
end;程式碼的最後面加上end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment