Fall 2006 1 EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.

Slides:



Advertisements
Similar presentations
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
Advertisements

1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
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.
Branches Two branch instructions:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 2: IT Students.
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
ECE 232 L6.Assemb.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 6 MIPS Assembly.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
Statement Format MIPS assembly language statements have the following format label: opcode operand,operand,operand # comment Label identifies the statement.
ELEN 468 Advanced Logic Design
SPIM and MIPS programming
1 Computer Architecture MIPS Simulator and Assembly language.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Fall 2003SYCS-401 Operating Systems Instruction Set Architecture An overview of MIPS R3000 assembly language.
Computer Science 210 Computer Organization The Instruction Execution Cycle.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
IT253: Computer Organization Lecture 5: Assembly Language and an Introduction to MIPS Tonga Institute of Higher Education.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
1 Compilers Modern Compiler Design Supplementary Note 2 SPIM Overview NCYU C. H. Wang.
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.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Fall EE 333 Lillevik 333f06-l5 University of Portland School of Engineering Computer Organization Lecture 5 MIPS Instructions Loops Machine Instructions.
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
The Assembly Process Computer Organization and Assembly Language: Module 10.
MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Lecture 3 Translation.
Assembly language.
ACOE301: Computer Architecture II Labs
ELEN 468 Advanced Logic Design
MIPS assembly syntax Comments
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Computer Science 210 Computer Organization
Assembly Programming using MIPS R3000 CPU
Instructions - Type and Format
Computer Science 210 Computer Organization
Lecture 4: MIPS Instruction Set
MPIS Instructions Functionalities of instructions Instruction format
The University of Adelaide, School of Computer Science
MIPS Instruction Encoding
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
MIPS Instruction Encoding
MIPS History MIPS is a computer family
Instruction encoding The ISA defines Format = Encoding
MIPS History MIPS is a computer family
Computer Instructions
Instruction encoding The ISA defines Format = Encoding
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
Instruction encoding The ISA defines Format = Encoding
Assembly Programming using MIPS R3000 CPU
Instruction encoding The ISA defines Format = Encoding
MIPS History MIPS is a computer family
MIPS e pipelining Tecniche di base.
MIPS Coding Continued.
CS352H Computer Systems Architecture
Generalities for Assembly Language
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and memory instructions

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering MIPS: Programmers View Memory Registers ALU We will design a subset of this computer

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Memory Usage Program Data Stack Memory divided into three separate regions or segments

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Assembly programming Sources files are assembled, then linked This could be compiled

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Assembler Purpose: translates a program statement (source file) into an address and data (object file) Steps (2-pass) –Create a symbol table –Use symbol table to generate instruction as a binary number Execution: OS writes program into memory, transfers control, program runs, control returns to OS

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Program statement syntax Generally, free-format Comments: begin with sharp (#) # this is a comment Labels: start the beginning of a line, end with colon (:) start: loop: end:

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Memory addresses Notation: c(rx) rx = register/base c = constant/offset Examples 100($t0)# EA = $t x2f ($22)# EA = $22 + 0x 2f ($sp)# EA = $sp, c = 0

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Directives Provides assembler information Start with dot (.) Examples.text# start text segment.data# start data segment.asciiz # null terminated string.word# insert word data

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering A typical line of code label:opCode $destination, $operand1, $operand2, #comment Examples loop:li$t0, 2# initialize $t0 = 2 calc:add$t1, $t3, $t1# $t1 = $t3 + $t1 nop# do nothing mult $s2, $s3# hi:lo = $s2 x $s3

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Program Structure Labels Program Directives

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Simple Program

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Let’s run the program

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Write the program? Subtract 3 from 5 and leave in $t2

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Instruction Classes Arithmetic and logic Load Store Comparison Branch and jump Data Movement Floating Point

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Arithmetic and Logic InstructionExampleMeaning addadd $s1, $s2, $s3$s1 = $s2 + $s3 subsub $s1, $s2, $s3$s1 = $s2 - $s3 add immediateaddi $s1, $s2, 100$s1 = $s multiplymult $s2, $s3hi:lo = $s2 x $s3 dividediv $s2, $s3lo = $s2 / $s3 hi = $s2 mod $s3 Only registers used for operands

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Loads (reg  mem) InstructionExampleMeaning Load word (32 bits) lw $s1, 100 ($s2)$s1 = mem[$s ] Load byte unsigned (8 bits) lbu $s1, 100($s2)$s1 = mem[$s ] Load addressla $a0, data$a0 = address of data: Load immediateli $t4, 18$t4 = 0x 12 The point of reference is a register

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Stores (reg  mem) InstructionExampleMeaning Store word (32 bits) sw $s1, 100 ($s2)mem[$s ] = $s1 Store byte (8 bits) sb $s1, 100 ($s2)mem[$s ] = $s1 The point of reference is a register

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Accessing Memory Use the la instruction to place address in a register Use the load/from & store/to address saved in the register la$t0, var# $t0 = address of var: lw$v1, ($t0)# $v1 = var sw $s0, 4($t0) # mem[var + 4] = $s0

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Write the program? NOTE: data movement, mflo $reg

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Write the program? Subtract 3 from 5 and leave in $t2

Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Write the program?