Download presentation
Presentation is loading. Please wait.
1
CS334: MIPS language _Mars simulator Lab 2_1
2
Part1:MIPS assembly language. Questions.
Contents: introduction. Part1:MIPS assembly language. Questions. Ins.Ebtesam AL-Etowi
3
Assembly Language Instructions are the primitive operations that the CPU may execute. Different CPUs implement different sets of instructions. The set of instructions a particular CPU implements is an Instruction Set Architecture (ISA). Examples: Intel 80x86 (Pentium 4), IBM/Motorola PowerPC (Macintosh), MIPS, Intel IA64, ... Ins.Ebtesam AL-Etowi
4
MIPS Architecture MIPS – semiconductor company that built one of the first commercial RISC architectures MIPS is simple, elegant. Assembly Operands are registers Groups of 32 bits called a word in MIPS The Text segment shows you: Address -- where this instruction is stored in memory Code -- the machine code of the instruction Basic -- [not too helpful at this point] Source -- the original instruction you typed in Ins.Ebtesam AL-Etowi
5
List of Instructions Ins.Ebtesam AL-Etowi
6
Part 1: MIPS .text $t1 = 3 + 5 + 9 addi $t1, $zero, 3
Start the program with: .text This says that the following are program instructions (and not, e.g.,data). Let's do the following: $t1 = First, let's put 3 in $t1: addi $t1, $zero, 3 Ins.Ebtesam AL-Etowi
7
Part 1: MIPS (cont…) addi $t1, $t1, 5 addi $t1, $t1, 9
This says to take what is stored in register $zero, add 3 to it, and put the result in register $t1. $zero ALWAYS contains 0, so this puts into register $t1 Now we want to add 5 to our running sum: addi $t1, $t1, 5 And then we want to add 9: addi $t1, $t1, 9 Save and Assemble the program (run it). You will see that $t1 contains 0x The 0x just means that the number following it is in hex. Ins.Ebtesam AL-Etowi
8
Performing the program
Pc : Special register keeping the address of next instruction . Read the code from memory by pc . $at : assembler temporary as handle for save value . Ins.Ebtesam AL-Etowi
9
Questions Answer: 17 program counter = 0x00400000
Question 1: What decimal number is 0x ? Answer: 17 Question 2: before the first instruction is executed (the program counter is the register labeled "pc") program counter = __________ program counter = 0x Ins.Ebtesam AL-Etowi
10
Cont..)) Questions program counter = 0x00400004 $t1 = 0x00000003
Question 3: after the first instruction is executed: program counter = $t1 = program counter = 0x $t1 = 0x Question 4: after the second instruction is executed: program counter = $t1 = ____________ program counter = 0x $t1 = 0x Ins.Ebtesam AL-Etowi
11
Cont..)) Questions program counter = 0x0040000C $t1 = 0x00000011
Question 5: after the third instruction is executed: program counter = ___________ $t1 = _____________ program counter = 0x C $t1 = 0x Question 6: Complete this sentence: After each instruction, the PC is incremented so that it contains: 1) A bit which is a 0 or 1. 2) A byte which is 8 bits. 3) A word which is 4 bytes. Ins.Ebtesam AL-Etowi
12
Cont..)) Questions Hint : In a MIPS architecture, each byte has its own address (the byte is the "addressable unit"). Question 7: How big are instructions in MIPS? Number of bits = Number of bytes = Number of words = 32 4 1 Ins.Ebtesam AL-Etowi
13
conclusion This shows a good way to learn assembly language. Enter and assemble instructions; this will show you the machine code that is produced. Then, step through execution so you can see the effects of the individual instructions. Ins.Ebtesam AL-Etowi
14
exercise to perform the calculation: f = (g + h) - (i + j) g= 5 h= -20
Ins.Ebtesam AL-Etowi
15
Ins.Ebtesam AL-Etowi
16
H.W for absent You are given the following two numbers in two’s complement representation. Perform the binary addition and subtraction. Did signed overflow occur? determined whether or not overflow occurred. Ins.Ebtesam AL-Etowi
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.