3 Programming Exercises • Implement a MIPS assembly function named test-prime that receives an integer as input argument
Posted: Sun May 15, 2022 1:30 pm
3 Programming Exercises • Implement a MIPS assembly function named test-prime that receives an integer as input argument in register $a0 and returns a 1 in $v0 if the number is a prime number, and 0 otherwise. The following skeleton code could help you as a starting point: main: li $a0, 0x3 jal test-prime test-prime: jr $ra • Call the function test-prime from the main function in order to store the first 100 prime numbers in the data segment of the mips simulator starting from memory location
Expected output : OI Data Segment Address Ox10010000 Ox10010020 Ox10010040 0x10010060 Ox10010080 Ox1001000 0x10010000 Ox1001000 Ox10010100 Ox10010120 Ox10010140 Ox10010160 Ox10010180 Value (+0) 2 23 59 97 137 179 227 269 313 367 419 461 509 Value (+4) 3 29 61 101 139 181 229 271 317 373 421 463 521 Value (+8) 5 31 67 103 149 191 233 277 331 379 431 467 523 Value (+) 7 37 71 107 151 193 239 281 337 383 433 479 541 Value (+10) 11 41 73 109 157 197 241 283 347 389 439 487 Value (+14) 13 43 79 113 163 199 251 293 349 397 443 491 0 Value (+18) 17 47 83 127 167 211 257 307 353 401 449 499 0 Value (+10) 19 53 89 131 173 223 263 311 359 409 457 503 0 0
Expected output : OI Data Segment Address Ox10010000 Ox10010020 Ox10010040 0x10010060 Ox10010080 Ox1001000 0x10010000 Ox1001000 Ox10010100 Ox10010120 Ox10010140 Ox10010160 Ox10010180 Value (+0) 2 23 59 97 137 179 227 269 313 367 419 461 509 Value (+4) 3 29 61 101 139 181 229 271 317 373 421 463 521 Value (+8) 5 31 67 103 149 191 233 277 331 379 431 467 523 Value (+) 7 37 71 107 151 193 239 281 337 383 433 479 541 Value (+10) 11 41 73 109 157 197 241 283 347 389 439 487 Value (+14) 13 43 79 113 163 199 251 293 349 397 443 491 0 Value (+18) 17 47 83 127 167 211 257 307 353 401 449 499 0 Value (+10) 19 53 89 131 173 223 263 311 359 409 457 503 0 0