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.

Slides:



Advertisements
Similar presentations
Goal: Write Programs in Assembly
Advertisements

Integer Arithmetic: Multiply, Divide, and Bitwise Operations
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
Machine Instructions Operations
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
Deeper Assembly: Addressing, Conditions, Branching, and Loops
There are two types of addressing schemes:
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
1 Registers and MAL - Part I. Motivation So far there are some details that we have ignored instructions can have different formats most computers have.
Informationsteknologi Saturday, September 29, 2007 Computer Architecture I - Class 41 Today’s class More assembly language programming.
Lecture 4: Loads, Logic, Loops. Review Memory is byte-addressable, but lw and sw access one word at a time. These instructions transfer the contents of.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
Logical & shift ops (1) Fall 2007 Lecture 05: Logical Operations.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
More decisions and logic (1) Fall 2010 Lecture 4: Loads, Logic, Loops.
MIPS Instruction Set Advantages
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
Lecture 18 Last Lecture Today’s Topic Instruction formats
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.
True Assembly Language Part I. The Assembly Process The process of translating a MAL code (an assembly language program) into machine code (a sequence.
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 CS224 Fall 2012 Lessons 7 and 8.
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
Computer Organization Instructions Language of The Computer (MIPS) 2.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Yaohang Li.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS 312 Computer Architecture & Organization
MIPS Instruction Set Advantages
MIPS Coding Continued.
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
MPIS Instructions Functionalities of instructions Instruction format
MISP Assembly.
The University of Adelaide, School of Computer Science
Computer Architecture & Operations I
ECE232: Hardware Organization and Design
Instruction encoding The ISA defines Format = Encoding
Review.
ECEG-3202 Computer Architecture and Organization
Introduction to Micro Controllers & Embedded System Design
MIPS Assembly.
COMS 361 Computer Organization
Computer Instructions
ECEG-3202 Computer Architecture and Organization
3.
Instruction encoding The ISA defines Format = Encoding
COMS 361 Computer Organization
Instruction encoding The ISA defines Format = Encoding
COMS 361 Computer Organization
MIPS Assembly.
Instruction encoding The ISA defines Format = Encoding
MIPS assembly.
Generalities for Assembly Language
9/27: Lecture Topics Memory Data transfer instructions
CS 286 Computer Architecture & Organization
MIPS instructions.
MIPS Assembly.
Presentation transcript:

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 assembler. SAL is both a memory-to-memory architecture and load/store architecture. SAL does not have indirect addressing mode.

The MAL architecture has two distinct register files: 32 general registers and 16 floating point registers SAL is implemented by synthesizing its instructions from a sequence of MAL instructions. lw $8,x lw $9,y add $10,$8,$9 sw $10,z add z,x,y SAL MAL

General Registers Numbered $0 to $31 Not all registers are used for programming $0 always contains zero; $0 may be specified as destination but any value calculated is lost $1 is used by the assembler $2, $4 are used for syscalls $26 and $27 are used by the operating system $28,$29, and $31are used in procedures

Floating Point Registers Floating point operands can be either single- precision(32 bits) or double-precision(64 bits) MAL floating point registers are 64 bits long Each register is two words long (two 32-bit words) The words are numbered 0 to 31. Each pair (e.g., word 0 and word 1) represents one floating point register Floating point register are numbered $f0,$f2,$f4,…,$f30 Only the even-numbered registers are used for single- precision representation

MAL Load and Store Instructions lw R, address R is the register. In its most general form the address can include both a constant (which can be a label) and a base register. For example, lw $22, 12($25) The effective address is computed by adding 12 to the contents of the base register $25. Note that ($25) means the contents of register 25. The word at the effective address is loaded into register 22. Make sure that the effective address is a multiple of 4.

The immediate addressing mode is supported by li R, constant The constant operand is loaded into register R. A variant of li is the load address instruction. la R, label In the above instruction, the address bound to label is loaded into register R. la $8, var_name lw $8,($8) lw $8, var_name equivalent

Example 14.1 We can access an element of an array ar of integers in the following manner: la $8, ar add $8,$8,20 #offset is 5 words lw $8,($8)

Data can be copied from the register R to the memory location specified by address sw R, address Similar to the load instruction the address can include both a constant and a base register specification. sw, $13, 4($9) The effective address is computed by adding 4 to the contents of register 9.

The sb is equivalent to the store word instruction, sw, only that it stores 1 byte instead of 4 bytes to the effective address. Only the least significant byte of the register is used. The lb and lbu instructions load the byte into the least significant byte of the register. lbu loads the byte as unsigned, i.e. the other three bytes in the register are set to 0 lb sign-extends the byte -- the other three bytes are set to whatever the sign of the byte is.

Arithmetic and Logical Instructions Arithmetic and logical instructions come in the following format: instruction_mnemonic D,S 1,S 2 where D is the destination register and registers S 1 and S 2 specify the source of operands If source register S 1 is not specified, it is implied to be the same as D S 2 must be present; it can either be a register or a constant

Example 14.2 add$9,$8,0xabcd #S 1 is $8, S 2 is 0xabcd mul$9,0xabcd# S 1 the same as D = $9 mul $9,$9,0xabcd sub $5,$21,16 and $4,$8,1

move instruction The move instruction is restricted to register operands move $4, $8 move $6, $0 # $0 is always zero

Shift Instructions There are three shift instructions: sll, srl, sra These instructions are the same as the SAL instructions only that registers are specified as source and destination The amount of shift can either be specified as a constant or as contents to the register. In this case the least 5 (note that log 2 32 = 5)significant bits are interpreted as unsigned integer

Example 14.3 Sll $8, $9, 5 The contents of register 9 is shifted to the left 5 times and the result is placed into register 8

Floating Point Instructions To load a single-precision number use l.s F, address where F specifies one of the 32 words making up the 16 floating point registers and from an address in memory It takes two load instructions to load a double-precision floating point register The register specified as address is a general-purpose register

To store floating point use s.s F, address where address like the load instruction is a multiple of four There are no byte operations for floating point registers The following loads an immediate single- precision floating point operand li.s $f6, 1.0

The move instruction mov.s $f4,$f0 copies value from $f0 to $f4 The register $f0 does not necessarily have a value of zero, unlike the general- purpose registers Other instructions: add.s, sub.s, mul.s, and div.s Double-precision operations can be specified by using the suffix.d instead of.s

I/O instructions A conversion is necessary if the type to be displayed or input is either.word or.float getc R where R is a general register putc R puts S where S can either be a general register or a label

Example 14.4.data ar:.word 0:50 # $8 - flag, 1 algorithm is done # 0 another iteration needed # $9 - offset to the correct element # $10 - address of element to compare # $11 - array element for comparison # $12 - neighbor of element in $11 # $14 - base address of array ar

21... la $14,ar loop: li $8,1 li $9,0 #offset for: add $10,$14,$9 lw $11,($10) lw $12,4($10) sub $13,$11,$12 blez $13,noswap li $8,0 #another iteration needed sw $11,4($10) sw $12,($10) noswap:add $9,$9,4 sub $13,$9,196 #check if end is reached bltz $13,for #check end of one iteration beq $8,$0,loop #$8 is 0 if a swap was done done