user1993381
user1993381

Reputation: 179

LC4 Assembly instructions

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

Answers (1)

Jens Bj&#246;rnhager
Jens Bj&#246;rnhager

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

Related Questions