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

Slides:



Advertisements
Similar presentations
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
Advertisements

1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
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
Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
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.
Lecture 8: MIPS Instruction Set
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Chapter 6 In introduction to System Software and Virtual Machine ***Assembly Language.
RISC Concepts, MIPS ISA and the Mini–MIPS project
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?
MIPS coding. SPIM Some links can be found such as:
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
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,
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 3 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
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.
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.
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.
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.
Chapter 1 Getting Acquainted With Computers, Programs, and C++
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.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
CS 312 Computer Architecture & Organization
Lecture 3 Translation.
Computer Architecture & Operations I
Assembly language.
MIPS Assembly Language Programming
Lecture 6: Assembly Programs
Chapter 1: Introduction to computers and C++ Programming
MIPS Instruction Set Advantages
Instruction Set Architecture
MIPS Coding Continued.
ACOE301: Computer Architecture II Labs
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Topic 2e High-Level languages and Systems Software
MIPS coding.
Instructions - Type and Format
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Assembler Directives Example program: .data # DATA segment city: .asciiz “Seattle” .align 2 num: .word 2210, 2341, 26, 0x022ec,
MIPS Functions.
MIPS Instruction Encoding
MIPS coding.
MIPS Instruction Encoding
MIPS function continued
COMS 361 Computer Organization
Lecture 6: Assembly Programs
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
Program Assembly.
9/27: Lecture Topics Memory Data transfer instructions
CS 286 Computer Architecture & Organization
PROF. JOHN ABRAHAM UTRGV
Presentation transcript:

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

MIPs Assembler Most C++ compilers use a four step process to compile programs. The preprocessor copies the contents of the included header files into the source code and replaces the #define constants. The source code is compiled into assembly language. The assembly language code is assembled into machine code. The machine code is linked to machine code files for library functions to produce the executable file. The assembly language process performs steps 3 and 4 only. Enter text as Assembly Code Assemble and link 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 locations Control program flow using jumps and branches

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 routines, but they are protected from user programs. User software can access these firmware routines indirectly by making system calls (syscall) 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