Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.

Slides:



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

MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
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.
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.
ECE 0142 Recitation #5.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Chapter 6 In introduction to System Software and Virtual Machine ***Assembly Language.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
SPIM : A MIPS Simulator Archi & Net Lab 이용석
Fall 2003SYCS-401 Operating Systems Instruction Set Architecture An overview of MIPS R3000 assembly language.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
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.
Intro. to Game Programming Want to program a game?
Computer Platforms Week 4: Assembly Language & Operating Systems.
Comp Sci vars & expns 1 Ch. 4 Variables and Expressions.
Procedure Basics Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Procedure Support From previous study of high-level languages,
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
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.
Strings in MIPS. Chapter 2 — Instructions: Language of the Computer — 2 Character Data Byte-encoded character sets – ASCII: 128 characters 95 graphic,
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
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.
MIPS coding. slt, slti slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2 ; else clear $t3 to be 0. – “Set Less Than.” slti $t3, $t1, 100 – set $t3 to be.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
CS 312 Computer Architecture & Organization
Lecture 3 Translation.
System Calls & Arithmetic
Computer Architecture & Operations I
Assembly language.
MIPS Assembly Language Programming
MIPS Instruction Set Advantages
Introduction to Lab #1 José Nelson Amaral.
MIPS I/O and Interrupt.
Instruction Set Architecture
MIPS Coding Continued.
ACOE301: Computer Architecture II Labs
MIPS assembly syntax Comments
MIPS I/O and Interrupt.
Topic 2e High-Level languages and Systems Software
MIPS coding.
Instructions - Type and Format
Ken D. Nguyen Department of Computer Science Georgia State University
Assembler Directives Example program: .data # DATA segment city: .asciiz “Seattle” .align 2 num: .word 2210, 2341, 26, 0x022ec,
MIPS Functions.
MIPS coding.
MIPS function continued
COMS 361 Computer Organization
MIPS I/O and Interrupt.
COMS 361 Computer Organization
MIPS Coding Continued.
MIPS coding.
Where is all the knowledge we lost with information? T. S. Eliot
Generalities for Assembly Language
Ken D. Nguyen Department of Computer Science Georgia State University
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.
PROF. JOHN ABRAHAM UTRGV
Presentation transcript:

Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell

MIPs Assembler Like most High Level Languages, assembly uses much of the same practices. Enter text as Assembly Code Assemble the code producing machine code Run the machine code.

Basic program format data text Variables are declared here Code goes here

Basic Program #This is where variable definitions go .data theSolution: .word 42 #in decimal #This is where code goes .text Main: lw $t0,theSolution #load value stored at address addi $t0,$t0, 3 #add 3 onto 42 move $a0, $t0 #output our value li $v0, 1 syscall li $v0, 10 # Systemcall code exit

Basic Program All labels are denoted as: someVariableName: All of these can be viewed as memory addresses. These are sometimes referred to as symbolic addresses The Assembler will use these to: Reference memory location Control program flow

BIOS functions Basic Input Output System All cpu architectures have one, just the name may be different. X86 it is called the BIOS Recall your PC has a BIOS MIPs refers to it as the firmware routines BIOS routines are drivers located in the firmware which interface the OS to the hardware. The OS has access to these, but are protected from user programs. User software can access these OS routines which access the firmware by making system calls to the OS.

OS Kernel Figure to the right shows a typical system. The kernel is viewed as the green and purple sections. To get to any functionality you must go through protected system calls

Typical BIOS routine example User programs will load specific registers with output data. Issue a syscall. OS determines what type of syscall, and processes the data accordingly. When complete, control returns to the user program.

Sys Calls MIPs has 17 standard system calls.

Load and Store Word 40% of all instructions will load and store data to/from the registers. Lw $t0, some_label Get the contents of memory address “some_label” and place it into register $t0. At times it may be convenient to have the data address in the register Lw $t0, ($t1) ($t1) indicates that the contents of $t1 is an address and should be treated as such. This implies that addresses can be contained in registers and are thus susceptible to arithmetic operations. This allows for dynamic addressing control. Store instructions will work the same way Sw $t0, some_label -- in this case the contents of $t0 is placed into memory at some_label Sw $t0, ($t1) - has a similar effect.

Hello World Strings can be defined as being null terminated or not. .asciiz is null terminated. La $a0, msg will load the base address of msg into $a0 for the syscall Syscall will output the entire message upto the null character at the end of the string.

Hello World!. Stored in memory as a series of bytes. Note the low byte of each word is on the right. Null terminator is a 0. String terminator.

Hello World! Note what happens when we remove the terminator from the first string.

Byte Addressable Memory MIPs uses byte addressable memory. Each address refers to a unique byte in memory. Words are collections of 4 bytes, and reside on addresses exactly divisible by 4. First 3 lines can be reduced to: lb $t1, msg + 4

Simple Arithmetic Variables x and y are defined and given 4 bytes of space in memory. Result is placed in x which appears first in the .data section, see below.

End