Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this MIPS problem. I'm using MARS simulator to create a program that read 2 8 bit 2sc program arguments. Store them

I need help with this MIPS problem. I'm using MARS simulator to create a program that read 2 8 bit 2sc program arguments. Store them then convert and add together. Print the sum as a signed base 4 number to the console. The detailed information is listed below. Also I have no idea on the extra credit part. Please help. Thanks.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Lab Objective In this lab, you will develop a more detailed understanding of how data is represented, stored, and manipulated at the processor level. In addition to strengthening your understanding of MIPS coding, you will read a string input and learn how to convert ASCII characters into a base 4 number and print it to the console Lab Preparation Read chapters 1 and 9 from Introduction To MIPS Assembly Language Programming. Specification Functionality The functionality of your program will be as follows: 1. Read two 8-bit 2SC program arguments. These numbers may be entered as hex (using the "0x" prefix) or binary (using the "ob" prefix). The range of these inputs are: [0x80, 0x7F] in hex or [0b10000000, 0be1111111] in binary. Note that this range is [-128, 127] in decimal a. Hex inputs will be exactly 2 digits. b. Binary inputs will be exactly 8 bits. 2. Print the user inputs 3. Identify each number as hex or binary by looking at "ox" prefix for hex and "ob" prefix for 2SC binary. 4. Convert the ASCII strings into two sign-extended integer values. a. Convert the first program argument to a 32-bit two's complement number, stored in register $s1. b. Convert the second program argument to a 32-bit two' s complement number, stored in register $s2. 5. Add the two integer values, store the sum in $s0 6. Print the sum as a signed base 4 number to the console. Do not print any leading 0s. a. If the number is negative, print a negative sign and the magnitude b. If the number is positive, just print the magnitude 7. (Extra credit) Read in the program arguments as signed decimal numbers and print the sum as a base 4 value a. The program arguments can be any decimal number between -128 and 127. These arguments do not need a prefix, and will not have any leading zeros (e.g. the number 9 will entered as "9" not "e9") b. Note that the ASCII code for a negative sign ("-") is ex20. Two Parts Part A: Block Diagram & Pseudocode Before coding, you will first create a top level block diagram or flowchart to show how the different portions of your program will work together. Use https:L/www.draw.io or a similar drafting program to create this document. This diagram will be contained in the file Diagram.pdf. This diagram must be computer generated to receive full credit. Next, you will create pseudocode that outlines your program. Your pseudocode will appear underneath your header comment in Lab4.asm. You may modify your pseudocode as you develop your program. Your pseudocode must be present in your final submission Guidelines on developing pseudocode can be found here: Wr Part B: Assembly Code Write a program in MIPS to implement the functionality. Output An example of the expected output is given below. Your code's output format should match this output format exactly. New line characters are printed after each number representation. Here are several example program outputs: You entered the numbers: 0x35 0xF4 The sum in base 4 is: 221 program is finished running You entered the numbers: 0xCE Ob11110100 The sum in base 4 is -332 program is finished running You entered the numbers: 53 -12 The sum in base 4 is 221 program is finished running -- You entered the numbers: OxCE -12 The sum in base 4 is: -332 - program is finished running Syscalls When printing the integer values, you may use syscall system services 4 (print string) and 11 (print character). You may not use the following syscalls: 1 (print integer) 5 (read integer) 12 (read character) 34 (print integer as hexadecimal) 35 (print integer as binary) 36 (print integer as unsigned) You will lose a significant number of points if you use any of these syscalls. See the rubric for more details Input In this lab you will obtain two user inputs, not using a syscall, but by using program arguments. The user will enter two values separated by one space as indicated above. These numbers will be sign-extended to 32 bits and stored in $s1 and $s2. Turn on program arguments from the Settings menu as shown below Settings Show Labels Window (symbol table) Program arguments provided to MIPS progranm Tools Help Popup dialog for input syscalls (5,6,7,8,12) V Addresses displayed in hexadecimal Values displayed in hexadecimal Assemble file upon opening Assemble all files in directory Assembler warnings are considered errors Initialize Program Counter to global 'main' if defined Permit extended (pseudo) instructions and formats Delayed branching Self-modifying code Editor... Highlighting... Exception Handler. Memory Configuration... Text Segment Program Arguments Bkpt AddressCode Basic Source When program arguments are entered and the code is run, $a0 initially contains the number of program arguments entered (program arguments are separated by spaces). The register $al initially contains an address that we will call Address 1. If we go to Address 1 in memory, we will find another address, which we will call Address 2A. If we go to Address 2A in memory, we will find the ASCII encoding for the first byte of the first string entered in the program arguments. Turn Off Delayed Branching From the settings menu, make sure Delayed branching is unchecked. Show Labels Window (symbol table) Program arguments provided to MIPS program Popup dialog for input syscalls (5,6,7,8,12) V Addresses displayed in hexadecimal VValues displayed in hexadecimal Assemble file upon opening Assemble all files in directory Assembler warnings are considered errors Initialize Program Counter to global 'main' if defined Permit extended (pseudo) instructions and formats Delayed branching Self-modifying code Editor... Highlighting. Exception Handler... Memory Configuration... Checking this option will insert a "delay slot" which makes the next instruction after a branch execute, no matter the outcome of the branch. To avoid having your program behave in unpredictable ways, make sure Delayed branching is turned off. In addition, add a nop instruction after each branch instruction. For example: LI $t1 2 LOOP: ADDI $t0 $t0 1 BLT $to $t1 LOOP NOP # nop added after the branch instruction MIPS Memory Configuration To find the program arguments more easily in memory, you may choose to develop your program using a compact memory configuration (Settings- Memory Configuration) However, your program MUST function properly using the Default memory configuration. You should not run into issues as long as you do not hard-code any memory addresses in your program. Make sure to test your program thoroughly using the Default memory configuration MIPS Memory Configuration exffffffff memory map exffffffff kenel space high address Oxffffe080 MMIO base address exftfeffft kenel data segment limit address 8x90808080 kdata base address 8x8ffffffc kernel text limit address 8x80800180 exception handler address 8x80008080 kernel space base address 0x80000080 ktext base address ex7fffffff user space high address limit address Configuration Default Compact, Data at Address 0x71fffff data segment limit address Compact, Text at Address 0 Ox7ffffffe stack base address 8x71ffeffc stack pointer Ssp 0x10848080 stack limit address 8x10848080 heap base address 8x108180 data base address 8x10808080 global pointer Sgp 8x18808080 data segment base address 8x10000000 .extern base address exeffffffe text limit address Lab Objective In this lab, you will develop a more detailed understanding of how data is represented, stored, and manipulated at the processor level. In addition to strengthening your understanding of MIPS coding, you will read a string input and learn how to convert ASCII characters into a base 4 number and print it to the console Lab Preparation Read chapters 1 and 9 from Introduction To MIPS Assembly Language Programming. Specification Functionality The functionality of your program will be as follows: 1. Read two 8-bit 2SC program arguments. These numbers may be entered as hex (using the "0x" prefix) or binary (using the "ob" prefix). The range of these inputs are: [0x80, 0x7F] in hex or [0b10000000, 0be1111111] in binary. Note that this range is [-128, 127] in decimal a. Hex inputs will be exactly 2 digits. b. Binary inputs will be exactly 8 bits. 2. Print the user inputs 3. Identify each number as hex or binary by looking at "ox" prefix for hex and "ob" prefix for 2SC binary. 4. Convert the ASCII strings into two sign-extended integer values. a. Convert the first program argument to a 32-bit two's complement number, stored in register $s1. b. Convert the second program argument to a 32-bit two' s complement number, stored in register $s2. 5. Add the two integer values, store the sum in $s0 6. Print the sum as a signed base 4 number to the console. Do not print any leading 0s. a. If the number is negative, print a negative sign and the magnitude b. If the number is positive, just print the magnitude 7. (Extra credit) Read in the program arguments as signed decimal numbers and print the sum as a base 4 value a. The program arguments can be any decimal number between -128 and 127. These arguments do not need a prefix, and will not have any leading zeros (e.g. the number 9 will entered as "9" not "e9") b. Note that the ASCII code for a negative sign ("-") is ex20. Two Parts Part A: Block Diagram & Pseudocode Before coding, you will first create a top level block diagram or flowchart to show how the different portions of your program will work together. Use https:L/www.draw.io or a similar drafting program to create this document. This diagram will be contained in the file Diagram.pdf. This diagram must be computer generated to receive full credit. Next, you will create pseudocode that outlines your program. Your pseudocode will appear underneath your header comment in Lab4.asm. You may modify your pseudocode as you develop your program. Your pseudocode must be present in your final submission Guidelines on developing pseudocode can be found here: Wr Part B: Assembly Code Write a program in MIPS to implement the functionality. Output An example of the expected output is given below. Your code's output format should match this output format exactly. New line characters are printed after each number representation. Here are several example program outputs: You entered the numbers: 0x35 0xF4 The sum in base 4 is: 221 program is finished running You entered the numbers: 0xCE Ob11110100 The sum in base 4 is -332 program is finished running You entered the numbers: 53 -12 The sum in base 4 is 221 program is finished running -- You entered the numbers: OxCE -12 The sum in base 4 is: -332 - program is finished running Syscalls When printing the integer values, you may use syscall system services 4 (print string) and 11 (print character). You may not use the following syscalls: 1 (print integer) 5 (read integer) 12 (read character) 34 (print integer as hexadecimal) 35 (print integer as binary) 36 (print integer as unsigned) You will lose a significant number of points if you use any of these syscalls. See the rubric for more details Input In this lab you will obtain two user inputs, not using a syscall, but by using program arguments. The user will enter two values separated by one space as indicated above. These numbers will be sign-extended to 32 bits and stored in $s1 and $s2. Turn on program arguments from the Settings menu as shown below Settings Show Labels Window (symbol table) Program arguments provided to MIPS progranm Tools Help Popup dialog for input syscalls (5,6,7,8,12) V Addresses displayed in hexadecimal Values displayed in hexadecimal Assemble file upon opening Assemble all files in directory Assembler warnings are considered errors Initialize Program Counter to global 'main' if defined Permit extended (pseudo) instructions and formats Delayed branching Self-modifying code Editor... Highlighting... Exception Handler. Memory Configuration... Text Segment Program Arguments Bkpt AddressCode Basic Source When program arguments are entered and the code is run, $a0 initially contains the number of program arguments entered (program arguments are separated by spaces). The register $al initially contains an address that we will call Address 1. If we go to Address 1 in memory, we will find another address, which we will call Address 2A. If we go to Address 2A in memory, we will find the ASCII encoding for the first byte of the first string entered in the program arguments. Turn Off Delayed Branching From the settings menu, make sure Delayed branching is unchecked. Show Labels Window (symbol table) Program arguments provided to MIPS program Popup dialog for input syscalls (5,6,7,8,12) V Addresses displayed in hexadecimal VValues displayed in hexadecimal Assemble file upon opening Assemble all files in directory Assembler warnings are considered errors Initialize Program Counter to global 'main' if defined Permit extended (pseudo) instructions and formats Delayed branching Self-modifying code Editor... Highlighting. Exception Handler... Memory Configuration... Checking this option will insert a "delay slot" which makes the next instruction after a branch execute, no matter the outcome of the branch. To avoid having your program behave in unpredictable ways, make sure Delayed branching is turned off. In addition, add a nop instruction after each branch instruction. For example: LI $t1 2 LOOP: ADDI $t0 $t0 1 BLT $to $t1 LOOP NOP # nop added after the branch instruction MIPS Memory Configuration To find the program arguments more easily in memory, you may choose to develop your program using a compact memory configuration (Settings- Memory Configuration) However, your program MUST function properly using the Default memory configuration. You should not run into issues as long as you do not hard-code any memory addresses in your program. Make sure to test your program thoroughly using the Default memory configuration MIPS Memory Configuration exffffffff memory map exffffffff kenel space high address Oxffffe080 MMIO base address exftfeffft kenel data segment limit address 8x90808080 kdata base address 8x8ffffffc kernel text limit address 8x80800180 exception handler address 8x80008080 kernel space base address 0x80000080 ktext base address ex7fffffff user space high address limit address Configuration Default Compact, Data at Address 0x71fffff data segment limit address Compact, Text at Address 0 Ox7ffffffe stack base address 8x71ffeffc stack pointer Ssp 0x10848080 stack limit address 8x10848080 heap base address 8x108180 data base address 8x10808080 global pointer Sgp 8x18808080 data segment base address 8x10000000 .extern base address exeffffffe text limit address

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

LO 2-2 What are the Ways to analyze different kinds of audiences.

Answered: 1 week ago

Question

1. Organize and support your main points

Answered: 1 week ago

Question

3. Move smoothly from point to point

Answered: 1 week ago

Question

5. Develop a strong introduction, a crucial part of all speeches

Answered: 1 week ago