SBB command error
pranabendra opened this issue · comments
Pranabendra Prasad Chandra commented
Initially, CY = 0. Upon running the following code,
MVI A,01H
MVI B,FFH
SBB B
STA 0020H
HLT
the output is 02H in 0020H, which is correct.
Now, initially, when CY = 0, upon running this code,
MVI A,01H
MVI B,FFH
STC
SBB B
STA 0020H
HLT
the output is 03H in 0020H. But, the correct answer is 01H.
After studying the codebase of this project, I could relate this bug to these lines below :
In the 2nd case, STC puts CY = 1. Therefore,
Line 959 in 9634aeb
is true,
and hence,
Line 960 in 9634aeb
Here, as value of B is rhs, I think rhs++
or lhs--
will give the correct results.