Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 21 Today’s class More assembly language programming.

Slides:



Advertisements
Similar presentations
Goal: Write Programs in Assembly
Advertisements

Integer Arithmetic: Multiply, Divide, and Bitwise Operations
Deeper Assembly: Addressing, Conditions, Branching, and Loops
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
Statement Format MIPS assembly language statements have the following format label: opcode operand,operand,operand # comment Label identifies the statement.
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
Assembly Language Working with the CPU.
Informationsteknologi Saturday, September 29, 2007 Computer Architecture I - Class 41 Today’s class More assembly language programming.
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
1 CS 430 Computer Architecture Clap if you like pizza! Pointless Poll.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
1 CS 430 Computer Architecture Clap if you like pizza! Pointless Poll.
Fall 2003SYCS-401 Operating Systems Instruction Set Architecture An overview of MIPS R3000 assembly language.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
ECE 232 L5 Assembl.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 5 MIPS Assembly.
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
Arithmetic for Computers
IT253: Computer Organization Lecture 5: Assembly Language and an Introduction to MIPS Tonga Institute of Higher Education.
Computer Organization and Design Instruction Sets Montek Singh Wed, Sep 12, 2012 Lecture 5.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
In Class Execise. .data A:.word 0,1,2,3,4,5,6,7,8,9.text.globl main main: la $a0,A li $a1,6 li $a2,5 jal onUpStream done: li $v0, 10# exit syscall onUpStream:
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.
Procedure (Method) Calls Ellen Spertus MCS 111 September 25, 2003.
True Assembly Language Part I. The Assembly Process The process of translating a MAL code (an assembly language program) into machine code (a sequence.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Computer Organization Instructions Language of The Computer (MIPS) 2.
CENG 311 Instruction Representation
1 CS61C L6 Machine Rep CENG 311 Procedure Conventions & The Stack.
MIPS Assembly Language Chapter 13 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu Arithmetic.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
MIPS Assembly Language Chapter 15 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer, 2003.
CDA 3101 Spring 2016 Introduction to Computer Organization
The Assembly Process Computer Organization and Assembly Language: Module 10.
COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD.
CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats 1 Instructors: Vladimir Stojanovic and Nicholas Weaver
CS 312 Computer Architecture & Organization
Integer Multiplication, Division Arithmetic shift
System Calls & Arithmetic
CSCI206 - Computer Organization & Programming
Integer Multiplication and Division
Computer Organization and Design Instruction Sets - 2
Chapter Three : Arithmetic for Computers
Lecture 4: MIPS Instruction Set
Computer Organization and Design Instruction Sets - 2
CDA 3101 Summer 2007 Introduction to Computer Organization
Computer Organization and Design Instruction Sets
CSCI206 - Computer Organization & Programming
Instructions - Type and Format
Appendix A Classifying Instruction Set Architecture
MPIS Instructions Functionalities of instructions Instruction format
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
Instruction encoding The ISA defines Format = Encoding
MIPS Assembly.
Flow of Control -- Conditional branch instructions
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
MIPS Assembly.
Flow of Control -- Conditional branch instructions
MIPS e pipelining Tecniche di base.
CS352H Computer Systems Architecture
Generalities for Assembly Language
MIPS Arithmetic and Logic Instructions
Pointless Poll Clap if you like pizza!.
9/27: Lecture Topics Memory Data transfer instructions
MIPS Arithmetic and Logic Instructions
7/6/
CS 286 Computer Architecture & Organization
9/13/
Presentation transcript:

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 21 Today’s class More assembly language programming

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 22 Data transfer instructions lw – load word from memory into a register (note that the address must be a word address, divisible by 4) lb – load byte sw – store word into memory from a register (address must be for a word) sb – store byte

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 23 Addition (signed) add reg dest,reg src1,reg src2  Performs reg dest = reg src1 + reg src2  Uses register addressing (no memory reference) addi reg dest,reg src,const  Performs reg dest = reg src + const  Add immediate, because const is part of instruction (no memory reference) add reg dest,reg src,const  Will generate an addi instruction by the assembler add reg dest, const  Will generate addi reg dest,reg dest,const

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 24 Addition (unsigned) addu reg dest,reg src1,reg src2  Performs reg dest = reg src1 + reg src2 addiu reg dest,reg src,const  Performs reg dest = reg src + const addu reg dest,reg src,const  Will generate an addiu instruction by the assembler addu reg dest, const  Will generate addiu reg dest,reg dest,const

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 25 Subtraction sub reg dest,reg src1,reg src2  Performs reg dest = reg src1 - reg src2  This is a signed subtraction subu reg dest,reg src1,reg src2  Performs reg dest = reg src1 - reg src2  This is an unsigned subtraction No subi instruction  Can do an addi with the negative of what you want to subtract

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 26 Multiplication Result of multiplying two 32-bit numbers can be 64 bits big Have two special registers called lo and hi to hold the two 32-bit parts of the result mult reg src1,reg src2 will put the low 32 bits of the product in lo and the high 32 bits in hi Use mflo reg dest (move from lo ) to get the low 32 bits into a register Use mfhi reg dest (move from hi ) to get the high 32 bits into a register The pseudo-instruction mul reg dest,reg src1,reg src2 will get the low 32 bits of the product into reg dest

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 27 Division div reg src1,reg src2 will put the integer quotient of reg src1 /reg src2 in lo and the remainder in hi The pseudo-instruction div reg dest,reg src1,reg src2 will get the integer quotient into reg dest

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 28 Example program Program temperature.asm converts Celsius temperatures to Fahrenheit Study it and demo itdemo

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 29 In-class exercise Modify the temperature conversion program so it converts from Fahrenheit to Celsius instead.

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 210 Unconditional branching j addr – jumps to the indicated address and continues execution from there jr reg – jumps to the address stored in the specified register and continues execution from there

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 211 Conditional branching beq reg src1,reg src2,addr – branch to addr if reg src1 equals reg src2 beqz reg,addr – branch to addr if reg equals 0 bne reg src1,reg src2,addr – branch to addr if reg src1 does not equal reg src2 blt reg src1,reg src2,addr – branch to addr if reg src1 is less than reg src2 The assembler will let the second operand be a constant instead of a register if desired There are many more – see Appendix B (page 146) of Waldron

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 212 Example programs Program length.asm prints out the length of a character string Program replace.asm replaces lower case ‘a’ with upper case ‘A’ in a string Study them and demo themdemo

Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 213 In-class exercise Write a program to count how many times the letter ‘e’ appears in a string.