I wrote a program to find the cube of a 4 bit number. Whenever I run it step by step everything works perfectly fine for every test case and there are no problems neither with the program itself nor the result generated. The problem occurs whenever I use the "Run all at a time" button, only when I try to find the cube of 0Fh. For every other case except for this one it also gives the correct answer. The result of the cube of 0Fh shown in the accumulator is F0H for some reason, but when I store it in a memory location or move it to another register, it sees it as E1H (which is the correct result).
I've tried troubleshooting this problem and what I think might be happening is that the bits of the accumulator get shifted right by one in the registers GUI, because when I tried to decrement the contents of the accumulator, the left most bit changed from 1 to 0.
I am going to attach the code of the program and a few images to further help you diagnose the problem. If the description of the problem that I've provided is not clear enough, feel free to contact me.
Edit: After further examining the problem, I've figured out that whenever the STA instruction gets called when I would use the "Run all at a time" button, the contents of the A register get shifted to the right by one bit.
I wrote a program to find the cube of a 4 bit number. Whenever I run it step by step everything works perfectly fine for every test case and there are no problems neither with the program itself nor the result generated. The problem occurs whenever I use the "Run all at a time" button, only when I try to find the cube of 0Fh. For every other case except for this one it also gives the correct answer. The result of the cube of 0Fh shown in the accumulator is F0H for some reason, but when I store it in a memory location or move it to another register, it sees it as E1H (which is the correct result). I've tried troubleshooting this problem and what I think might be happening is that the bits of the accumulator get shifted right by one in the registers GUI, because when I tried to decrement the contents of the accumulator, the left most bit changed from 1 to 0. I am going to attach the code of the program and a few images to further help you diagnose the problem. If the description of the problem that I've provided is not clear enough, feel free to contact me.
Edit: After further examining the problem, I've figured out that whenever the STA instruction gets called when I would use the "Run all at a time" button, the contents of the A register get shifted to the right by one bit.
Source code:
SUM:
ADD B DCR C JNZ SUM