| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10452 | problem1 |
|
Description
We have 4 normal registers, r0, r1, r2, r3, whose initial values are all zeros. This CPU has 7 kinds of instructions, MOV, ADD, SUB, CMP, JMP, JLE, JG, whose formats are specified as follows.
MOV , copy the constant to the register
MOV , copy the value stored in the register 2 to the register 1
ADD , add the constant to the register
SUB , minus the constant value to the register
CMP ,
JLE
CMP ,
JLE
CMP ,
JG
CMP ,
JG
JMP
Please fill in the following assembly code which is a translation of the following c code using these introduced instructions and store variable “a” in r0, variable “b” in r1, variable "c" in r2, variable "d" in r3.
We will give you some hints and one "something missing" means one instruction.
c code :
int main(){int a, b, c, d;a=17;b=2;c=a;while(c<=10){d=c;while(d>1){d-=b;}c--;}}
assembly code :
MOV r0, 17
MOV r1, 2
MOV r2, r0
/* something missing */
L5 :
MOV r3, r2
JMP L3
L4 :
/* something missing */
L3 :
CMP r3, 1
/* something missing */
/* something missing */
L2 :
/* something missing */
JLE L5
Input
There is no input.
Output
Please print the complete assembly code and use minimal instructions.