CS334: Memory _ Mars simulator Lab 4(part2-2)

Slides:



Advertisements
Similar presentations
CENG 311 Decisions in C/Assembly Language
Advertisements

Goal: Write Programs in Assembly
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Lecture 5: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
The 8051 Microcontroller and Embedded Systems
MIPS processor continued. Review Different parts in the processor should be connected appropriately to be able to carry out the functions. Connections.
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
MIPS Instruction Set Advantages
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 1 In-Class Lab Session (Lab 2)
Registers and MAL Lecture 12. The MAL Architecture MAL is a load/store architecture. MAL supports only those addressing modes supported by the MIPS RISC.
Lecture 15 Today’s lecture MARIE programming Assembler
CSCI 136 Lab 1: 135 Review.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Fall EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions.
Computer Organization – Memory Access David Monismith Jan. 30, 2015 Based upon notes by Dr. Bill Siever and the Patterson and Hennessy Text.
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Represents different voltage levels High: 5 Volts Low: 0 Volts At this raw level a digital computer is instructed to carry out instructions.
9/29: Lecture Topics Conditional branch instructions
MIPS coding. slt, slti slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2 ; else clear $t3 to be 0. – “Set Less Than.” slti $t3, $t1, 100 – set $t3 to be.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization Instructions Language of The Computer (MIPS) 2.
CS334: Number Systems&& Mars simulator Lab 1_2. Ins.Ebtesam AL-Etowi Quizzes/Participation/Absence 5% Logisim/MIPS Programming5% CPU Design Project10%
10/1: Lecture Topics Conditional branch instructions –slides from 9/29 set Unconditional jump instructions Instruction encoding.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 1 In-Class Lab Session (Lab 2) Answer Key.
Writing an Assembly-language program MIPS assembly language using MARS: MIPS Assembler and Runtime Simulator CS-2710 Dr. Mark L. Hornick 1.
CS 312 Computer Architecture & Organization
Deeper Assembly: Addressing, Conditions, Branching, and Loops
MIPS Instruction Set Advantages
EE 333 Exam 1 September 29, 2005 Answers Instructions Name Student ID
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
Assembly Programming using MIPS R3000 CPU
Instructions for Making Decisions
CS170 Computer Organization and Architecture I
MIPS processor continued
MIPS coding.
CSCI206 - Computer Organization & Programming
MIPS Instructions.
MIPS Instruction Encoding
MIPS Instruction Encoding
Instruction encoding The ISA defines Format = Encoding
MIPS Functions.
MIPS Coding.
SELECTIONS STATEMENTS
COMS 361 Computer Organization
Assembly Programming using MIPS R3000 CPU
MIPS Assembly.
MIPS Coding Continued.
MIPS coding.
CS334: Number Systems Lab 1.
MIPS assembly.
CS/COE0447 Computer Organization & Assembly Language
CS334: MIPS language _Mars simulator Lab 2_1
Lab4 PROGRAMMING 1 exercise chapter3.
Binary Lesson 7 Review of Binary and Hexadecimal
CS 286 Computer Architecture & Organization
Computer Architecture and System Programming Laboratory
MIPS instructions.
CS 111 – Sept. 16 Machine language examples Instruction execution
PROF. JOHN ABRAHAM UTRGV
Conditional Branching (beq)
MIPS Assembly.
Presentation transcript:

CS334: Memory _ Mars simulator Lab 4(part2-2)

Control Structures in mips. Load / Store Instructions Add in hex. Contents: Control Structures in mips. Load / Store Instructions Add in hex. Part2:memory. Exercise. Questions. Ins.Ebtesam AL-Etowi

Control Structures Branches comparison for conditional branches is built into instruction. Jump to lable(target) if condition true else continue Ins.Ebtesam AL-Etowi

Cont……. Jumps j target # unconditional jump to program label target Ins.Ebtesam AL-Etowi

Ins.Ebtesam AL-Etowi

Load / Store Instructions RAM access only allowed with load and store instructions . all other instructions use register operands load: lw register_destination, RAM_source #copy word (4 bytes) at source RAM location to destination register. store word: sw register_source, RAM_destination #store word in source register into RAM destination Ins.Ebtesam AL-Etowi

Cont ….. load immediate li register_destination, value example: #load immediate value into destination register example: lw $t0, var1 # load contents of RAM location into register $t0: $t0 = var1 li $t1, 5 # $t1 = 5 ("load immediate") sw $t1, var1 # store contents of register $t1 into RAM: var1 = $t1 Ins.Ebtesam AL-Etowi

Add hex digit 3A49 + 4BA9 -------- 85F2 Before working with memory, you need to be able to add hex digits. Here is an example of adding 2 hex digits: 3A49 + 4BA9 -------- 85F2 Ins.Ebtesam AL-Etowi

Add hex digit 8* 16^3 + 5 * 16^2 + F * 16^1 + 2* 16^0 = 34290 Note that numbers without the 0x are decimal: Digit 0: 0x9 + 0x9 = 9 + 9 = 18 = 0x12 (1 * 16^1 + 2 * 16^0). So, write down the 2 and carry the 1. Digit 1: 1 (carry) + 0x4 + 0xA = 1 + 4 + 10 = 15 = 0xF. So, write down the F. There is no carry. Digit 2: 0xA + 0xB = 10 + 11 = 21 = 0x15 (1*16^1 + 5 * 16^0). So, write down the 5 and carry the 1. Digit 3: 1 (carry) + 0x3 + 0x4 = 1 + 3 + 4 = 8 = 0x8. So, write down the 8. 8* 16^3 + 5 * 16^2 + F * 16^1 + 2* 16^0 = 34290 34290=0x 85F2 Ins.Ebtesam AL-Etowi

Ins.Ebtesam AL-Etowi

Part 2: memory Now, let's look at memory. Start by entering the following into the simulator: .data A: .word 25, 3, 0x44, 0x33, 0x25, 0x3, 16, 0x22, 44, 33, 22 Ins.Ebtesam AL-Etowi

Ins.Ebtesam AL-Etowi Words Hex Value (show the correct number of digits! 8 hex digits = 32 bits = 1 word) 25 3 0x44 0x33 0x25 0x3 16 0x22 44 33 22 Ins.Ebtesam AL-Etowi

Cont…. ".data" is an assembler directive (instruction to the assembler) that tells the assembler we are in the data segment of memory. ".word" is an assembler directive that tells the assembler to store the following into subsequent words in memory. The 0x values are in hex. The other values are in decimal. The data segment of memory begins at address 0x10010000 Ins.Ebtesam AL-Etowi

Cont..)) Questions Question 8:Now that you understand what you are looking at, fill out the above table (if you have already filled out that table, then you are done!) (show the correct number of digits! 8 hex digits = 32 bits = 1 word) Ins.Ebtesam AL-Etowi

Cont….. 25 0x00000019 3 0x00000003 0x44 0x00000044 0x33 0x00000033 0x25 0x00000025 0x3 0x00000003 16 0x00000010 0x22 0x00000022 44 0x0000002C 33 0x00000021 22 0x00000016 Ins.Ebtesam AL-Etowi

Questions Question 9: 2A8E + CBF3 -------- ???? Answer: F681 Question 10: : Does each box shown in the data segment window represent a byte or a word? Please explain. Answer: A word. It packs four bytes into a word and shows it on each of the boxes. Ins.Ebtesam AL-Etowi

exercise to perform the following: If (n1>n2) n2= 0x5 true Else Add it n1+n2 true in .data n1 =8 n2 =11 Ins.Ebtesam AL-Etowi

Exercise if the condition false Ins.Ebtesam AL-Etowi

Execute Ins.Ebtesam AL-Etowi

Exercise if the condition true Ins.Ebtesam AL-Etowi

Ins.Ebtesam AL-Etowi

? ? ? Ins.Ebtesam AL-Etowi