这是我的代码:
init:
; expected to go in "zero" part
mvi a, 0ah
mvi e, 05h
; content of reg b is "251"
; expected to go in "zero" part
;mvi a, 0ah
;mvi e, 0ah
; if followed two are commented out content of reg b is "254"
; expected to go in "minus" part
;mvi a, 0ah
;mvi e, 03h
; if followed two are commented out content of reg b is "254"
; expected to go in "minus" part
;mvi a,0ah
;mvi e,0bh
; if followed two are commented out content of reg b is "255"
subtractionLoop:
sub e
jp subtractionLoop
jz zero
jm minus
minus:
mvi b, 0ffh
; print value as 255 to see it comes within "minus" part
; the part means last result is minus, so we can get remainder by adding
; content of reg E only one time
hlt
zero:
mvi b, 0bh
; print value as 11 to see it comes within "zero" part
hlt
我只是尝试实现简单的除法,但是当您阅读评论(;
)时,我得到了不同且有趣的结果。
我的想法如下:
只要股息为正,subtractionLoop
就继续减法。如果达到0
,则转到零部分。否则,转到减号部分。
我的错误在哪里/在哪里?
跳跃似乎不对。