True Assembly Language Part I. The Assembly Process The process of translating a MAL code (an assembly language program) into machine code (a sequence.

Slides:



Advertisements
Similar presentations
Goal: Write Programs in Assembly
Advertisements

Integer Arithmetic: Multiply, Divide, and Bitwise Operations
Branches Two branch instructions:
Statement Format MIPS assembly language statements have the following format label: opcode operand,operand,operand # comment Label identifies the statement.
CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
The Assembly Process Basically how does it all work.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
MIPS Assembler Programming
Integer Multiplication and Division
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
1 CS 430 Computer Architecture Clap if you like pizza! Pointless Poll.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
MIPS on FLEET Amir Kamil. Goals Run most MIPS assembly code on FLEET  Attempt to duplicate level of support in SPIM interpreter  MIPS assembly translated.
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.
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.
CSCI 136 Lab 1: 135 Review.
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Integer Multiplication and Division
Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 21 Today’s class More assembly language programming.
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
CENG 311 Instruction Representation
EI 209 Chapter 3.1CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 3: Arithmetic for Computers Haojin Zhu ( )
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.
The Assembly Process Basically why does it all work.
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.
Integer Operations Computer Organization and Assembly Language: Module 5.
Pirouz Bazargan SabetDecember 2003 Effective Implementation of a 32-bit RISC Processor Pirouz Bazargan Sabet University of Paris 6 - LIP6 - ASIM
CS Computer Organization Numbers and Instructions Dr. Stephen P. Carl.
Computer Architecture & Operations I
Integer Multiplication, Division Arithmetic shift
MIPS Instruction Set Advantages
Computer Architecture & Operations I
Integer Multiplication and Division
Computer Organization and Design Instruction Sets - 2
Chapter Three : Arithmetic for Computers
CS 314 Computer Organization Fall Chapter 3: Arithmetic for Computers
Computer Organization and Design Instruction Sets - 2
Morgan Kaufmann Publishers
CDA 3101 Summer 2007 Introduction to Computer Organization
Computer Organization and Design Instruction Sets
Lecture 8: Addition, Multiplication & Division
MISP Assembly.
ECE232: Hardware Organization and Design
Instruction encoding The ISA defines Format = Encoding
Part II Instruction-Set Architecture
Flow of Control -- Conditional branch instructions
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
MIPS Assembly.
Flow of Control -- Conditional branch instructions
MIPS assembly.
CS352H Computer Systems Architecture
Generalities for Assembly Language
MIPS Arithmetic and Logic Instructions
Pointless Poll Clap if you like pizza!.
MIPS Arithmetic and Logic Instructions
7/6/
9/13/
MIPS instructions.
Conditional Branching (beq)
Presentation transcript:

True Assembly Language Part I

The Assembly Process The process of translating a MAL code (an assembly language program) into machine code (a sequence of bits) is called assembly. The program that performs the translation is called an assembler. The translation from assembly language to machine code is mechanical, repetitive, and tedious. Small errors can have disastrous results and therefore this job is better left to computers.

Sometimes, a set of instructions are repeated several times within a code. It is best to give a name to this repetitive code sequence. A macro defines a sequence of instructions by associating to it a keyword. A preprocessor can then be used to expand a macro into a series of instructions it represents. Many MAL instructions are identical to TAL. The first step in assembling a MAL program is to translate the code into TAL.

TAL - True Assembly Language MAL is not directly translatable into machine code because of several abstractions in the language. The TAL instruction set, however, defines the MIPS RISC architecture. TAL arithmetic and logical instructions generally require three-operand specifications but MAL permits two- or three-operand specifications.

Arithmetic and Logical Instructions TAL has both register and immediate addressing modes, although not all have immediate modes, e.g., there is no immediate sub instruction because it can be done by add addi R t,R s,I R t [R s ]+([I 15 ] 16 ||I ) addiu R t,R s,I R t [R s ]+([I 15 ] 16 ||I ) andi R t,R s,I R t 0 16 ||([R s ] AND I ) lui R t,I R t I ||0 16

The MAL move instruction move R t, R s is equivalent to the TAL instruction add R t,$0,R s Each of the MAL shift instructions exists in two forms in TAL sll R dest,R src1,Src2 sllv R dest,R scr1,R scr2 The first shift instruction is the same as MAL; the second one specifies a register from which the amount of shifts is obtained from. The suffix v indicate that the amount of shift is variable.

Multiplication in TAL MIPS RISC architecture contains two special registers, HI and LO, that are used to hold 64-bit results. mult R s,R t takes the contents of R s and R t as multiplicands and places the least 32-bit result into LO and the other 32-bit result into HI. mul $8,$9,$10 mult $9,$10 mflo $8 MALTAL HI must be checked for overflow move from LO

Division in TAL The TAL div instruction computes both the integer quotient and remainder, leaving the quotient in LO and the remainder in HI. rem $8,$9,$10div $9,$10 mfhi $8 MALTAL div $8,$9,$10div $9,$10 mflo $8

Unsigned arithmetic The MIPS RISC architecture provides a set of instructions that perform unsigned arithmetic via instructions that are suffixed u. These instructions never cause exceptions (error condition) even if overflow occurs. The responsibility is left to the programmer or compiler to assure that overflow never occurs when these instructions are used. adduaddiu multusubu divu

Branch Instructions Branch instructions use a signed 2 16 offset field, hence (because addresses must be multiples of 4, we can shift the 18 bit value right twice and just store a 16 bit value) can only jump addresses forward and 2 17 backward. Jump instructions can jump longer using a 26 -bit offset field. Not all MAL branch instructions are available in TAL. Only bltz, blez, bgez, blez, beq, bne, and b are available.

Subtle problems on branching blt $11,$12,next sub $10,$11,$12 bltz $10,next Subtraction may cause an overflow, e.g. if $11 contains and $12 contains then the result is which has no representation MAL TAL slt $10,$11,$12 bne $10,$0,next Sets $10 to 1 if the 2 ’s complement of the contents of $11 is less than the 2 ’s complement of the contents of $12, else it sets $10 to 0. The comparison does not cause overflow

Load Address Instruction TAL does not natively have the MAL la instruction (though la still works in TAL). The assembler determines the address bound to label and divides it into two halves. The upper half is loaded into R via lui and the lower half is or ed into R using the ori instruction. la R, labellui R, highaddress ori R, lowaddress MALTAL la $12, 0x lui $12, 0x0003 ori $12, 0x0248