# 2013 HSC Paper Question 20 (SDD) (1 Viewer)

#### sparcut

##### Member
Been trying to figure out what I'm doing wrong with this question. (Q.20, SDD HSC 2013 Paper)

I am completely stumped to how this question's correct answer is D.

Anyone got have an explanation...

#### dan964

##### MOD
Moderator
Been trying to figure out what I'm doing wrong with this question. (Q.20, SDD HSC 2013 Paper)

I am completely stumped to how this question's correct answer is D.

Anyone got have an explanation...

It is C from the MG.

SUBTR a
JMPN else

IF b-a <0 then go to else statement. that is if b<a.
This means the IF statement in the high level code corresponds with the else block in the CPU code.

(Think of the ELSE case in the high-level language as the default, and so the default in the CPU code, is the JMPN code doesn't trigger a jump to "else")

#### silverdawn565

##### Member
Oh yea I did this paper in class when we had finished the course early. I got it wrong at first I remember.
So D loads 'a' into the accumulator. Because 'b' needs to be less than 'a', a - b needs to be positive. JUPN jumps if a - b is negative to 'else'. If a - b isn't negative then it just continues on.
Actually... now I'm confused... lol
Nvm, it's not D. I agree with C now but it's confusing because 'c=a' is under 'else' instead of c=b and the command for 'IF a>b', would be 'IF b>=a' in this case...
IF b>=a THEN
c=b
ELSE
c=a
ENDIF
which is the same as saying:
IF a>b THEN
c=a
ELSE
b=a
ENDIF
Correct me if I'm wrong because I'm actually a bit confused and might have overthought it.

#### silverdawn565

##### Member
Oh yea I did this paper in class when we had finished the course early. I got it wrong at first I remember.
So D loads 'a' into the accumulator. Because 'b' needs to be less than 'a', a - b needs to be positive. JUPN jumps if a - b is negative to 'else'. If a - b isn't negative then it just continues on.
Actually... now I'm confused... lol
Nvm, it's not D. I agree with C now but it's confusing because 'c=a' is under 'else' instead of c=b and the command for 'IF a>b', would be 'IF b>=a' in this case...
IF b>=a THEN
c=b
ELSE
c=a
ENDIF
which is the same as saying:
IF a>b THEN
c=a
ELSE
b=a
ENDIF
Correct me if I'm wrong because I'm actually a bit confused and might have overthought it.
I really hope I don't take this long to solve a MCQ today in the exam though... I actually ended up deskchecking (not exactly, I drew a tree diagram for D & C...)

Last edited:

#### sparcut

##### Member
Interesting, I agree with C since:

b is put into ACC then you subtract a from the ACC.

If that results in a negative (aka a being greater than b), it puts a into ACC then stores that in c.

Then visa versa; if the result is not negative, it will put the value of b into ACC then stores that in c.

...

Last edited:

#### silverdawn565

##### Member
Lol. Pretty much what I thought for a second this morning. But C seems right its just weird that it seems reversed or something. Trick question?

#### dan964

##### MOD
Moderator
I really hope I don't take this long to solve a MCQ today in the exam though... I actually ended up deskchecking (not exactly, I drew a tree diagram for D & C...)
I didn't do SDD, so I just did it knowing using intuition.

#### silverdawn565

##### Member
I didn't do SDD, so I just did it knowing using intuition.
Oh. Well, intuition and common sense can get people far in life.

#### sparcut

##### Member
Well... it was pointed out to me before the exam that the marking guidelines actually says C.

I must have had some temporary dyslexia, cause I swear it said D.

dan, you did say it was C from the marking guidelines, but I think I skipped over that, somehow didn't understand your acronym 'MG'.

Cheers for the help anyway!