Integers/Characters Input/Output Integers and Characters Input/Output System Calls. syscall Trap Handler Services for Integers and Characters Read Integer,

Slides:



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

Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
SPIM and MIPS programming
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Assembly Language Programming
1 Computer Architecture MIPS Simulator and Assembly language.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Introduction to Computers and Programming Lecture 7:
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
Working with the data type: char  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
Chapter 8 Overview Programmed I/O Introduction to Interrupt Driven I/O Project 3.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#1) By Dr. Syed Noman.
1 Input/Output. 2 Principles of I/O Hardware Some typical device, network, and data base rates.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
CISC105 General Computer Science Class 1 – 6/5/2006.
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
Slide 1 Wednesday, October 07, 2015 Low Level Machine.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Input, Output, and Processing
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
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,
Indira Gandhi National Open University presents. A Video Lecture Course: Computer Platforms.
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.
1 Program Input Software Design Chapter 4. 2 You Will Want to Know... Prompting for and reading values into a program. Accessing data from a file. What.
MIPS I/O and Interrupt.
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.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
An Example Architecture. A Paper Computer - Woody Woody's characteristics Word size – 8 bits One word.
All code must be commented! Each problem part (1,2,3a,3b,…) will be in a separate file: problem_1.s …. You may be asked to demonstrate your program. You.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
The SPIM Trap Handler Syscall Trap handler services String operations File operations Memory allocation Central Connecticut State University, MIPS Tutorial.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
MIPS Architecture Topics –What resources MIPS assembly manipulates –CPU (Central Processing Unit) –ALU (Arithmetic & Logical Unit), Registers –Memory –I/O.
MISP Exception Facility Supported by SPIM simulator.
C is a high level language (HLL)
Input and Output The system console. In the beginning … When computers were relatively expensive and rare, most users interacted with a terminal –CRT.
CHAPTER 1 COMPUTER SCIENCE II. HISTORY OF COMPUTERS (1.1) Eniac- one of the worlds first computers Used more electricity than an entire city block of.
CPS4200 System Programming Spring 1 Systems Programming Chapter 1 Background I.
CS 312 Computer Architecture & Organization
Computers’ Basic Organization
Computer Science II Chapter 1.
Engineering Problem Solving With C An Object Based Approach
Computer Science 210 Computer Organization
Microprocessor Systems Design I
Integers/Characters Input/Output
Computer Science 210 Computer Organization
Microprocessor Systems Design I
Computer Electronic device Accepts data - input
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Operating Systems Chapter 5: Input/Output Management
Chapter 9 TRAP Routines and Subroutines
COMS 361 Computer Organization
CS 286 Computer Architecture & Organization
Presentation transcript:

Integers/Characters Input/Output Integers and Characters Input/Output System Calls. syscall Trap Handler Services for Integers and Characters Read Integer, Print Integer, Read Character, Print Character, Example Program No Input Line Buffer correction. Textbook: Appendix A (a48-a49) Central Connecticut State University, MIPS Tutorial. Chapter 22.

Review: MIPS Programming Model Based on this model we can suppose the existence of several groups of MIPS instructions: Inter Register transfer instructions. Arithmetic or Logical instructions with registers. Input / output instructions. Memory - register transfer instructions.

Single program without OS Up until now, our programs have been running with SPIM used as a computer with no machine code in it but our own. Can we write a program to deal with the Input / Output ? Up until now, our programs have been running with SPIM used as a computer with no machine code in it but our own. Can we write a program to deal with the Input / Output ?

I/O by user program or by OS ? I/O by user program is very costly process. In even the simplest computer, putting a character on the screen involves many instructions and a detailed knowledge of the video card duplication of significant parts of the program code. I/O by user program is very costly process. In even the simplest computer, putting a character on the screen involves many instructions and a detailed knowledge of the video card duplication of significant parts of the program code. One of the Operating System’s task is: to implement all these input/output operations and allow the user programs to use the high level input/output services provided by the OS. System Calls. One of the Operating System’s task is: to implement all these input/output operations and allow the user programs to use the high level input/output services provided by the OS. System Calls.

 Assembly language programs request operating system services using the syscall instruction.  The syscall instruction transfers control to the operating system which then performs the requested service.  Then control (usually) returns to the program.  Assembly language programs request operating system services using the syscall instruction.  The syscall instruction transfers control to the operating system which then performs the requested service.  Then control (usually) returns to the program. System Calls

 Different operating systems use the syscall instruction in different ways.  For the SPIM trap handler integer and character services it is used like this: SPIM trap handler integer and character services format

 The print services write characters to the simulated monitor of SPIM.  The read services read characters from the keyboard  and (for numeric read services) convert character strings into the appropriate type. SPIM trap handler integer and character services Service Code in $2 ($v0) Arguments Returned Value print integer1($a0) $4 == integer to print read integer5 $2 ($v0) <-- integer print character11($a0) $4 == character to print read character12 $2 ($v0) <-- character

 The read integer service reads an entire line of input from your keyboard—all the characters you type up to the newline character.  These characters are expected to be ASCII digits '0', '1',.., '9' with an optional leading '-' or '+'.  The characters are converted into a 32-bit two's complement representation of the integer which is returned in $v0.  The read integer service reads an entire line of input from your keyboard—all the characters you type up to the newline character.  These characters are expected to be ASCII digits '0', '1',.., '9' with an optional leading '-' or '+'.  The characters are converted into a 32-bit two's complement representation of the integer which is returned in $v0. Read Integer  The terminal gives to computer only one character at a time  That is why to get any other than character type of information (integer, string) OS reads characters one by one and translates them to the type we need.

The print integer service prints the integer represented by the 32 bits in $a0 to the SPIM terminal. Print Integer  The terminal is able to print only one character at a time  That is why any other type of information should be translated to the characters before printing to the terminal

The read character service reads one character from your keyboard. The character’s ASCII code is returned in $v0. Read Character ori $2,$0,12 # read character # to $2($v0) syscall General Purpose Register $V Low order

 The print character service prints the character represented in the lowest order byte of the 32 bits in $a0 to the SPIM terminal.  Characters 0x0D and 0x0A could be used for moving the console cursor to the next line’s first position. This is the standard End Of Line “\n” character’s behavior.  The print character service prints the character represented in the lowest order byte of the 32 bits in $a0 to the SPIM terminal.  Characters 0x0D and 0x0A could be used for moving the console cursor to the next line’s first position. This is the standard End Of Line “\n” character’s behavior. Print Character ori $4,$0,0x41 # prepare character “A” in $4 ($a0) ori $2,$0,11 # print character syscall 4 1 General Purpose Register $a Low order

 The user might make a mistake in entering the character and try to correct it by hitting the "backspace" key to erase the mistake.  But this does not work. The ascii value of the key 0x08 is included in the string just as any character value.  Odd byte values show up (in SPIM) as a small black rectangle.  The user might make a mistake in entering the character and try to correct it by hitting the "backspace" key to erase the mistake.  But this does not work. The ascii value of the key 0x08 is included in the string just as any character value.  Odd byte values show up (in SPIM) as a small black rectangle. No Input Line Buffer Correction