Reputation: 179
I am trying to convert this pseudocode into LC4 assembly language
B = 0
If (A >= 0) {
While (B*B <= A) {
B = B + 1
}
}
B = B - 1
What mnemonic do I use for an if statement? Would it be CMP and for the while statement CMPI?
Upvotes: 0
Views: 1689
Reputation: 5648
I would say it's the other way around, the if
compares against a constant, while the while
does not. So use cmpi
to compare A
against 0
and cmp
to compare B*B
against A
.
Upvotes: 1