Can this cause a bug?

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A push instruction between sub and breq.

	mov	temp, chrWmax
	sub	temp, chrWval		;count = chrWmax - chrWval
	push	temp		;keep count
	breq	cntZero

RES

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely the possible bug is down to whether all destination paths have a balancing POP? Show some more context.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, provided the push/pop is balanced in either branch. The push instruction doesn't affect any flags so your SUB status bits will be seen intact in either branch destination.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes there is pop instruction further down in the code.

---
   mov   temp, chrWmax 
   sub   temp, chrWval      ;count = chrWmax - chrWval 
   push   temp      ;keep count 
   breq   cntZero
.
.
cntZero:
.
.
.
   pop   temp      ;fetch count 
---

No problem, ok. 8)

RES

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks like trouble... use another reg or store the value.
Brad

No Fate But What We Make!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
. 
. 
. 
. 
.

And nothing more happens on the stack within those "...."?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the original question is all you're interested in (restated: does a push affect the flags?), then you're fine.

If you're having a difficulty and have traced it back to this sequence of instructions, then your problem is elsewhere (as suggested above).

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But without seeing any more code, it would seem like the stack operation is just a waste of time since temp is not changed past the branch.

Looks like a puzzle with too many pieces missing, so I will take another blind guess and ask... maybe you also need SBC as well as SUB?

Getting close yet?

Brad

No Fate But What We Make!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RES is the perpetual riddle poster 8) usually adding only minute fractions of a piece of the puzzle every other so many posts...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bring it!

Brad

No Fate But What We Make!