Catch up on previous topics Summary and putting together first four classes.

Slides:



Advertisements
Similar presentations
Integer Arithmetic: Multiply, Divide, and Bitwise Operations
Advertisements

Lecture 5: MIPS Instruction Set
CS/COE0447 Computer Organization & Assembly Language
Branches Two branch instructions:
CDA 3100 Recitation Week 8. Question 1.data A:.word 21,3,2,9,100,22,6,15,33,90.text.globl main main: la $a0, A li $a1, 17 li $a2, 10 jal funct li $v0,
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Statement Format MIPS assembly language statements have the following format label: opcode operand,operand,operand # comment Label identifies the statement.
SPIM and MIPS programming
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Function Continued
MIPS Assembly Language Programming
Ch. 8 Functions.
1 Computer Architecture MIPS Simulator and Assembly language.
Assembly Language Working with the CPU.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop Experience: – The main loop usually has to deal with many.
ECE 0142 Recitation #5.
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.
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
Computer Architecture CPSC 321 E. J. Kim. Overview Logical Instructions Shifts.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Instruction Representation II (1) Fall 2005 Lecture 10: Instruction Representation II.
MIPS Instruction Set Advantages
Computer Organization - Syscalls David Monismith Jan. 28, 2015 Based on notes from Patterson and Hennessy Text and from Dr. Bill Siever.
Simple Procedure Calls jal: performs the control transfer (unconditional jump) to the starting address of procedure, while also saving the return.
1 Branches and Procedure Calls Lecture 14 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Ch2b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Thanks for all the Memory! When 32 registers just won’t do. Many times (almost.
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture Instructions: Part the Last.
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
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.
Lecture 161 Lets examine a SPIM program in detail. io.asm This program is a simple routine which demonstrates input/output using assembly code. SPIM.
Computer Organization Instructions Language of The Computer (MIPS) 2.
MIPS Assembly Language Chapter 13 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Erik Jonsson School of Engineering and Computer Science FEARLESS Engineeringwww.utdallas.edu/~pervin EE/CE 2310 – HON/002 Introduction to Digital Systems.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
Integers/Characters Input/Output Integers and Characters Input/Output System Calls. syscall Trap Handler Services for Integers and Characters Read Integer,
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.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
File I/O. I/O Flags Flags are passed to give some information about how the file is to be used. – Read only file – flag=0x0 – Write only file – flag=0x1.
CS 312 Computer Architecture & Organization
System Calls & Arithmetic
MIPS Assembly Language Programming
MIPS Instruction Set Advantages
Integers/Characters Input/Output
Lecture 4: MIPS Instruction Set
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Lecture 4: MIPS Instruction Set
MPIS Instructions Functionalities of instructions Instruction format
MISP Assembly.
MIPS Functions.
MIPS Instructions.
Instruction encoding The ISA defines Format = Encoding
MIPS function continued
MIPS Assembly.
MIPS assembly.
Generalities for Assembly Language
MIPS Assembly Language Programming Computer Architecture
CS 286 Computer Architecture & Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Introduction to SPIM Simulator
MIPS instructions.
PROF. JOHN ABRAHAM UTRGV
Conditional Branching (beq)
Presentation transcript:

Catch up on previous topics Summary and putting together first four classes

SYSTEM I/O Uses the SYSCALL command: The SYSCALL can do many different operations. Each operation is given a number. The syscall expects to find the operation number in register $v0. Arguments being sent are in $a0 and maybe $a1.

Syscall Table Description operation code (in $v0) values passed Print an integer1Integer printed is in $a0 Print a string4Address of a null termintated string in $a0 Read an integer5Integer returned in $v0 Read a string8Address of buffer in $a0, max length in $a1 Terminate10No arguments

Read/Write Example.data p:.asciiz “Input now” r:.asciiz “answer”.txt main:la $a0,p li $v0,4 #prompt syscall li $v0,5 #input syscall addi $a0,$v0,100 li $v0,1 syscall li $v0,10 syscall

Strings There are two kinds, ASCII and ASCIIZ Recall from C++ that strings were implemented as an array of characters with a null (\0=0) terminator. A variable initialized as.ASCIIZ will have the null terminator (\0) at the end of the string..ASCII will not have the null terminator. The syscall print string expects to see a null.

.data hello_msg:.ascii "Hello" # The word "Hello".ascii " " # the space..ascii "World" # The word "World".ascii "\n" # A newline..byte 0 # a 0 byte. IS EQUIVALENT TO: hello_msg:.asciiz “Hello World\n”

Various commands la - load the address of a variable. (very, very different from lw. li – loads the immediate argument into a register. Because of the instruction format, the value must fit into 16 bits lui – loads the upper 16 bits of a register with the 16 bits in the immediate field. Sets lower 16 bits to 0 ori – logical or of a register with a 16 bit immediate operand.

Jump Much like the b statement for unconditional branch (which means you cannot use b as a variable name), there is an unconditional jump. Note: b is really a macro command that gets translated into: bgez $0, label Jump is just: j label. Branch statements can only branch 2 15 statements away. Jump can jump to anywhere on the same 2 26 instruction group. (more later).

Shift srl sra sll