0

I am working on a project in Pep8 and this is the given pseudo-code for one block of code:

If ((Num2 is negative AND Result is negative) OR (Num2 is negative and Result is positive)) Change the sign of Result

I'm not sure how to write translate this into assembly since there are two conditionals in one statement. Also, how would you go about changing the sign of an integer?

Thank you

EDIT:

For future reference: So all I had to do was load 0 into the accumulator, and then subtract the number by that.

LDA 0,i
SUBA num1,d
STA num1
Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97
user2994884
  • 153
  • 7

1 Answers1

0

If I understood your pseudocode correct, it doesn't actually depends on Result value, only on Num2, i.e. whatever Result will be, it doesn't influence execution. So, you can rewrite your pseudo-code as

If (Num2 is negative) Change the sign of Result

and continue with assembler with just one condition

Serhii Kheilyk
  • 933
  • 1
  • 8
  • 24
  • I just noticed that, weird that he would give us that pseudo code. I have that written, but I still just need to figure out how to switch the signs of a value in assembly language. In this case, result is a .WORD – user2994884 Nov 15 '13 at 04:53
  • @user2994884, there are too many assembler languages Every CPU architecture has its own, plus there may be dialects. So, to get an answer 'how to switch signs' you need to provide CPU architecture. Data format also is significant – Serhii Kheilyk Nov 15 '13 at 05:46