Computer Science 210 Computer Organization

Slides:



Advertisements
Similar presentations
Computer Science 210 Computer Organization Strings, I/O, and Trap Service Routines.
Advertisements

Chapter 7 Introduction to LC-3 Assembly Language Assembly Language Assembly Process Using the Editor & Simulator for Assembly Language Programming.
1 System Calls (TRAPS) and Subroutines Patt and Patel Ch. 9.
LC-3 Assembly Language Programming Examples
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
Overview I/O – memory mapped programmed / interrupt driven Traps mechanism & RET Subroutines & JSR & JSRR & RET Interrupt mechanism & RTI.
Chapter 9 Overview Traps mechanism & RET Subroutines & JSR & JSRR & RET Interrupt mechanism & RTI.
CSS 372 Oct 2 nd - Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture.
Chapter 6 Programming in Machine Language The LC-3 Simulator
Chapter 9 Trap Routines & RET Subroutines (or Functions) & JSR & JSRR & RET.
Overview Projects The Assembly Process Programmed I/O Interrupt Driven I/O.
Chapter 8 Overview Programmed I/O Introduction to Interrupt Driven I/O Project 3.
Chapter 8 I/O Programming Chapter 9 Trap Service Routines Programmed I/O Interrupts Interrupt Driven I/O Trap Service Routines.
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Chapter 8 Overview Programmed I/O Interrupt Driven I/O.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 8 Input/Output Basic organization Keyboard input Monitor output Interrupts DMA.
Chapter 8 Input/Output l I/O basics l Keyboard input l Monitor output l Interrupt driven I/O l DMA.
Computer Science 210 Computer Organization Introduction to Subroutines.
Chapter 9 Chapter 9 Subroutines and TRAPs l Privileged Instructions l TRAP Routines l Subroutines.
Computer Science 210 Computer Organization Machine Language Instructions: Control.
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 tutorial 5
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 & 9.2 Assembly Language
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
HKN ECE 220: Fall 2017 Midterm 1 AJ Schroeder, Evan Lissoos, Utsav Kawrani 23rd September, 2017.
COSC121: Computer Systems: LC3 Traps and Subroutines
Chapter 7 Assembly Language
COSC121: Computer Systems: LC3 I/O (Intro)
Computer Science 210 Computer Organization
Chapter 8 Input/Output I/O basics Keyboard input Monitor output
Chapter 9 TRAP Routines and Subroutines
The LC-3 Instruction Set Architecture Data Movement instructions
Computer Science 210 Computer Organization
LC-3 Details and Examples
Chapter 7 LC-2 Assembly Language.
Computer Science 210 Computer Organization
Chapter 9 TRAP Routines and Subroutines
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
HKN ECE 220: Spring 2018 Midterm 1
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Introduction to Computer Engineering
TRAP Routines Subroutines Privileged Instructions
Chapter 9 TRAP Routines and Subroutines
Chapter 8 I/O.
Chapter 7 LC-2 Assembly Language.
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 Assembly Language
TRAP Routines Privileged Instructions Subroutines
Chapter 9 TRAP Routines and Subroutines
Chapter 8 I/O.
School of Computer Science and Technology
Computer Science 210 Computer Organization
HKN ECE 220: Fall 2018 Midterm 1 Andrew Fortunat, Jeff Chang, Srijan Chakraborty, Kanad Sarkar February 16, 2019.
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
Chapter 7 Assembly Language
Midterm 2 Review Chapters 4-16 LC-3
Chapter 9 TRAP Routines and Subroutines
Presentation transcript:

Computer Science 210 Computer Organization Introduction to Strings

Strings Sequences of characters, represented internally as ASCII values Basic ASCII is 8 bits, stored in lower order byte, with higher order byte clear A null character (ASCII 0) always terminates a string

;; Author: Ken Lambert ;; This program declares the string "Assembler is fun!" .ORIG x3000 ; Program code HALT ; Data variables MESSAGE .STRINGZ "Assembler is fun!" .END The STRINGZ directive puts a string’s ASCII values in consecutive memory cells, followed by a null character (ASCII 0)

String output with array-based loop and polling ;; Author: Ken Lambert ;; This program outputs the string "Assembler is fun!" ;; Pseudocode design: ; for ch in "Assembler is fun!" ; loop while display status >= 0 ; print ch .ORIG x3000 ;; Register usage: ; R1 = contents of display status register ; R0 = contents of display data register ; R2 = address of the next character in the string ; Main program code LEA R2, MESSAGE ; Get the base address of the string CHLOOP LDR R0, R2, #0 ; Get the next character from the string BRz ENDMAIN ; Quit when it's null (end of string) POLL LDI R1, DSR ; Poll for negative display status register BRzp POLL ; (ready bit = 1) STI R0, DDR ; Display is ready, so output the character ADD R2, R2, #1 ; Increment the character's address BR CHLOOP ENDMAIN HALT ; Main program data DSR .FILL xFE04 ; Address of the display status register DDR .FILL xFE06 ; Address of the display data register MESSAGE .STRINGZ "Assembler is fun!" .END String output with array-based loop and polling

String output with trap service routine PUTS ;; Author: Ken Lambert ;; This program outputs the string "Assembler is fun!" ;; Pseudocode design: ; print "Assembler is fun!" ;; Register usage: ; R0 = base address of the string .ORIG x3000 ; Main program code LEA R0, MESSAGE ; Load the address of the string PUTS ; Call the trap service routine to output it HALT ; Main program data MESSAGE .STRINGZ "Assembler is fun!" .END String output with trap service routine PUTS Using the trap service routine reduces 8 lines of code to 2

Watch Your Registers! The PUTS routine expects the address of the string in R0 Before the call, the return address (the incremented PC) is saved in R7

LC-3 Trap Service Routines vector symbol routine x20 GETC read a single character (no echo) x21 OUT output a character to the monitor x22 PUTS write a string to the console x23 IN print prompt to console, read and echo character from keyboard x25 HALT halt the program The first four routines work with data in R0

More Problems Find the length of a string Convert a string to uppercase or lowercase Convert a string of digits to an integer Convert an integer to a string of digits

For Wednesday String input