2

I am having some trouble getting this procedure called DoLeftShift to work properly. The Shifter procedure is working, I know because I have test values and they all work, so the problem is in DoLeftShift.

For the shifter disabled, I am getting all 0's or all 1's, where it should be the same binary that was put in originally. Enable Shift and Shift Instruction also are not working.

Edit: Code removed because it was part of a homework assignment.

Justin
  • 170
  • 8
  • Don't vandalize your questions by removing the code. It removes the context for the answer. (If you have some reason for needing to remove some/all of the code, at least say so in the edit message or people are just going to roll it back.) – Peter Cordes Oct 08 '18 at 20:44

1 Answers1

2
mov ecx, $parm2         ;ecx = enable/disable bit
call Shifter            ;call Shifter procedure

When you call the Shifter procedure, the enable/disable is set just fine (coming from $parm2).

But when you repeatedly call the Shifter procedure from within the loopTop loop, the ECX register no longer holds the correct info!

The Shifter procedure never preserves any registers and so the CL register is returned in a toggled state (xor cl, 1 ;cl = NOT cl).

Solution:

  • Reload the ECX from $parm2 each time before calling Shifter
  • Reverse the toggle of CL preferrably at the end of the Shifter procedure.
  • Preserve any registers that do not return a value.
Sep Roland
  • 33,889
  • 7
  • 43
  • 76