Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This needs to be in MIPS assembly language, need help with it. CSC263 Computer Organization & Architecture I Lab 3 When we se the nextint
This needs to be in MIPS assembly language, need help with it.
CSC263 Computer Organization & Architecture I Lab 3 When we se the nextint method of Scanner In lava, and when we use the syscall to read an Int In MIPS, the L/O routine reads the slgn (If present) and all digits of the number, and returns a 2's complement value to us. To us It seems like one step, get an int. Hut actually these routines read each digit as a character, make sure the character is valid, and build the 's complement number digit by digi Prompt the user to enter a number. Read character by character, and comblne the characters into an Integer. If there is any Invalld character, print an error message and exit the program. If the characters are all valld, print the number The number may start with a minus sign; all other characters should be digits. You may assume that the number entered will tit in a register once it is converted to an integen I strongly suggest thal you write out your alorithr in a Java style pseudocode belore starting lo write your program. we will write this routine Comments When your program reads a character, the reglster wll contain the ASCII code for the character The AScII code is a number, s if you are checking for a specifir character, Just compare the character you have to the ASCI code for the character you are checking for. Forexample, if you are checking for '', you can compare to 45 (the ASCII oode in base 10) or 0x2d (the ASCII code in base 16) . You know you are done reading in the number wheri you read n' (called line feed on the ASCII chart) The minus sign, if it appears, can only be the first character you read. If you read a minus sign after reading any digitis), that's an error Aside from the optlonal minus sign as the first character, all other characters before the newline must be digits. You will need same constants to compare with your input. Set up those canstants at the beginning of your program. - Look at the value of your number before you print it, to make sure you have converted it properly. Stop your program before it prints and look at the register containing the number to be sure it is correct. Register values are . You will be reading the digits trom leit to right high order to low order. Think about how you will turn that into an integer. It will help if you pick a simple example (like 317) and try converting it to integer digit by digit, starting displayed in hex with the 3. Be sure to line your code up In columns. I recommend starting opcodes In column 9, operands in column 1, and comments In column 38. You don't have to use these exact columns but you need to keep your code lined up. Blank lines to separate sections of your code are nice tno. Assemhler code is hard enough to read, don't make it worse by having messy code CSC263 Computer Organization & Architecture I Lab 3 When we se the nextint method of Scanner In lava, and when we use the syscall to read an Int In MIPS, the L/O routine reads the slgn (If present) and all digits of the number, and returns a 2's complement value to us. To us It seems like one step, get an int. Hut actually these routines read each digit as a character, make sure the character is valid, and build the 's complement number digit by digi Prompt the user to enter a number. Read character by character, and comblne the characters into an Integer. If there is any Invalld character, print an error message and exit the program. If the characters are all valld, print the number The number may start with a minus sign; all other characters should be digits. You may assume that the number entered will tit in a register once it is converted to an integen I strongly suggest thal you write out your alorithr in a Java style pseudocode belore starting lo write your program. we will write this routine Comments When your program reads a character, the reglster wll contain the ASCII code for the character The AScII code is a number, s if you are checking for a specifir character, Just compare the character you have to the ASCI code for the character you are checking for. Forexample, if you are checking for '', you can compare to 45 (the ASCII oode in base 10) or 0x2d (the ASCII code in base 16) . You know you are done reading in the number wheri you read n' (called line feed on the ASCII chart) The minus sign, if it appears, can only be the first character you read. If you read a minus sign after reading any digitis), that's an error Aside from the optlonal minus sign as the first character, all other characters before the newline must be digits. You will need same constants to compare with your input. Set up those canstants at the beginning of your program. - Look at the value of your number before you print it, to make sure you have converted it properly. Stop your program before it prints and look at the register containing the number to be sure it is correct. Register values are . You will be reading the digits trom leit to right high order to low order. Think about how you will turn that into an integer. It will help if you pick a simple example (like 317) and try converting it to integer digit by digit, starting displayed in hex with the 3. Be sure to line your code up In columns. I recommend starting opcodes In column 9, operands in column 1, and comments In column 38. You don't have to use these exact columns but you need to keep your code lined up. Blank lines to separate sections of your code are nice tno. Assemhler code is hard enough to read, don't make it worse by having messy codeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started