Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-----------------Students write their subroutine here--------------------*/
- PUSH {LR};
- LDR R0,=WelcomeString; //Print welcome msg
- BL printf;
- BL cr;
- LDR R0,= Prompt; //prepare inital size prompt
- prompt:
- BL printf; //print prompt
- BL cr;
- BL getstring;
- PUSH {R0}
- BL value; //print value
- BL cr;
- POP {R0};
- CMP R0, 0x3; //test for val<3, load prompt and branch if invalid
- ITT LT;
- LDRLT R0,= Prompt3;
- BLT prompt;
- CMP R0,10; //test for val>10, load prompt and branch if invalid
- ITT GT;
- LDRGT R0,= Prompt4;
- BGT prompt;
- STR R0, [SP, 4]; //store size on stack
- .equ outAdd, 0x20001000; //output array address
- LDR R1,= outAdd;
- PUSH {R0-R1}; //this is just moving size and address over
- POP {R1-R2}; //so R0 is unnocupied / unneccessary
- loop:
- LDR R0,= Prompt1; //start of the loop loads main prompt
- CMP R1, 0x1; //or prompt for last input
- IT EQ;
- LDREQ R0,= Prompt2;
- PUSH {R1-R2};
- keyPrompt: //seperate branch so I can print without loading original prompts
- BL printf; //print prompt
- BL cr;
- BL getstring;
- PUSH {R0};
- BL value; //print value
- BL cr;
- POP {R0};
- CMP R0, 0x0; //checks for negative value
- IT LT; //loads invalid prompt and branches back if invalid
- LDRLT R0,= Prompt5;
- BLT keyPrompt;
- POP {R1-R2}; //output value to array
- STR R0, [R2], 0x4;
- SUB R1, 0x1; //subtract from size, check if all inputs have been grabbed
- CMP R1, 0x0;
- BNE loop;
- POP {LR};
- BX LR;
- /*-------Code ends here ---------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement