Write a program that takes user input for 6 integers
Exit if the first one is Zero
Call a function named Add5Subtract1. Don't forget the Comment Block!
You need to create this function using a stack frame
This function takes 6 parameters
Add the first 5 parameters
Subtract the 6th parameter
Hints about main
It should also have a stack frame
Print out the results
Repeat
.data tempRet: .word 1 str1: .asciz "Hello World!" .text .global main .func main main: ldr R1, =tempRet str LR, [R1] ldr R0,=str1 bl puts ldr R1, =tempRet ldr LR, [R1] mov R0, #23 bx LR //Rene Antoun //Cstrings .data courseString:.string "RENE ANTOUN\t\tCIST 039\t\n" stringInput:.string "\nEnter a string: " inputBuffer:.SKIP 81 charsCounter:.string "There are %d characters in: \"%s\".\n" vowelsCounter:.string "There are %d vowels in: \"%s\".\n" upperFirst:.string "Upper case first characters: \"%s\".\n" messageShout:.string "Shouting: \"%s\".\n" spaceRemoverString:.string "Extra spaces removed: \"%s\".\n" .text .global main main: STMDBSP!, {LR} LDRR0, =courseString BLprintf LDRR0, =stringInput BLprintf //user input entered and read LDRR0,=inputBuffer MOVR1, #81 BLgetLine //printing number of characters LDRR0, =inputBuffer BLcountCharacter MOVR1, R0 LDRR2, =inputBuffer LDRR0, =charsCounter BL printf //printing number of vowels LDRR0, =inputBuffer BLcountVowels MOVR1, R0 LDRR2, =inputBuffer LDR R0, =vowelsCounter BLprintf //printing upper case LDRR0, =inputBuffer BLfunctionUpper LDRR1, =inputBuffer LDRR0, =upperFirst BLprintf //printing shouting the message LDRR0, =inputBuffer BLshoutingFunction LDRR1, =inputBuffer LDRR0, =messageShout BLprintf //printing the message without extra spaces LDRR0, =inputBuffer BLremoveSpaces LDRR1, =inputBuffer LDRR0, =spaceRemoverString BLprintf LDMIASP!, {LR} MOVR0, #0 BXLR //Input: // R0 is the base address of the start of the user string // R1 is the length // Output: None //getLine function getLine: STMDBSP!, {R4, R5,LR} MOVR4, R0 MOVR5, R1 secondGetLine: BLgetchar CMPR0, #'\n' BEQExit STRBR0, [R4] ADDR4, R4, #1 SUBSR5, R5, #1 BNEsecondGetLine Exit: MOVR0, #0 STRBR0, [R4] LDMIASP!, {R4, R5, LR} BXLR //INput: //R0 is the base address of the start of the user string //Output: //R0 is the number of characters in the user string countCharacter: MOVR2, #00 MOVR1, R0 charCounterLoop: LDRBR0, [R1, R2] CMP R0, #00 BEQcountingCharsDone ADDR2, R2, #01 BcharCounterLoop countingCharsDone: MOVR0, R2 BXLR //Input: // R0 is the base address of inputBuffer //Output: // R0 is the numbers of vowels in the user string //counting vowels function countVowels: STMDBSP!, {LR} MOVR1, #0 MOVR2, #00 MOVR3, R0 nextCountingVowels: LDRBR0, [R3, R2] BLtoUpper CMPR0, #00 BEQcountingVowelsDone ADDR2, R2, #1 CMPR0, #'A' BEQVowel CMPR0, #'E' BEQVowel CMPR0, #'I' BEQVowel CMPR0, #'O' BEQVowel CMPR0, #'U' BNEnextCountingVowels Vowel: ADDR1, R1, #1 BnextCountingVowels countingVowelsDone: MOVR0, R1 LDMIASP!, {LR} BXLR //Input: //R0 is the base address of inputBuffer //Output: // None //first Upper Case function functionUpper: STMDBSP!, {LR} MOVR1, R0 MOVR2, #00 MOVR3, #' ' LDRBR0, [R1] BLtoUpper STRBR0, [R1] upperLoop: LDRBR0, [R1, R2] CMPR0, #00 BEQupperDone ADDR2, R2, #1 CMPR0, #' ' BNEupperLoop LDRBR0, [R1, R2] BLtoUpper STRBR0, [R1, R2] BupperLoop upperDone: LDMIASP!, {LR} BXLR //Input: // R0 is the bas address of inputBuffer //Output: //None //shouting Function shoutingFunction: STMDBSP!, {LR} MOVR1, R0 MOVR2, #00 shoutingLoop: LDRBR0, [R1, R2] CMPR0, #00 BEQshoutingDone BLtoUpper STRBR0, [R1, R2] ADDR2, R2, #1 BshoutingLoop shoutingDone: LDMIASP!, {LR} BXLR //Input: //R0 is the base address of inputBuffer //Output: //None //remove space function removeSpaces: STMDBSP!, {LR} LDRR1, =inputBuffer LDRR2, =inputBuffer spaceRemoverLoop: LDRBR0, [R1] CMPR0, #0 BEQRemovingDone CMPR0, #' ' BNESPACE LDRBR3, [R1, #1] CMPR3, #' ' BNESPACE ADDR1, R1, #1 BspaceRemoverLoop SPACE: LDRBR3, [R1] STRBR3, [R2] ADDR1, R1, #1 ADDR2, R2, #1 BspaceRemoverLoop RemovingDone: MOVR3, #0 STRBR3, [R2] LDMIASP!, {LR} BXLR //Input: // R0 is the base address of InputBuffer //Output: //None //to upper function toUpper: CMP R0, #'a' BXLOLR CMPR0, #'z' BXHILR ANDR0, R0, #0b11011111 BXLR //RENE ANTOUN