代写C C++ Java Python 视频讲解客服在线客服在线

代做国外C C++ Java程序 Python QQ 2365427650 Email 2365427650@qq.com 免费咨询编程问题

« CIT 593 Module08 LC-4 Assembly & I/OICS 51 MIPS Tutor »

ICS 51 MIPS tutor

 

ICS 51 Winter 2022 - Lab #1 Coding Activity
The goals of this lab are:
experience working with basic instructions (arithmetic, logical, shift, load & store) in MIPS
experience working with syscalls in MIPS
These programs are meant to guide you through the usage of basic instructions. To help understand each instruction we
ask that you run the program/debug between each step and examine what the result is. Each grey box contains
questions meant as a guide to help think about the action performed by the instructions and the reasons why it occurred.
Future labs will not be written in this step-by-step format. We use this format to ease the transition to understanding
assembly.
To begin, download the base files, lab1_A.asm and lab1_B.asm
. RENAME these files to lab1_A_y
ournetid
.asm
and lab1_B_y
ournetid
.asm
, replacing y
ournetid with your actual netid. (For example: If your yournetid is
panteate
, then you would name your submission lab1_A_panteate.asm
)
Program A
Open the lab1_A_y
ournetid
.asm file in MARS.
In the top of the file place your name and netid in comments
# Your full name
# Netid
N
otice, in the .data
section of the file, the following is declared for you: two integers, a 4-character array, and 3
strings.
In the .text
section of the file, create a main program which performs the following steps:
1. Print the string stored at the label, prompt
, to the screen (use a syscall) to prompt the user to enter an
integer number.
🤔
Remember a listing of all the official MARS systems calls here
. You can also find the
documentation for all instructions and supported system calls within MARS itself. Click the ?
in the toolbar (as shown in figure below) to open it.
2. Read in the integer value from the user (use a syscall).
Which register is the value placed in by the syscall?
3. Load the address (la) for the label num into a temporary register (referred to as Reg A).
🤔 Reg A can be any temporary register (
$t0-$t9
) that you want!
4. Load the value stored in memory at the label num (lw using Reg A) into a temporary register (referred to
as Reg B). Add the user's value to this value.
ICS 51 - Introduction to Computer Organization
Copyright 2020 - Prof. Jennifer Wong-Ma
This content is protected and may not be shared uploaded or distributedWhere could you put the resultant value? If you p
ut it in Reg A or B, what information is lost?
5. Print the resultant value to the screen as an integer (use a syscall) on its own line (use a syscall and the
label endl
).
6. Modify the resultant value to its negated value (eg. 10 to -10). Place the result in Reg C (a temporary
register).
There are multiple ways to do this, eg. Subtract from 0, negate instruction
Look at the number representation of this value in memory. Why is the negative number stored this way?
7. Print the value of Reg C to the screen as an integer (use a syscall) on its own line.
Do you need to reload the value from memory? Nope! It will still be in the register unless you wrote
code to modify it.
8. Store the Reg C value into memory at label
value
.
9. Print the character array stored at label abcd
as a string to the screen (use a syscall) on its own line.
What printed this time!?! Why did this happen? Think about the definition of a string and the values
in memory. Look at the memory pane of MARS to see the bytes and how they are positioned relative to
each other.
There is an option in Mars to show the symbol table. This will open a pane that specifies the address
associated with each label of your program. When you double-click on the address the Memory pane will
display the associated region of memory.
10. Shift the Reg C by 8 bits to the left (logical operation). Print the new value to the screen on its own line.
What kind of mathematical operation is performed b
y shifting to the left? to the right?
Does modifying the value Reg C change the content of memory at label
value
?
11. Store the value calculated in the previous step into memory at label
value
.
12. Print the character array, stored at label abcd
, to the screen again (use a syscall) on its own line.
What printed this time? Why did this happen?
13. Quit the program (use a syscall).
Example of expected MARS output
Enter an integer:10
2020
-2020
A
BCD øÿÿEFGHIJK
-517120
A
BCD
-- program is finished running --
Step 1 & 2
Step 5
Step 7
Step 9
Step 10
Step 12
Step 13
ICS 51 - Introduction to Computer Organization
Copyright 2022- Prof. Jennifer Wong-Ma
This content is protected and may not be shared uploaded or distributedEnter an integer:-40
1970
-1970
A
BCDNøÿÿEFGHIJK
-504320
A
BCD
-- program is finished running --
Step 1 & 2
Step 5
Step 7
Step 9
Step 10
Step 12
Step 13
Program B
Open the lab1_B_y
ournetid
.asm file in MARS.
In the top of the file place your name and netid in comments
# Your full name
# Netid
N
otice in the .data
section of the file 2 items are declared for you: an integer and a string.
In the .text
section of the file, create a main program which performs the following steps:
1. Prompt the user to enter a string of 4 characters using label, prompt
(use a syscall).
2. Read in the 4 characters from the user (use a syscall) and store the string into memory at label, str
.
🤔 For specified length n
, string can be no longer than n-1
. Set the length to 5 in order to accept 4
characters. The fifth character will be set to '\0'
(null character) to terminate the strings.
The syscall will read exactly 4 characters from the user. This means that the user does not need to press
enter to terminate the input.
3. Print the entered string stored into memory at the label str
to the screen (use a syscall) on its own line.
4. Load the first 4-bytes (a word) of the string, str
, into a temporary register (Reg A)
🤔 Memory is just Memory! It can be loaded or stored in any way we specify. The value entered is
characters, but we can load more than 1 character into a register at a time.
5. Print the value in Reg A as an integer to the screen (use a syscall) on its own line.
🤔 Data is just Data! It can be interpreted in any way we specify.
6. Print the value in Reg A in binary (use syscall 35 - see Mars help for more information) on its own line.
7. Print the value in Reg A in hexadecimal (use syscall 34 - see Mars help for more information) on its own
line.
8. Add 1 to the value in Reg A and store the result (a word) back into memory at the label, str
.
🤔 Values in registers do not affect the value in memory until stored in memory!
9. Print the modified string, str
, to the screen (use a syscall) on its own line.
What happened to the string? ASCII character encodings are just numbers! Modifying the value,
changes the character. (Ref: ASCII Character Table
)
ICS 51 - Introduction to Computer Organization
Copyright 2022- Prof. Jennifer Wong-Ma
This content is protected and may not be shared uploaded or distributed
  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Walle Build 100427

Copyright 代写C.