2 Steps Building the Coding and Testing Infrastructure

Size: px
Start display at page:

Download "2 Steps Building the Coding and Testing Infrastructure"

Transcription

1 CSI 333 Prog. HW/SW Interface Projects 5 Spring 2007 Professor Chaiken Simple Recursive Regular Expression Matcher in ASM Due: Oct 23 and Oct 30 (see below) The numbered items specify what will be graded and sketch a plan for adding new functionality to partially implemented modules. Early in the project, the infrastructure for printing the stack pointer within trace messages and for getting the input is built. Then, the for ordinary characters and special characters in the pattern are added one-by-one. Non-trivial programming work projects are best done incrementally. This means first write, test, debug and test again (after every change, no matter how little it is) a version that meets just a few of the specifications correctly. The first and subsequent versions enable you to add new functionality a little at a time, in such a way that each time new code is added, you can trust the previously completed code to help test and debug the new code. 1 Basic Requirements The subject (string) and pattern strings can contain any characters except for newlines (ascii code 0xA), carriage returns (ascii code 0xD) and the null character (ascii code 0x0). The LC3 simulator returns either an 0xA or 0xD when the user presses the ENTER key. Your program will detect that and put a null character after the subject and pattern strings. The pattern match code will detect the end of those strings when it finds the null character. In the pattern string, all characters are treated alike except for the following six special characters: *, [, ], {, } and \. All other characters are called ordinary characters. This project must be submitted in one file named matcher.asm of LC-3 assembly language. 1 The labels, operators, operands and comments must be indented fairly consistantly. You might indent everything the same way, or (better) you might use indentation to express the loop or conditional structure. 2 Different blocks of assembly code with different purposes must be separated by blank lines or blank comment lines. Also, each such block must be headed by comment that explains what it is for. 3 Every function implementation must be preceeded by comments that document what the function does, what its arguments are for, which registers hold which arguments, what it returns if anything, and which register holds the return value. 4 The comments preceeding each function that uses the stack must specify the function s stack frame layout. For example: ;M[R6]=saved R2 ;M[R6+1]=saved R3 ;M[R6+2]=saved R7 5 You are expected to assemble your source file one last time before submitting it so that you can be absolutely sure that the file will be assembled without errors when we test it. 2 Steps Building the Coding and Testing Infrastructure 2.1 Debugging Option Code DEBUG.BLKW 1 ; non-zero for debugging. 6 When the program starts, it should print the prompt: Debugging(0 or 1)? 1

2 The program then sets this DEBUG depending on whether the user inputs 0 (zero) or 1. (Don t bother with checking user input correctness or echoing.) Then, depending on whether the user inputs 0 or 1 by typing 0 (zero) or 1, the program sets this flag variable. 2.2 Function to Print 16-bit Numbers in Hex Code a function to print the number from R0 in upper case hexadecimal. For this you could code rotates and mask operations to extract each of the 4 nibbles. It might also use a decision to tell whether the nibble is 0-9 or A-F. To obtain the character to print in the first case, just add the nibble with the ASCII code for 0. In the second case, add the nibble to the constant (ASCII code for A MINUS Ten). Calculate this constant when you write the program. (A production assembler will let you code CONSTA10.FILL A -#10.) You might alternatively use table lookup to translate a nibble into Hex. Each Hex number printout should begin with x. The printout should NOT end with a newline. The Hex printing function must not mess up any of the registers other than R0 because this function will be called within functions that are quite unrelated. Since it won t be recursive, it can save register values in nearby memory words. R7 must be saved that way also because the LC-3 TRAPs you will call for printing will use R7. 7 If the DEBUG flag is set, the program should test your Hex printing function. A successful test is indicated by the printout: Testing Hex printer:xc3b0 (You will get 0 for the project if you fake this or any other test!) 2.3 LC-3 Functions that might be recursive We will follow the callee-save convention. All functions must protect the registers that are not used by their interface. All functions that call functions should follow the pattern demonstrated in our Week 06 Laboratory Exercise by using the stack to save register values. (Our algorithm can be expressed with one recursive function, so only that function needs to use the stack.) 1. One argument should be passed in R0 or two arguments be passed in R0 and R1. 2. The return value if any should be in R0. 3. R6 should always point to the top entry in the stack; push and pop operations are implemented by decrementing and incrementing R6. After decrementing R6, a value can be copied into the stack with STR Rx,R6,#0 where Rx contains the value. 4. R7 will be used by the JSR instruction to save the return address. Therefore, a function that calls another function must save and restore R7 using the stack. 5. The callee save convention should be used in all other cases: Every function should either not use, or save and restore the registers R2, R3, R4, and R5. R0 or R1 should be untouched or saved and restored except if the function is specified to use it for an argument or a return value. 2

3 2.4 Functions to Report Function Call and Return Code two function call and return tracing functions. One first prints Function call with SP(R6)= and the other prints Function retn with SP(R6)=. Then each should use the Hex printing function to print the value from R6. This should be the value of the stack pointer at the time the tracing function was called. 2.5 Main input and output First the program should set the DEBUG flag. The Hex printing test should be done next if the DEBUG flag is 1. Remember to write 8 the.blkw... code to reserve memory for the stack, and 9 to make R6 point to the word after the bottommost stack word soon after the program begins to run. Debugging or not, the program should next print 10 : Enter Pattern: and, on the same line, accept a pattern string of length up to 30 and store it as an LC-3 string (one character per 16-bit word terminated by 0.) 11 You should code an LC-3 function that inputs a string of length up to 30, with echoing, into memory beginning at the address given in R0. This function can be called once to get the Pattern and again to get the Subject. 12 If the user types more than 30 pattern characters, print Input too long. and call the QUIT trap. 13 Your program should make the LC-3 echo the characters as the user types them because this is what all computer users expect when they type on the keyboard. See the PP textbook for how to do this. 14 A newline (ASCII value 10 or 0xA) OR a carriage return (ASCII value 13 or 0xD) will indicate that the user pressed the ENTER key. When either of these values are returned by the GETC trap, it should (like other characters) be echoed with OUT. Then, 0 (zero) should be stored after characters that had been before. Since the maximum string length is 30, you must provide 31 words to accomodate them plus the 0 terminator. 15 Then, do the analogous things to input the subject string, length up to 30: Enter Subject: The program should next call your pattern matching function stub, with the address of the pattern string in R0 and the address of the subject string in R1. The pattern matching function will be coded to return 1 in R0 if the subject matches the subject and 0 otherwise. 16 The main sequence should then print Yes, it matches. or No, it doesn t match. depending on the return value. After printing this result, call the QUIT trap. 3

4 2.6 Pattern Matcher Stub Begin to write the pattern matching function as a stub. (A stub means a preliminary implementation that codes little or none of the functionality. It is written so that early versions of the software can be built and other functionality can be tested.) The stub should operate as follows: 17 First, if the DEBUG flag is non-zero, report a function call with the SP value by calling the function specifed above in 2.4, and then print the pattern and subject strings. The pattern string should be on the same line as the SP value. 18 The subject string should be on the next line and be vertically ALIGNED with the pattern string. The output should look like (with the?, x, and y replaced with the right data, of course): Function call with SP(R6)=x???? Pat:xxxxxxxxxx Sub:yyyyyyyy The stub should then print: Not implemented yet. 19 Third, if the DEBUG flag is non-zero, report a function return (including SP value) by calling the function specifed above in 2.4, and then printing the value that will be returned. It should look like: (The non-functioning should return 0 or 1, your choice.) Function retn with SP(R6)=x???? Ret value:x000? 20 The SP values printed by the call message and the corresponding retn message must be EQUAL. At this point, your program should assemble and run, and you can test all the functionality so far. Achieving this point is the bare minimum for a 50% or C- grade in this project. That includes proper operation BOTH when debugging is requested and when not. It should be submitted to Project 5 Infrastructure by Oct 23 to be on-time. 3 Pattern Matching An excellent algorithmic strategy for pattern matching results from extending the easy recursive algorithm for testing if two strings are equal. So, we will start with that first. 3.1 Recursive Algorithm to test if two strings are equal Prototype: bool Match(string P, string S) Input: Two strings, the pattern string P and the subject string S. Output: Return 0 if P and S are different, 1 if they are the same. Base Cases: If P is empty and S is non-empty, or if P is non-empty and S is empty, 4

5 then return 0. If both P and S are empty, then return 1. (Important!) Recursive Case: If both P and S are non-empty, do the following. Extract the first characters P1 and S1 from P and S respectively. If P1!= S1, then return 0. (Don t recurse). Otherwise, (P1==S1). Make PRest and SRest refer to the substrings of P and S that begin just after the first characters of each. Evaluate Match(PRest, SRest), capture its return value and return that. (Briefly, return Match(PRest, SRest).) Please note that every recursion terminates because the strings PRest and SRest in recursive calls are never longer than P and S respectively, and at least one of them is shorter than P or R respectively. In fact, both are shorter here; but in more interesting kinds of patterns, only one might be shorter. Recursion will terminate so long as (1) The base cases cover all the possibilities not covered by the recursive cases; and (2) in every recursive case, the total size of input to the recursive call is SMALLER THAN the total size of inputs to the caller. (CSI210 alumni can let N represent the total input size and prove that the program terminates for all values of N 0 by writing the explanation in terms of strong mathematical induction.) Assignment 21 First, add code to your Match function that handles the base cases as above. You must test it and get it right before going on! Under debugging, the messages for Function call and retn should be correct. Of course, the 3 test cases are empty P, non-empty S, non-empty P and empty S, and two empty strings. Again, test and correct it before going on!! 22 Second, add the recursive case. The debugging reports should show 1. the nesting of calls and returns, 2. the pattern and subject strings diminishing in length from each call to the next, and 3. the first return of 0 should be where the leftmost non-matching characters occur, and the first return of 1 should be where two empty strings match. If you get recursive exact matching with debugging reports to work correctly for all cases (either or both strings empty, successful matches with various string matches, and various cases of unsuccessful matches) the project grade will be at least C. 5

6 3.2 Any substring matching 23 The character * within the pattern will match any substring of 0 or more characters in the subject. Here is the strategy to adding the * capability: When the pattern string BEGINS with *, the Match function tries to find a successful match by trying these possiblities in order: 1. The (first) * matches the empty string. Try matching S against the pattern obtained by removing the *. 2. The (first) * matches one or more characters at the beginning of S. Try matching P (unchanged, beginning with *) against the subject obtained from S by removing the first character. (This first character is one of those matched by the *.) 3.3 Subset matching of one character Here and below,??? denotes a possibly empty string that does not contain any of the characters [, ], {, } or *. 24 A substring within the pattern of the form [???] will match exactly one character from S if that character is in???. 3.4 Subset matching of a substrings 25 A substring within the pattern of the form {???} will match any number of characters from S including 0 if all those characters are in???. (So, if??? is empty, it matches the empty string only. If??? is non-empty, it can match either the empty string or some non-empty strings.) 3.5 Escape d Characters The special character \ is called the escape character. It enables the pattern writer to use a special character anywhere an ordinary character would be acceptable. 26 Thus, the the six length 2 character sequences *, \\, \[, \] \{ and \} match single characters *, \, [, ] { and } respectively. These six length 2 sequences are called escape sequences. 27 The appearance of (an unescaped) \ in the pattern immediately followed by the end of the pattern or a character that is not d, *, \, [, ] { or } makes the pattern illegal. 28 Escape sequences can appear within [...] or {...} expressions. In that context, the escaped character is treated as an ordinary character within the set that the [...] or {...} denotes. 29 Unescaped special characters cannot appear within the... of the [...] or {...} expressions, and expressions beginning with [ or { must be complete. Thus, [a{bc}d], and [a}] and {abcd are illegal patterns. 6

7 3.6 Digit Class of Characters 30 (As in Perl patterns) the new escape sequence \d in a pattern stands for any of the decimal digit characters Project 5 Infrastructure Due Oct 23 (2 weeks) The on-time due time in 11:00 PM, Oct. 23. Submit the ACSII file (with the comments) to Project 5 Infrastructure via WebCT. Late submissions will be penalized at the rate of about 25% per day for the next 48 hours, so the maximum penalty will be 50%. Please address any questions not addressed by the material above to me or the TA early enough so you know what you need to complete the project on time, even if there are some unexpected debugging delays! 5 Project 5 Functional Completion Due Oct 30 (1 week later) The on-time due time in 11:00 PM, Oct. 30. Submit the ACSII file (with the comments) to Project 5 Infrastructure via WebCT. Late submissions will be penalized at the rate of about 25% per day for the next 48 hours, so the maximum penalty will be 50%. 6 Background Pattern matchers are useful for testing a string for particular properties, such as whether it begins with a particular letter or has a particular substring in it. Pattern matching can be invoked repeatedly to find from a set of strings all the strings we might be interested in. To see pattern matching in action, go to /usr/bin (with cd /usr/bin) and try the command ls *es* Then, try ls and see how hard it is find all the Unix commands whose names contains the consecutive letters es. Try the commands ls [ab]*, and ls [ab]*s. What names do these patterns select? Why? The Unix utility pattern matcher is described by man regexp. Pattern matching is a heavily used feature of the programming language Perl which is commonly used in CGI programs to interpret what people type into response boxes on Web pages. Regular expression patterns are also used in programming language manuals or other application specifications to describe precisely what the legal strings for various applications are. A language (set of strings) that can be defined as the set of all strings that match a particular regular expression is called a regular language. The fact that regular languages can be defined just as well by scanners with a finite number of states ( finite state automata ) is fundamental to the theory of computation. See the attached chapter by Kernighan for additional background and insights. (DO NOT implement the patterns in the chapter for this project...they are different from the CSI333 assignment above.) 7

Subroutines & Traps. Announcements. New due date for assignment 2 5pm Wednesday, 5May

Subroutines & Traps. Announcements. New due date for assignment 2 5pm Wednesday, 5May Computer Science 210 s1c Computer Systems 1 2010 Semester 1 Lecture Notes Lecture 19, 26Apr10: Subroutines & Traps James Goodman! Announcements New due date for assignment 2 5pm Wednesday, 5May Test is

More information

ENCM 369 Winter 2017 Lab 3 for the Week of January 30

ENCM 369 Winter 2017 Lab 3 for the Week of January 30 page 1 of 11 ENCM 369 Winter 2017 Lab 3 for the Week of January 30 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2017 Lab instructions and other documents for

More information

A Microprocessor Systems Fall 2009

A Microprocessor Systems Fall 2009 304 426A Microprocessor Systems Fall 2009 Lab 1: Assembly and Embedded C Objective This exercise introduces the Texas Instrument MSP430 assembly language, the concept of the calling convention and different

More information

Project 1: Implementation of the Stack ADT and Its Application

Project 1: Implementation of the Stack ADT and Its Application Project 1: Implementation of the Stack ADT and Its Application Dr. Hasmik Gharibyan Deadlines: submit your files via handin by midnight (end of the day) on Thursday, 10/08/15. Late submission: submit your

More information

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri

CS356: Discussion #6 Assembly Procedures and Arrays. Marco Paolieri CS356: Discussion #6 Assembly Procedures and Arrays Marco Paolieri (paolieri@usc.edu) Procedures Functions are a key abstraction in software They break down a problem into subproblems. Reusable functionality:

More information

ECE220: Computer Systems and Programming Spring 2018 Honors Section due: Saturday 14 April at 11:59:59 p.m. Code Generation for an LC-3 Compiler

ECE220: Computer Systems and Programming Spring 2018 Honors Section due: Saturday 14 April at 11:59:59 p.m. Code Generation for an LC-3 Compiler ECE220: Computer Systems and Programming Spring 2018 Honors Section Machine Problem 11 due: Saturday 14 April at 11:59:59 p.m. Code Generation for an LC-3 Compiler This assignment requires you to use recursion

More information

ECE 206, Fall 2001: Lab 3

ECE 206, Fall 2001: Lab 3 ECE 206, : Lab 3 Data Movement Instructions Learning Objectives This lab will give you practice with a number of LC-2 programming constructs. In particular you will cover the following topics: - Load/store

More information

A4: HTML Validator/Basic DOM Operation

A4: HTML Validator/Basic DOM Operation A4: HTML Validator/Basic DOM Operation Overview You are tasked with creating a basic HTML parser to perform a *very* limited subset of what a web browser does behind the scenes to setup the DOM for displaying

More information

Chapter 10 And, Finally... The Stack. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University

Chapter 10 And, Finally... The Stack. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University Chapter 10 And, Finally... The Stack ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 2 Stack: An Abstract Data Type An important abstraction that

More information

Introduction to Computer Engineering. CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison

Introduction to Computer Engineering. CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison Introduction to Computer Engineering CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison Chapter 7 & 9.2 Assembly Language and Subroutines Human-Readable

More information

Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore (Refer Slide Time: 00:20) Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 4 Lexical Analysis-Part-3 Welcome

More information

CS401 Assembly Language Solved MCQS From Midterm Papers

CS401 Assembly Language Solved MCQS From Midterm Papers CS401 Assembly Language Solved MCQS From Midterm Papers May 14,2011 MC100401285 Moaaz.pk@gmail.com MC100401285@gmail.com PSMD01(IEMS) Question No:1 ( Marks: 1 ) - Please choose one The first instruction

More information

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000 Declaring Variables in Assembly Language As in Java, variables must be declared before they can be used Unlike Java, we do not specify a variable type in the declaration in assembly language Instead we

More information

Subroutines. int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;}

Subroutines. int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;} Subroutines Also called procedures or functions Example C code: int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;} // subroutine converts Celsius to kelvin int celtokel(int i) { return (i

More information

6.001 Recitation 23: Register Machines and Stack Frames

6.001 Recitation 23: Register Machines and Stack Frames 6.001 Recitation 23: Register achines and Stack Frames RI: Gerald Dalley, dalleyg@mit.edu, 8 ay 2007 http://people.csail.mit.edu/dalleyg/6.001/sp2007/ iscellany apply: See the IT Scheme documentation for

More information

Homework #3: Functions Calling Functions, and Recursion

Homework #3: Functions Calling Functions, and Recursion Homework #3: Functions Calling Functions, and Recursion Assigned: Tuesday 17 Jun 2014 Due: Monday 23 Jun 2014 (at 23:59:59) This MIPS programming assignment introduces MIPS functions (which [P&H14] calls

More information

Final Project: LC-3 Simulator

Final Project: LC-3 Simulator Final Project: LC-3 Simulator Due Date: Friday 4/27/2018 11:59PM; No late handins This is the final project for this course. It is a simulator for LC-3 computer from the Patt and Patel book. As you work

More information

appendix a The LC-3 ISA A.1 Overview

appendix a The LC-3 ISA A.1 Overview A.1 Overview The Instruction Set Architecture (ISA) of the LC-3 is defined as follows: Memory address space 16 bits, corresponding to 2 16 locations, each containing one word (16 bits). Addresses are numbered

More information

Address Modes effective address

Address Modes effective address Address Modes The MARIE supports only three addressing modes: immediate, direct, and indirect. We are now going to discuss addressing modes in general. Most computers support quite a few of these modes.

More information

Lecture V Toy Hardware and Operating System

Lecture V Toy Hardware and Operating System 2. THE Machine Lecture V Page 1 Lecture V Toy Hardware and Operating System 1. Introduction For use in our OS projects, we introduce THE Machine where THE is an acronym 1 for Toy HardwarE. We also introduce

More information

System Calls. Chapter 9 TRAP Routines and Subroutines

System Calls. Chapter 9 TRAP Routines and Subroutines System Calls Chapter 9 TRAP Routines and Subroutines Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Certain operations require

More information

TRAPs and Subroutines. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

TRAPs and Subroutines. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell TRAPs and Subroutines University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell System Calls Certain operations require specialized knowledge and protection: specific knowledge

More information

Chapter 9 TRAP Routines and Subroutines

Chapter 9 TRAP Routines and Subroutines Chapter 9 TRAP Routines and Subroutines System Calls Certain operations require specialized knowledge and protection: specific knowledge of I/O device registers and the sequence of operations needed to

More information

ECE 109 Sections 602 to 605 Final exam Fall December, 2007

ECE 109 Sections 602 to 605 Final exam Fall December, 2007 ECE 109 Sections 602 to 605 Final exam Fall 2007 13 December, 2007 This is a closed book and closed notes exam. Calculators, PDA's, cell phones, and any other electronic or communication devices may not

More information

Final Programming Project

Final Programming Project Due Thursday, Dec. 7, at 5:00 pm Logistics This assignment should be completed in groups of 3. This is not optional -- you are not allowed to complete it on your own, or in groups of any other size. I

More information

Chapter 9 TRAP Routines and Subroutines

Chapter 9 TRAP Routines and Subroutines Chapter 9 TRAP Routines and Subroutines System Calls Certain operations require specialized knowledge and protection: specific knowledge of I/O device registers and the sequence of operations needed to

More information

! What do we care about? n Fast program execution. n Efficient memory usage. n Avoid memory fragmentation. n Maintain data locality

! What do we care about? n Fast program execution. n Efficient memory usage. n Avoid memory fragmentation. n Maintain data locality Problem Chapter 10 Memory Model for Program Execution Original slides by Chris Wilcox, Colorado State University How do we allocate memory during the execution of a program written in C?! Programs need

More information

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer

CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer Assigned: Thursday, September 16, 2004 Due: Tuesday, September 28, 2004, at 11:59pm September 16, 2004 1 Introduction Overview In this

More information

Trap Vector Table. Interrupt Vector Table. Operating System and Supervisor Stack. Available for User Programs. Device Register Addresses

Trap Vector Table. Interrupt Vector Table. Operating System and Supervisor Stack. Available for User Programs. Device Register Addresses Chapter 1 The LC-3b ISA 1.1 Overview The Instruction Set Architecture (ISA) of the LC-3b is defined as follows: Memory address space 16 bits, corresponding to 2 16 locations, each containing one byte (8

More information

Programming Project 4: COOL Code Generation

Programming Project 4: COOL Code Generation CS 331 Compilers Fall 2017 Programming Project 4: COOL Code Generation Prof. Szajda Due Tuesday, December 5, 11:59:59 pm NOTE: There will be no extensions whatsoever given for this project! So, begin it

More information

Assembly Language. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

Assembly Language. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell Assembly Language University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell Human-Readable Machine Language Computers like ones and zeros 0001110010000110 Humans like symbols

More information

sarm User Guide Note that a space must appear before the operation field because any word beginning in the first column is a label

sarm User Guide Note that a space must appear before the operation field because any word beginning in the first column is a label sarm User Guide The sarm is program that implements an experimental CPU simulator. It is called experimental because it is not yet complete, and it also incorporates facilities that are not conventionally

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

Project #1 Exceptions and Simple System Calls

Project #1 Exceptions and Simple System Calls Project #1 Exceptions and Simple System Calls Introduction to Operating Systems Assigned: January 21, 2004 CSE421 Due: February 17, 2004 11:59:59 PM The first project is designed to further your understanding

More information

Chapter 9 TRAP Routines and Subroutines

Chapter 9 TRAP Routines and Subroutines Chapter 9 TRAP Routines and Subroutines ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 5-2 System Calls Certain operations require specialized knowledge

More information

LC-3 Subroutines and Traps. (Textbook Chapter 9)"

LC-3 Subroutines and Traps. (Textbook Chapter 9) LC-3 Subroutines and Traps (Textbook Chapter 9)" Subroutines" Blocks can be encoded as subroutines" A subroutine is a program fragment that:" lives in user space" performs a well-defined task" is invoked

More information

ECE198KL: Introduction to Computer Engineering II Spring 2013 due: 10 p.m. on Monday 21 January. Printing a Histogram

ECE198KL: Introduction to Computer Engineering II Spring 2013 due: 10 p.m. on Monday 21 January. Printing a Histogram ECE198KL: Introduction to Computer Engineering II Spring 2013 Program 1 due: 10 p.m. on Monday 21 January Printing a Histogram In this first programming assignment, you will extend code that we develop

More information

LC-3 TRAP Routines. Textbook Chapter 9

LC-3 TRAP Routines. Textbook Chapter 9 LC-3 TRAP Routines Textbook Chapter 9 System Calls Certain operations require specialized knowledge and protection: specific knowledge of I/O device registers and the sequence of operations needed to use

More information

Syntax of LC-3 assembly: Language elements. Instructions

Syntax of LC-3 assembly: Language elements. Instructions LC-3 Assembly Language (Textbook Chapter 7) Assembly and assembler Machine language - binary 0001110010000110 Assembly language - symbolic ADD R6, R2, R6 ; increment index reg. Assembler is a program that

More information

Midterm 2 Review Chapters 4-16 LC-3

Midterm 2 Review Chapters 4-16 LC-3 Midterm 2 Review Chapters 4-16 LC-3 ISA You will be allowed to use the one page summary. 8-2 LC-3 Overview: Instruction Set Opcodes 15 opcodes Operate instructions: ADD, AND, NOT Data movement instructions:

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

1/30/2018. Conventions Provide Implicit Information. ECE 220: Computer Systems & Programming. Arithmetic with Trees is Unambiguous

1/30/2018. Conventions Provide Implicit Information. ECE 220: Computer Systems & Programming. Arithmetic with Trees is Unambiguous University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming The Stack Abstraction Conventions Provide Implicit Information What does

More information

ECE 190 Midterm Exam 3 Spring 2011

ECE 190 Midterm Exam 3 Spring 2011 ECE 190 Midterm Exam 3 Spring 2011 Practice Exam Notes: This exam will consist entirely of five programming problems. Each problem will be graded separately. We will provide skeleton codes for each problem.

More information

Lab 03 - x86-64: atoi

Lab 03 - x86-64: atoi CSCI0330 Intro Computer Systems Doeppner Lab 03 - x86-64: atoi Due: October 1, 2017 at 4pm 1 Introduction 1 2 Assignment 1 2.1 Algorithm 2 3 Assembling and Testing 3 3.1 A Text Editor, Makefile, and gdb

More information

EXPERIMENT 1. FAMILIARITY WITH DEBUG, x86 REGISTERS and MACHINE INSTRUCTIONS

EXPERIMENT 1. FAMILIARITY WITH DEBUG, x86 REGISTERS and MACHINE INSTRUCTIONS EXPERIMENT 1 FAMILIARITY WITH DEBUG, x86 REGISTERS and MACHINE INSTRUCTIONS Pre-lab: This lab introduces you to a software tool known as DEBUG. Before the lab session, read the first two sections of chapter

More information

EE 314 Spring 2003 Microprocessor Systems

EE 314 Spring 2003 Microprocessor Systems EE 314 Spring 2003 Microprocessor Systems Laboratory Project #3 Arithmetic and Subroutines Overview and Introduction Review the information in your textbook (pp. 115-118) on ASCII and BCD arithmetic. This

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

CMSC 412 Project 1: Keyboard and Screen Drivers

CMSC 412 Project 1: Keyboard and Screen Drivers Introduction CMSC 412 Project 1: Keyboard and Screen Drivers Due: February 11, 1998 (in recitation) Almost all computers need to operate with external devices. At the very least, you need to use the keyboard,

More information

Chapter 10 Memory Model for Program Execution. Problem

Chapter 10 Memory Model for Program Execution. Problem Chapter 10 Memory Model for Program Execution Original slides by Chris Wilcox, Colorado State University Problem How do we allocate memory during the execution of a program written in C?! Programs need

More information

COMP 412, Fall 2018 Lab 1: A Front End for ILOC

COMP 412, Fall 2018 Lab 1: A Front End for ILOC COMP 412, Lab 1: A Front End for ILOC Due date: Submit to: Friday, September 7, 2018 at 11:59 PM comp412code@rice.edu Please report suspected typographical errors to the class Piazza site. We will issue

More information

Introduction to Computers & Programming

Introduction to Computers & Programming 16.070 Introduction to Computers & Programming Theory of computation 5: Reducibility, Turing machines Prof. Kristina Lundqvist Dept. of Aero/Astro, MIT States and transition function State control A finite

More information

Project 3 Due October 21, 2015, 11:59:59pm

Project 3 Due October 21, 2015, 11:59:59pm Project 3 Due October 21, 2015, 11:59:59pm 1 Introduction In this project, you will implement RubeVM, a virtual machine for a simple bytecode language. Later in the semester, you will compile Rube (a simplified

More information

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands Table Of Contents 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands Getting onto the Zoo Type ssh @node.zoo.cs.yale.edu, and enter your netid pass when prompted.

More information

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

UNIT-II. Part-2: CENTRAL PROCESSING UNIT Page1 UNIT-II Part-2: CENTRAL PROCESSING UNIT Stack Organization Instruction Formats Addressing Modes Data Transfer And Manipulation Program Control Reduced Instruction Set Computer (RISC) Introduction:

More information

CS 2210 Programming Project (Part IV)

CS 2210 Programming Project (Part IV) CS 2210 Programming Project (Part IV) April 25, 2018 Code Generation This project is intended to give you experience in writing a code generator as well as bring together the various issues of code generation

More information

CS 61C: Great Ideas in Computer Architecture (Machine Structures) More MIPS Machine Language

CS 61C: Great Ideas in Computer Architecture (Machine Structures) More MIPS Machine Language CS 61C: Great Ideas in Computer Architecture (Machine Structures) More MIPS Machine Language Instructors: Randy H. Katz David A. PaGerson hgp://inst.eecs.berkeley.edu/~cs61c/sp11 1 2 Machine Interpreta4on

More information

Chapter 7 Assembly Language

Chapter 7 Assembly Language Chapter 7 Assembly Language Computing Layers Problems Algorithms Language Instruction Set Architecture Microarchitecture Circuits Devices 2 Human-Readable Machine Language Computers like ones and zeros

More information

Chapter 7 Assembly Language. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University

Chapter 7 Assembly Language. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University Chapter 7 Assembly Language ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 2 Human-Readable Machine Language Computers like ones and zeros 0001110010000110

More information

Shift and Rotate Instructions

Shift and Rotate Instructions Shift and Rotate Instructions Shift and rotate instructions facilitate manipulations of data (that is, modifying part of a 32-bit data word). Such operations might include: Re-arrangement of bytes in a

More information

Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #7. Warehouse Scale Computer

Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #7. Warehouse Scale Computer CS 61C: Great Ideas in Computer Architecture Everything is a Number Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13 9/19/13 Fall 2013 - - Lecture #7 1 New- School Machine Structures

More information

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm CSECE 374 Fall 2016 Homework 1 Due Tuesday, September 6, 2016 at 8pm Starting with this homework, groups of up to three people can submit joint solutions. Each problem should be submitted by exactly one

More information

Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson

Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson Lecture 7: Primitive Recursion is Turing Computable Michael Beeson Closure under composition Let f and g be Turing computable. Let h(x) = f(g(x)). Then h is Turing computable. Similarly if h(x) = f(g 1

More information

Intel Architecture Segment:Offset Memory Addressing

Intel Architecture Segment:Offset Memory Addressing Name: Date: Lab Section: Lab partner s name: Lab PC Number: Objectives: Understanding video memory and character mapping of CGA characters in ROM BIOS, using the DOS debug command. Writing simple assembly-language

More information

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison Introduction to Computer Engineering CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison Chapter 7 & 9.2 Assembly Language and Subroutines Human-Readable Machine

More information

Programming Assignment IV Due Thursday, November 18th, 2010 at 11:59 PM

Programming Assignment IV Due Thursday, November 18th, 2010 at 11:59 PM Programming Assignment IV Due Thursday, November 18th, 2010 at 11:59 PM 1 Introduction In this assignment, you will implement a code generator for Cool. When successfully completed, you will have a fully

More information

Chapter 2A Instructions: Language of the Computer

Chapter 2A Instructions: Language of the Computer Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction

More information

MIPS Functions and Instruction Formats

MIPS Functions and Instruction Formats MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other

More information

CS 135: Computer Architecture I

CS 135: Computer Architecture I What next? : Computer Architecture I Instructor: Prof. Bhagi Narahari Dept. of Computer Science Course URL: www.seas.gwu.edu/~bhagiweb/cs135/ Low level/machine-level Programming Assembly Language programming

More information

EECE.2160: ECE Application Programming

EECE.2160: ECE Application Programming Spring 2018 Programming Assignment #10: Instruction Decoding and File I/O Due Wednesday, 5/9/18, 11:59:59 PM (Extra credit ( 4 pts on final average), no late submissions or resubmissions) 1. Introduction

More information

ASSIST Assembler Replacement User s Guide

ASSIST Assembler Replacement User s Guide ASSIST Assembler Replacement User s Guide Program&Documentation: John R. Mashey Pro ject Supervision : Graham Campbell PSU Computer Science Department Preface This manual is the key reference source for

More information

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Programming Standards: You must conform to good programming/documentation standards. Some specifics: CS3114 (Spring 2011) PROGRAMMING ASSIGNMENT #3 Due Thursday, April 7 @ 11:00 PM for 100 points Early bonus date: Wednesday, April 6 @ 11:00 PM for a 10 point bonus Initial Schedule due Thursday, March

More information

COMP40 Assignment: Assembly-Language Programming

COMP40 Assignment: Assembly-Language Programming COMP40 Assignment: Assembly-Language Programming Assignment due Sunday, December 11 at 11:59 PM. Design (in limited form; see below) due Tuesday December 6 at 11:59 PM. Contents 1 Purpose and overview

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Homework 1 Due Tuesday, January 30, 2018 at 8pm

Homework 1 Due Tuesday, January 30, 2018 at 8pm CSECE 374 A Spring 2018 Homework 1 Due Tuesday, January 30, 2018 at 8pm Starting with this homework, groups of up to three people can submit joint solutions. Each problem should be submitted by exactly

More information

Objectives. ICT106 Fundamentals of Computer Systems Topic 8. Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8

Objectives. ICT106 Fundamentals of Computer Systems Topic 8. Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8 Objectives ICT106 Fundamentals of Computer Systems Topic 8 Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8 To understand how HLL procedures/functions are actually implemented

More information

S206E Lecture 19, 5/24/2016, Python an overview

S206E Lecture 19, 5/24/2016, Python an overview S206E057 Spring 2016 Copyright 2016, Chiu-Shui Chan. All Rights Reserved. Global and local variables: differences between the two Global variable is usually declared at the start of the program, their

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Introduction to Regular Expressions Version 1.3. Tom Sgouros

Introduction to Regular Expressions Version 1.3. Tom Sgouros Introduction to Regular Expressions Version 1.3 Tom Sgouros June 29, 2001 2 Contents 1 Beginning Regular Expresions 5 1.1 The Simple Version........................ 6 1.2 Difficult Characters........................

More information

Wednesday, February 7, 2018

Wednesday, February 7, 2018 Wednesday, February 7, 2018 Topics for today The Pep/9 memory Four example programs The loader The assembly language level (Chapter 5) Symbolic Instructions Assembler directives Immediate mode and equate

More information

And Parallelism. Parallelism in Prolog. OR Parallelism

And Parallelism. Parallelism in Prolog. OR Parallelism Parallelism in Prolog And Parallelism One reason that Prolog is of interest to computer scientists is that its search mechanism lends itself to parallel evaluation. In fact, it supports two different kinds

More information

CS 61C: Great Ideas in Computer Architecture Func%ons and Numbers

CS 61C: Great Ideas in Computer Architecture Func%ons and Numbers CS 61C: Great Ideas in Computer Architecture Func%ons and Numbers 9/11/12 Instructor: Krste Asanovic, Randy H. Katz hcp://inst.eecs.berkeley.edu/~cs61c/sp12 Fall 2012 - - Lecture #8 1 New- School Machine

More information

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI Recall Big endian, little endian Memory alignment Unsigned

More information

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs

More information

Important Project Dates

Important Project Dates Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2002 Handout 4 Project Overview Wednesday, September 4 This is an overview of the course project

More information

CSCI-1200 Data Structures Spring 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

CSCI-1200 Data Structures Spring 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic CSCI-1200 Data Structures Spring 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic Announcements: Test 1 Information Test 1 will be held Monday, February 5th, 2017 from 6-7:50pm Students will be randomly

More information

EEL 3801 Introduction to Computer Engineering Summer Home Work Schedule

EEL 3801 Introduction to Computer Engineering Summer Home Work Schedule EEL 3801 Introduction to Computer Engineering Summer 2005 Home Work Schedule Schedule of Assignments: Week HW# Due Points Title 1 07/05/05 3% Memory dump in assembly 2 07/19/05 3% Solve a Maze 3 08/02/05

More information

1. Introduction to Assembly Language

1. Introduction to Assembly Language www.vchowk.com 1. Introduction to Assembly Language Solved EXERCISE 1 Note: Dear fellows I tried my best to solve this exercise questions if there s any mistake or doubt in any question correct it and

More information

Programming Model 2 A. Introduction

Programming Model 2 A. Introduction Programming Model 2 A. Introduction Objectives At the end of this lab you should be able to: Use direct and indirect addressing modes of accessing data in memory Create an iterative loop of instructions

More information

CS 4410 Operating Systems. Computer Architecture Review Oliver Kennedy

CS 4410 Operating Systems. Computer Architecture Review Oliver Kennedy CS 4410 Operating Systems Computer Architecture Review Oliver Kennedy The Dawn of Computing The OS! Multitasking So what s under the hood? Well... not quite Networks A CPU Registers: The CPU s short term

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #9: MIPS Procedures 2006-07-11 CS 61C L09 MIPS Procedures (1) Andy Carle C functions main() { int i,j,k,m;... i = mult(j,k);... m =

More information

CS 61C: Great Ideas in Computer Architecture Strings and Func.ons. Anything can be represented as a number, i.e., data or instruc\ons

CS 61C: Great Ideas in Computer Architecture Strings and Func.ons. Anything can be represented as a number, i.e., data or instruc\ons CS 61C: Great Ideas in Computer Architecture Strings and Func.ons Instructor: Krste Asanovic, Randy H. Katz hdp://inst.eecs.berkeley.edu/~cs61c/sp12 Fall 2012 - - Lecture #7 1 New- School Machine Structures

More information

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes Overview For this lab, you will use: one or more of the conditional statements explained below

More information

CSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic

CSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic CSCI-1200 Data Structures Spring 2017 Lecture 5 Pointers, Arrays, Pointer Arithmetic Announcements Submitty iclicker registration is still open. Even if you already registered on the iclicker website,

More information

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like? Chapter 3 - Simple JavaScript - Programming Basics Lesson 1 - JavaScript: What is it and what does it look like? PP presentation JavaScript.ppt. Lab 3.1. Lesson 2 - JavaScript Comments, document.write(),

More information

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in

More information

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1 CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB

More information

Winter 2019 CISC101 1/17/2019

Winter 2019 CISC101 1/17/2019 CISC101 Reminders Today TA emails are listed on the Labs page of the course web site. More assignments are posted. Commanding the CPU the use of a Stack. Computer Languages History of Python. Features

More information

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation Course Schedule CS 221 Computer Architecture Week 3: Information Representation (2) Fall 2001 W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep

More information

CSC 101 Spring 2010 Lab #8 Report Gradesheet

CSC 101 Spring 2010 Lab #8 Report Gradesheet CSC 101 Spring 2010 Lab #8 Report Gradesheet Name WFU Username Lab Section: A B C D Partner s Name (if you had one): Topic Points Notes Pre-lab questions 20 total - 5 at 4 points each Lab report questions

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information