Computer Organization - Syscalls David Monismith Jan. 28, 2015 Based on notes from Patterson and Hennessy Text and from Dr. Bill Siever.

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

Lecture 5: MIPS Instruction Set
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
I/O: SPARC Assembly Department of Computer Science Georgia State University Georgia State University Updated Spring 2014.
SPIM and MIPS programming
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
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.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
More on Assembly CS 210 Tutorial 4. Detail of Echo program entry main.enter; import "../IMPORT/callsys.h"; block main uses CALLSYS { code { public enter:
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.
Lecture 2 Introduction to C Programming
Introduction to C Programming
VBA Modules, Functions, Variables, and Constants
Fall 2003SYCS-401 Operating Systems Instruction Set Architecture An overview of MIPS R3000 assembly language.
INTRODUCTION TO IBM PC ASSEMBLY LANGUAGE
MIPS coding. SPIM Some links can be found such as:
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 3 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Lecture 4: MIPS Instruction Set
Computer Organization – Memory Access David Monismith Jan. 30, 2015 Based upon notes by Dr. Bill Siever and the Patterson and Hennessy Text.
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,
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 CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
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 CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
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.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
Characters and Strings
MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
CS 312 Computer Architecture & Organization
Computer Organization Exam Review CS345 David Monismith.
Lecture 3 Translation.
System Calls & Arithmetic
Introduction to Lab #1 José Nelson Amaral.
Lecture 4: MIPS Instruction Set
MIPS assembly syntax Comments
MIPS coding.
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Ken D. Nguyen Department of Computer Science Georgia State University
MIPS coding.
Keith Carolus and Dr. Alphonce
MIPS function continued
MIPS coding.
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.
Introduction to SPIM Simulator
Some Assembly
Presentation transcript:

Computer Organization - Syscalls David Monismith Jan. 28, 2015 Based on notes from Patterson and Hennessy Text and from Dr. Bill Siever

Last Time MIPS registers MIPS mathematics instructions A start on memory and hexadecimal numbers

This Time We will continue with memory soon, but first, we will look at system calls for printing data. As an in class exercise, download MARS if you haven't done so yet. Copy and paste the HelloWorld.asm file from the class website into the MARS editor.

A.asm program #Program: Hello, World!.data #data declaration section Greeting:.asciiz "\nHello, World!\n".text #start of code section main: #execution begins with the label "main" li $v0, 4 #system call code for printing string = 4 la $a0, Greeting # load address of string to be printed # into $a0 syscall # call operating system to perform # operation # v0 specifies the system function called # syscall takes $v0 (and opt arguments) li $v0, 10#system call code for exit syscall

.data Section.data is where data stored in memory will be declared. The memory for this data is statically allocated. That is, it is allocated before the program runs. We use labels to refer to sections of memory. Labels consist of a name followed by a colon. We can allocate a string by using a directive..asciiz is a directive that tells the assembler we would like a string. The z in.asciiz refers to the fact that strings must be NULL terminated. They must end in a NULL or '\0' character. Strings are denoted after a directive using double quotes. Syntax –Label_name:.directive data_to_be_allocated

.text Section.text is where your instructions are written Programs always start with the main: label Procedures may be denoted with other names such as my_procedure: Instructions follow each label. The program is terminated using a system call with the code 10. Notice that there are two types of instructions used in the Hello, world program.

Load Instructions li -> load immediate Immediately load a fixed value such as a constant integer into a register Example: –li $t3, 8 – Loads the integer 8 into $t3 – Note that $v0 is a special register. In this case it is used to specify a system call code.

Load Instructions la -> load address Load the address of a memory location into a register Example –la $a0, Greetings – Loads the address represented by the label Greetings into the argument register $a0 Syntax –la destination_register, an_address – Note that an_address may be a label. – Such labels may refer to strings, arrays, or variables stored in memory.

System Calls These are used to request a system service such as input, output, or program termination. A value must be loaded into $v0 to specify the type of system call. Sometimes system calls have arguments. Arguments are often (but not always) loaded into $a0, an argument register.

System Call Syntax Syntax li $v0, A_NUMBER #note that A_NUMBER must be a #numerical value #load any arguments here syscall

Hexadecimal Numbers Recall that memory is addressed in binary (32 or 64-bit) If we use base 16 or hexadecimal numbers, these values can be represented in a more compact manner > > > A (10 decimal) 1011-> B (11 decimal) 1100-> C (12 decimal) 1101-> D (13 decimal) 1110-> E (14 decimal) 1111-> F (15 decimal) 0000-> > > > > > > > 7

Next Time Next time we will look at memory and at how exactly data is stored. One of the reasons we need to look at binary and hex values is so we can understand how data is stored in memory. In particular, we will look at arrays.