Chapter 6 Programming the LC-3

Size: px
Start display at page:

Download "Chapter 6 Programming the LC-3"

Transcription

1 Chapter 6 Programming the LC-3 Based on slides McGraw-Hill Additional material 4/5 Lewis/Martin Aside: Booting the Computer How does it all begin? We have LC-3 hardware and a program, but what next? Initial state of computer All zeros (registers, memory, condition codes) Only mostly true Boot process Load boot code held in ROM (read-only memory) BIOS (basic input/output system) Loads operating system from disk (or other input device) Operating systems loads other programs Uses memory operations (loads, stores) Sets to beginning of program to run it Programs invoke O.S. using TRAP instructions 6- Aside: Copying BIOS into Memory clock 6 6 C + A in 6 by 6 bit ROM 6 D in D out A in WE 6 by 6 bit memory BIOS Main Memory Solving Problems using a Computer Methodologies for creating computer programs that perform a desired function Problem Solving How do we figure out what to tell the computer to do? Convert problem statement into algorithm (stepwise refinement) Convert algorithm into LC-3 machine instructions Debugging How do we figure out why it didn t work? Examining registers and memory, setting breakpoints, etc. Time spent on the first can reduce time spent on the second!

2 Stepwise Refinement Problem Statement Also known as systematic decomposition Start with problem statement: We wish to count the number of occurrences of a character in a file. The character in question is to be input from the keyboard; the result is to be displayed on the monitor. Because problem statements are written in English, they are sometimes ambiguous and/or incomplete Where is the data located? How big is it, or how do I know when I ve reached the end? How should final count be printed? A decimal number? If the character is a letter, should I count both upper-case and lower-case occurrences? Decompose task into a few simpler subtasks Decompose each subtask into smaller subtasks, and these into even smaller subtasks, etc... until you get to the machine instruction level How do you resolve these issues? Ask the person who wants the problem solved, or Make a decision and document it Three Basic Constructs Programming at the Instruction Level There are three basic ways to decompose a task: Advantage: can do anything General, powerful Task Disadvantage: can do anything Difficult to structure, modify, understand Mitigate disadvantages using structured programming Test condition Test condition Use familiar constructs (even at the instruction level) From Java/C/Pascal/Fortran/Basic Iteration (while loop, for loop) Conditional (if statement, switch/case statement) Sequential Conditional Iterative

3 Sequential Do to completion, then do to completion, etc. Conditional If condition is true, do ; else, do Get character input from keyboard file char = input? Count and print the occurrences of a character in a file Examine file and count the number of characters that match Test character. If match, increment counter. Count = Count + Print number to the screen Iterative Do over and over, as long as the test condition is true Problem Solving Skills Learn to convert problem statement into step-by-step description of subtasks Check each element of the file and count the characters that match. more chars to check? Check next char and count if matches. Like a puzzle, or a word problem from grammar school math What is the starting state of the system? What is the desired ending state? How do we move from one state to another? Recognize English words that correlate to three basic constructs: do A then do B sequential if G, then do H conditional for each X, do Y iterative do Z until W iterative

4 LC-3 Control Instructions Code for Conditional How can instructions encode these basic constructs? Sequential Instructions naturally flow from one to next, so no special instruction needed to go from one sequential subtask to next Test Condition Exact bits depend on condition being tested A B Instruction Generate Condition? C offset to address C Conditional and Iterative Create code that converts condition into N, Z, or P Condition: Is R = R? Code: Subtract R from R; if equal, Z bit will be set Use BR instruction to transfer control What about R < R? Code: Subtract R from R (R-R), if less, N bit will be set 6-3 Next Unconditional branch to Next C D D Next Assuming all addresses are close enough that -relative branch can be used offset to address D 6-4 Code for Iteration Test Condition Next Exact bits depend on condition being tested Unconditional branch to retest condition A B C Instruction Generate Condition? C A Next Assuming all addresses are close enough that -relative branch can be used offset to address C offset to address A 6-5 Example (from both Ch 5 and 6) Count the occurrences of a character in a file Program begins at location x3 Read character from keyboard Load each character from a file In this example the file is already in sequence of memory locations Starting address of file is stored in the memory location immediately after the program If file character equals input character, increment counter End of file is indicated by a special ASCII value: EOT (x4) At the end, print the number of characters and halt (assume there will be fewer than occurrences of the character) A special character used to indicate the end of a sequence is often called a sentinel Useful when you don t know ahead of time how many times to execute a loop 6-6 4

5 Example: Counting Characters START Refining B START A Initialize: Put initial values into all locations that will be needed to carry out this task. B Input a character. Then scan a file, counting occurrences of that character. Finally, display on the monitor the number of occurrences of the character (up to 9). STOP B - Input a character. - Set up a pointer to the first location of the file that will be scanned. - Get the first character from the file. - Zero the register that holds the count. Scan the file, location by location, incrementing the counter if the character matches. B Scan the file, location by location, incrementing the counter if the character matches. B Test character. If a match, increment counter. Get next character. Initial refinement: Big task into three sequential subtasks. C Display the count on the monitor. STOP 6-7 Refining B into iterative construct. 6-8 Refining B Refining B and B3 B B B Test character. If a match, increment counter. Get next character. B B Test character. If matches, increment counter. B3 Get next character. B B Test character. If matches, increment counter. B3 Get next character. R = R? R = R + B3 R3 = R3 + R = M[R3] Refining B into sequential subtasks. Conditional (B) and sequential (B3). Use of LC-3 registers and instructions

6 Entire Flow Chart Input: M[x3] (address of file ) Output: Print count to display Count = (R = ) Ptr = st file character (R3 = M[x3]) Input char from keybd (TRAP x3) Load char from file (R = M[R3]) Incr Count (R = R + ) (R?= EOT) Match? (R?= R) Load next char from file (R3 = R3 +, R = M[R3]) Convert count to ASCII character (R = x3, R = R + R) Print count (TRAP x) (TRAP x5) Translate to Pseudocode R (Count) R3 M[x3] (Ptr) Input to R (TRAP x3) Count = (R = ) Ptr = st file character (R3 = M[x3]) Input char from keybd (TRAP x3) Load char from file (R = M[R3]) Incr Count (R = R + ) (R?= EOT) Match? (R?= R) Load next char from file (R3 = R3 +, R = M[R3]) Convert count to ASCII character (R = x3, R = R + R) Print count (TRAP x) (TRAP x5) R4 R 4 (EOT) BRz x???? R T R R R + R R + R BRnp x????? R R + R3 R3 + BRnzp x???? R M[x33] R R + R Print R (TRAP x) (TRAP x5) 6-6- Iterative Construct in Pseudocode R (Count) R3 M[x3] (Ptr) Input to R (TRAP x3) Count = (R = ) Ptr = st file character (R3 = M[x3]) Input char from keybd (TRAP x3) Load char from file (R = M[R3]) Incr Count (R = R + ) (R?= EOT) Match? (R?= R) Load next char from file (R3 = R3 +, R = M[R3]) Convert count to ASCII character (R = x3, R = R + R) Print count (TRAP x) (TRAP x5) R4 R 4 (EOT) BRz x???? R T R R R + R R + R BRnp x????? R R + R3 R3 + BRnzp x???? R M[x33] R R + R Print R (TRAP x) (TRAP x5) Conditional in Pseudocode R (Count) R3 M[x3] (Ptr) Input to R (TRAP x3) Count = (R = ) Ptr = st file character (R3 = M[x3]) Input char from keybd (TRAP x3) Load char from file (R = M[R3]) Incr Count (R = R + ) (R?= EOT) Match? (R?= R) Load next char from file (R3 = R3 +, R = M[R3]) Convert count to ASCII character (R = x3, R = R + R) Print count (TRAP x) (TRAP x5) R4 R 4 (EOT) BRz x???? R T R R R + R R + R BRnp x???? R R + R3 R3 + BRnzp x???? R M[x33] R R + R Print R (TRAP x) (TRAP x5)

7 Final Pseudocode R (Count) R3 M[x3] (Ptr) Input to R (TRAP x3) Count = (R = ) Ptr = st file character (R3 = M[x3]) Input char from keybd (TRAP x3) Load char from file (R = M[R3]) Incr Count (R = R + ) (R?= EOT) Match? (R?= R) Load next char from file (R3 = R3 +, R = M[R3]) Convert count to ASCII character (R = x3, R = R + R) Print count (TRAP x) (TRAP x5) Don t know offset bits until all the code is done R4 R 4 (EOT) BRz x???? R T R R R + R R + R BRnp x???? R R + R3 R3 + BRnzp x???? R M[x33] R R + R Print R (TRAP x) (TRAP x5) 6-5 Translate Pseudocode ( of ) Address Instruction x3 x3 x3 x33 x34 x35 x36 X38 x39 BR ADD LD AND TRAP Comments R (counter) R3 M[x3] (ptr) Input to R (TRAP x3) R4 R 4 (EOT) BRz x3e R T R R R + R R + R BRnp x3b 6-6 BR Translate Pseudocode ( of ) Address Instruction x3a x3b x3c ADD LD AND TRAP Comments R R + R3 R3 + Structured Programming of LC-3 Summary Decompose task Top-down Specification often ambiguous Continual refinement of details x3d x3e x3f x3 x3 BRnzp x34 R M[x33] R R + R Print R (TRAP x) (TRAP x5) Write code Top-down or bottom-up Focus on one bite-sized part at a time Use structured programming (even at the instruction level) Translate flowchart to pseudo code then to machine code X3 x33 Starting Address of File ASCII x3 ( ) Continual testing and debugging of code

8 Debugging You ve written your program and it doesn t work w what? What do you do when you re lost in a city? Drive around randomly and hope you find it? Return to a known point and look at a map? In debugging, the equivalent to looking at a map is tracing your program Examine the sequence of instructions being executed Keep track of results being produced Compare result from each instruction to the expected result Debugging Operations Any debugging environment might provide means to:. Display values in memory and registers. Deposit values in memory and registers 3. Execute instruction sequence in a program 4. Stop execution when desired Different programming levels offer different tools High-level languages (C, Java,...) have source-code debugging tools For debugging at the machine instruction level: Simulators Operating system monitor tools Special hardware LC-3 Simulator Start Execution Command Line Mem/Reg Valus Stop Execution Types of Errors Syntax Errors Typing error that resulted in an illegal operation Machine language: not caught, because almost any bit pattern corresponds to some legal instruction High-level language: caught during the translation from language to machine code Logic Errors Program is legal, but wrong, so the results don t match the problem statement Trace the program to see what s really happening and determine how to get the proper behavior Data Errors Input data is different than what you expected Test the program with a wide variety of inputs

9 Tracing the Program Execute the program one piece at a time, examining register and memory to see results at each step Single-Stepping Execute one instruction at a time Tedious, but useful to help you verify each step of your program Breakpoints Tell the simulator to stop executing when it reaches a specific instruction Check overall results at specific points in the program Lets you quickly execute sequences to get a high-level overview of the execution behavior Quickly execute sequences that your believe are correct 6-33 Example : Multiply Goal: Multiply the two unsigned integers in R4 and R5, and place result in R clear R add R4 to R decrement R5 R5 =? x3 x3 x3 x33 x34 Set R4 =, R5 =3 Run program Result: R = 4, not 3 (R = x8, not xe) 6-34 Example : Multiply Goal: Multiply the two unsigned integers in R4 and R5, and place result in R clear R add R4 to R decrement R5 R5 =? x3 AND R,R,# x3 ADD R,R,R4 x3 ADD R5,R5,#- x33 BRzp x3 x34 Set R4 =, R5 =3 Run program Result: R = 4, not 3 (R = x8, not xe) 6-35 Debugging the Multiply Program and registers at the beginning of each instruction x3 x3 x3 x33 x3 x3 x33 x3 x3 x33 x3 x3 x33 x34 R R4 R Single-stepping Breakpoint at branch (x33) x33 x33 x33 x33 R R4 R5 Executing loop one time too many Branch at x33 should be based on Z bit only, not Z and P (change x7fd to x3fd) Should stop looping here! 9

10 Example : Summing an Array of Numbers Goal: Sum the numbers stored in memory locations beginning with x3, leaving the result in R R = R4 = R = x3 R = R + M[R] R = R + R4 = R4 - R4 =? x3 AND x3 AND x3 ADD x33 LD x34 LDR x35 ADD x36 ADD ADD x38 BRp x39 R,R,# R4,R4,# R4,R4,# R,x3 R3,R,# R,R,# R,R,R3 R4,R4,#- x Debugging the Summing Program Running the data below yields R = x4, but the sum should be x835. What happened? Address x3 x3 x3 x33 x34 x35 x36 x37 x38 x39 Contents x37 x89 x x3 x x xb x9 x7 x4 Start single-stepping program... x3 x3 x3 x33 x34 R R x37 R4 Should be x3! Loading contents of M[x3], not address Change opcode of x33 from (LD) to xe or (LEA) 6-38 Example 3: Looking for a 5 Scan ten memory locations starting at x3 If a 5 is found set R to, otherwise set R to R3 =? R = R =, R = -5, R3 = R4 = x3, R = M[R4] R = 5? R4 = R4 + R3 = R3- R = M[R4] x3 AND R,R,# x3 ADD R,R,# x3 AND R,R,# x33 ADD R,R,#-5 x34 AND R3,R3,# x35 ADD R3,R3,# x36 LD R4,x3 LDR R,R4,# x38 ADD R,R,R x39 BRz x3f x3a ADD R4,R4,# x3b ADD R3,R3,#- x3c LDR R,R4,# x3d BRp x38 x3e AND R,R,# x3f X3 x Debugging the Fives Program Running the program with a 5 in location x38 results is R =, not R =. What happened? Address x3 x3 x3 x33 x34 x35 x36 x37 x38 x39 Contents Perhaps we didn t look at all the data? Put a breakpoint at x3d to see how many times we branch back x3d x3d R R 7 3 R3 9 8 R4 x3 x3 x3d 7 x33 7 x33 Didn t branch back, even though R3 >? Branch uses condition code set by loading R with M[R4], not by decrementing R3. Swap x3b and x3c, or remove x3c and branch back to 6-4

11 Example 4: Finding First in a Word Goal: Return (in R) the bit position of the first in a word; address of word is in location x39 (just past the end of the program); if there are no ones, R should be set to R = 5 R = data R[5] =? decrement R shift R left one bit R[5] =? x3 AND R,R,# x3 ADD R,R,#5 x3 LDI R,x39 x33 BRn x38 x34 ADD R,R,#- x35 ADD R,R,R x36 BRn x38 BRnzp x34 x38 x39 x3 6-4 Shifting Left We often want to manipulate individual bits Example: is a number odd or even? Answer: R := R AND x If R is -> R was even If R is -> R was odd LC-3 doesn t give us an instruction to shift bits Most ISAs include shift left and shift right Example: If you shift left one place, results How do we shift left in LC-3? Multiple value by (why?) Same as R := R + R Example: + = Adding a value to itself shifts the bits left one place 6-4 Debugging the First-One Program Program works most of the time, but if data is zero, it never seems to Breakpoint at backwards branch () R R If no ones, then branch to never occurs! This is called an infinite loop. Must change algorithm to either (a) check for special case (R=), or (b) exit loop if R <. Debugging: Lessons Learned Trace program to see what s going on Breakpoints, single-stepping When tracing, make sure to notice what s really happening, not what you think should happen In summing program, it would be easy to not notice that address x37 was loaded instead of x3 Test your program using a variety of input data In Examples 3 and 4, the program works for many data sets Be sure to test extreme cases (all ones, no ones,...)

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

11/10/2016. Review the Problem to Be Solved. ECE 120: Introduction to Computing. What Shall We Keep in the Registers? Where Are the Pieces in Memory?

11/10/2016. Review the Problem to Be Solved. ECE 120: Introduction to Computing. What Shall We Keep in the Registers? Where Are the Pieces in Memory? University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Letter Frequency Coding Review the Problem to Be Solved The task: given an ASCII

More information

LC-3 Instruction Set Architecture

LC-3 Instruction Set Architecture CMPE12 Notes LC-3 Instruction Set Architecture (Textbookʼs Chapter 5 and 6)# Instruction Set Architecture# ISA is all of the programmer-visible components and operations of the computer.# memory organization#

More information

Introduction to Computer Engineering. Chapter 5 The LC-3. Instruction Set Architecture

Introduction to Computer Engineering. Chapter 5 The LC-3. Instruction Set Architecture Introduction to Computer Engineering CS/ECE 252, Spring 200 Prof. David A. Wood Computer Sciences Department University of Wisconsin Madison Chapter 5 The LC-3 Adapted from Prof. Mark Hill s slides Instruction

More information

Instruction Set Architecture

Instruction Set Architecture Chapter 5 The LC-3 Instruction Set Architecture ISA = All of the programmer-visible components and operations of the computer memory organization address space -- how may locations can be addressed? addressibility

More information

Chapter 5 The LC-3. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 5-2

Chapter 5 The LC-3. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 5-2 Chapter 5 The LC-3 ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 5-2 Instruction Set Architecture ISA = All of the programmer-visible components

More information

Chapter 5 - ISA. 1.The Von Neumann Model. The Stored Program Computer. Von Neumann Model. Memory

Chapter 5 - ISA. 1.The Von Neumann Model. The Stored Program Computer. Von Neumann Model. Memory Chapter 5 - ISA 1.The Von Neumann Model The Stored Program Computer 1943: ENIAC Presper Eckert and John Mauchly -- first general electronic computer. (or was it John V. Atanasoff in 1939?) Hard-wired program

More information

Computing Layers. Chapter 5 The LC-3

Computing Layers. Chapter 5 The LC-3 Computing Layers Problems Chapter 5 The LC-3 Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Algorithms Language Instruction

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 5 The LC-3 Instruction Set Architecture ISA = All of the

More information

LC-3 Instruction Set Architecture. Textbook Chapter 5

LC-3 Instruction Set Architecture. Textbook Chapter 5 LC-3 Instruction Set Architecture Textbook Chapter 5 Instruction set architecture What is an instruction set architecture (ISA)? It is all of the programmer-visible components and operations of the computer

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 5 The LC-3 Announcements Homework 3 due today No class on Monday

More information

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers Chapter 5 The LC-3 Original slides from Gregory Byrd, North Carolina State University Modified slides by C. Wilcox, S. Rajopadhye Colorado State University Computing Layers Problems Algorithms Language

More information

COSC121: Computer Systems: Review

COSC121: Computer Systems: Review COSC121: Computer Systems: Review Jeremy Bolton, PhD Assistant Teaching Professor Constructed using materials: - Patt and Patel Introduction to Computing Systems (2nd) - Patterson and Hennessy Computer

More information

EEL 5722C Field-Programmable Gate Array Design

EEL 5722C Field-Programmable Gate Array Design EEL 5722C Field-Programmable Gate Array Design Lecture 12: Pipelined Processor Design and Implementation Prof. Mingjie Lin Patt and Patel: Intro. to Computing System * Stanford EE271 notes 1 Instruction

More information

COSC121: Computer Systems: Review

COSC121: Computer Systems: Review COSC121: Computer Systems: Review Jeremy Bolton, PhD Assistant Teaching Professor Constructed using materials: - Patt and Patel Introduction to Computing Systems (2nd) - Patterson and Hennessy Computer

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

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

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

Computing Layers. Chapter 7 Assembly Language

Computing Layers. Chapter 7 Assembly Language Computing Layers Problems Chapter 7 Assembly Language Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Algorithms Language Instruction

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

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

Register Files. Single Bus Architecture. Register Files. Single Bus Processor. Term Project: using VHDL. Accumulator based architecture

Register Files. Single Bus Architecture. Register Files. Single Bus Processor. Term Project: using VHDL. Accumulator based architecture Register Files DR 3 SelS Design and simulate the LC-3 processor using VHDL Term Project: Single Processor Decoder... R R3 R6...... mux mux S S SelDR 3 DRin Clock 3 SelS LC-3 Architecture 3 Register File

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

Assembly Language. 7.1 Assembly Language Programming Moving Up o Level. chapter

Assembly Language. 7.1 Assembly Language Programming Moving Up o Level. chapter chapter 7 Assembly Language By now, you are probably a little tired of Is and Os and keeping track of 0001 meaning ADD and 1001 meaning NOT. Also, wouldn'titbe nice if we could refer to a memory location

More information

Load -- read data from memory to register. Store -- write data from register to memory. Load effective address -- compute address, save in register

Load -- read data from memory to register. Store -- write data from register to memory. Load effective address -- compute address, save in register Data Movement Instructions Load -- read data from memory to register LD: PC-relative mode LDR: base+offset mode LDI: indirect mode Store -- write data from register to memory ST: PC-relative mode STR:

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

Introduction to Computer. Chapter 5 The LC-3. Instruction Set Architecture

Introduction to Computer. Chapter 5 The LC-3. Instruction Set Architecture Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin Madison Chapter 5 The LC-3 Instruction Set Architecture

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

11/6/2016. Let s Solve a Problem. ECE 120: Introduction to Computing. Overview of Our Task. Programs are Finite State Machines

11/6/2016. Let s Solve a Problem. ECE 120: Introduction to Computing. Overview of Our Task. Programs are Finite State Machines University of Illinot Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Typing in a Number Let s Solve a Problem Let s see how we can translate a task in

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

Memory Usage in Programs

Memory Usage in Programs Memory Usage in Programs ECE2893 Lecture 4a ECE2893 Memory Usage in Programs Spring 2011 1 / 17 The Little Computer 3 (LC3) ECE2893 Memory Usage in Programs Spring 2011 2 / 17 The LC3 Instruction Set,

More information

Assembly Language. 7.1 Assembly Language Programming Moving Up o Level. chapter

Assembly Language. 7.1 Assembly Language Programming Moving Up o Level. chapter chapter 7 Assembly Language By now, you are probably a little tired of Is and Os and keeping track of 0001 meaning ADD and 1001 meaning NOT. Also, wouldn'titbe nice if we could refer to a memory location

More information

LC-3 ISA - II. Lecture Topics. Lecture materials. Homework. Machine problem. Announcements. ECE 190 Lecture 10 February 17, 2011

LC-3 ISA - II. Lecture Topics. Lecture materials. Homework. Machine problem. Announcements. ECE 190 Lecture 10 February 17, 2011 LC- ISA - II Lecture Topics LC- data movement instructions LC- control instructions LC- data path review Lecture materials Textbook 5. - 5.6 Textbook Appendix A. Homework HW due Wednesday February 2 at

More information

LC-3 Assembly Language

LC-3 Assembly Language Chapter 7 LC-3 Assembly Language CS Reality You ve got to know assembly Chances are, you ll never write program in assembly Compilers are much better & more patient than you are Understanding assembly

More information

Ch. 5: The LC-3. PC-Relative Addressing Mode. Data Movement Instructions. James Goodman!

Ch. 5: The LC-3. PC-Relative Addressing Mode. Data Movement Instructions. James Goodman! 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ADD + 0001 1 0 00 2 Computer Science 210 s1c Computer Systems 1 2012 Semester 1 Lecture Notes ADD + AND + AND + BR JMP 0001 1 1 imm5 0101 1 0 00 2 0101 1 1 imm5 0000

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

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

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

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON Prof. Mark D. Hill & Prof. Mikko H. Lipasti TAs Sanghamitra Roy, Eric Hill, Samuel Javner,

More information

ADD R3, R4, #5 LDR R3, R4, #5

ADD R3, R4, #5 LDR R3, R4, #5 ECE 109 Sections 602 to 605 Exam 2 Fall 2007 Solution 6 November, 2007 Problem 1 (15 points) Data Path In the table below, the columns correspond to two LC/3 instructions and the rows to the six phases

More information

Intro. to Computer Architecture Homework 4 CSE 240 Autumn 2005 DUE: Mon. 10 October 2005

Intro. to Computer Architecture Homework 4 CSE 240 Autumn 2005 DUE: Mon. 10 October 2005 Name: 1 Intro. to Computer Architecture Homework 4 CSE 24 Autumn 25 DUE: Mon. 1 October 25 Write your answers on these pages. Additional pages may be attached (with staple) if necessary. Please ensure

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

20/08/14. Computer Systems 1. Instruction Processing: FETCH. Instruction Processing: DECODE

20/08/14. Computer Systems 1. Instruction Processing: FETCH. Instruction Processing: DECODE Computer Science 210 Computer Systems 1 Lecture 11 The Instruction Cycle Ch. 5: The LC-3 ISA Credits: McGraw-Hill slides prepared by Gregory T. Byrd, North Carolina State University Instruction Processing:

More information

CIT 593: Intro to Computer Systems Homework #4: Assembly Language Due October 18, 2012, 4:30pm. Name

CIT 593: Intro to Computer Systems Homework #4: Assembly Language Due October 18, 2012, 4:30pm. Name CIT 593: Intro to Computer Systems Homework #4: Assembly Language Due October 18, 2012, 4:30pm Instructions You may print this document and write your answers here, or submit solutions on a separate piece

More information

CS 2461: Computer Architecture I

CS 2461: Computer Architecture I Computer Architecture is... CS 2461: Computer Architecture I Instructor: Prof. Bhagi Narahari Dept. of Computer Science Course URL: www.seas.gwu.edu/~bhagiweb/cs2461/ Instruction Set Architecture Organization

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

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 8 & 9.1 I/O and Traps Aside Off-Topic: Memory Hierarchy 8-3

More information

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Mikko Lipasti & Prof. Gurindar S. Sohi TAs: Felix Loh, Daniel Chang, Philip Garcia, Sean Franey, Vignyan Kothinti

More information

Homework 06. Push Z Push Y Pop Y Push X Pop X Push W Push V Pop V Push U Pop U Pop W Pop Z Push T Push S

Homework 06. Push Z Push Y Pop Y Push X Pop X Push W Push V Pop V Push U Pop U Pop W Pop Z Push T Push S Homework 06 1. How many TRAP service routines can be implemented in the LC-3? Why? Since the trap vector is 8 bits wide, 256 trap routines can be implemented in the LC-3. Why must a instruction be used

More information

Chapter 10 And, Finally... The Stack

Chapter 10 And, Finally... The Stack Chapter 10 And, Finally... The Stack Memory Usage Instructions are stored in code segment Global data is stored in data segment Local variables, including arryas, uses stack Dynamically allocated memory

More information

Chapter 13 Control Structures

Chapter 13 Control Structures Chapter 13 Control Structures Control Structures Conditional making a decision about which code to execute, based on evaluated expression if if-else switch Iteration executing code multiple times, ending

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

10/31/2016. The LC-3 ISA Has Three Kinds of Opcodes. ECE 120: Introduction to Computing. ADD and AND Have Two Addressing Modes

10/31/2016. The LC-3 ISA Has Three Kinds of Opcodes. ECE 120: Introduction to Computing. ADD and AND Have Two Addressing Modes University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing The LC-3 Instruction Set Architecture The LC-3 ISA Has Three Kinds of Opcodes

More information

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

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi, Kai Zhao TAs: Yuzhe Ma, Annie Lin, Mohit Verma, Neha Mittal, Daniel Griffin, Examination 4 In Class

More information

University of Illinois at Urbana-Champaign First Midterm Exam, ECE 220 Honors Section

University of Illinois at Urbana-Champaign First Midterm Exam, ECE 220 Honors Section University of Illinois at Urbana-Champaign First Midterm Exam, ECE 220 Honors Section Name: SOLUTION IS IN RED Thursday 15 February 2018 Net ID: Be sure that your exam booklet has ELEVEN pages. Write your

More information

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof Mark D. Hill and Prof. Gurindar Sohi TAs: Rebecca Lam, Mona Jalal, Preeti Agarwal, Pradip Vallathol Midterm Examination

More information

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Mohit Verma, Annie Lin

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Mohit Verma, Annie Lin CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Instructor: Rahul Nayar TAs: Mohit Verma, Annie Lin Examination 4 In Class (50 minutes) Wednesday, May 3rd, 2017 Weight:

More information

Chapter 8 I/O. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. But where does data in memory come from?

Chapter 8 I/O. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. But where does data in memory come from? Chapter 8 I/O I/O: Connecting to Outside World So far, we ve learned how to: compute with values in registers load data from memory to registers store data from registers to memory But where does data

More information

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Junaid Khalid and Pradip Vallathol Midterm Examination 3 In Class (50 minutes) Friday, November

More information

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Professor Guri Sohi TAs: Newsha Ardalani and Rebecca Lam Examination 4 In Class (50 minutes) Wednesday, Dec 14, 2011 Weight:

More information

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Professor Karthikeyan Sankaralingam TAs: Kamlesh Prakash, Suriyha Balaram Sankari, Rebecca Lam, Newsha Ardalani, and Yinggang

More information

Problem Solving in C. Stepwise Refinement. ...but can stop refining at a higher level of abstraction. Same basic constructs. as covered in Chapter 6

Problem Solving in C. Stepwise Refinement. ...but can stop refining at a higher level of abstraction. Same basic constructs. as covered in Chapter 6 Problem Solving in C Stepwise Refinement as covered in Chapter 6...but can stop refining at a higher level of abstraction. Same basic constructs Sequential -- C statements Conditional -- if-else, switch

More information

The LC-3 Instruction Set Architecture. ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path

The LC-3 Instruction Set Architecture. ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path Chapter 5 The LC-3 Instruction Set Architecture ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path A specific ISA: The LC-3 We have: Reviewed data encoding

More information

Assembly: Review. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 14

Assembly: Review. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 14 Assembly: Review Computer Science and Engineering College of Engineering The Ohio State University Lecture 14 Definition Recall: Translation A source program is translated into a target program Each language

More information

Chapter 13. Control Structures

Chapter 13. Control Structures Chapter 13 Control Structures Control Structures Conditional making a decision about which code to execute, based on evaluated expression if if-else switch Iteration executing code multiple times, ending

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

Chapter 12 Variables and Operators

Chapter 12 Variables and Operators Chapter 12 Variables and Operators Basic C Elements Variables Named, typed data items Operators Predefined actions performed on data items Combined with variables to form expressions, statements Statements

More information

CIT 595 Spring System Software: Programming Tools. Assembly Process Example: First Pass. Assembly Process Example: Second Pass.

CIT 595 Spring System Software: Programming Tools. Assembly Process Example: First Pass. Assembly Process Example: Second Pass. System Software: Programming Tools Programming tools carry out the mechanics of software creation within the confines of the operating system and hardware environment Linkers & Loaders CIT 595 Spring 2010

More information

Review Topics. Midterm Exam Review Slides

Review Topics. Midterm Exam Review Slides Review Topics Midterm Exam Review Slides Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University!! Computer Arithmetic!! Combinational

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

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 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

Review Topics. Midterm Exam Review Slides

Review Topics. Midterm Exam Review Slides Review Topics Midterm Exam Review Slides Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Computer Arithmetic Combinational

More information

11/16/2016. Review Our Process for Programming. ECE 120: Introduction to Computing. A Typical Programming Process. Can a Computer Help Us Program?

11/16/2016. Review Our Process for Programming. ECE 120: Introduction to Computing. A Typical Programming Process. Can a Computer Help Us Program? University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing Assembly Language Review Our Process for Programming Step 1: Figure out the instruction

More information

UNIVERSITY OF WISCONSIN MADISON

UNIVERSITY OF WISCONSIN MADISON CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Sujith Surendran, Lisa Ossian, Minsub Shin Midterm Examination 4 In Class (50 minutes) Wednesday,

More information

Chapter 13 Control Structures

Chapter 13 Control Structures Chapter 13 Control Structures Highlights Sequence action_1 action_2 Conditional Iteration 13-2 Control Structures Conditional making a decision about which code to execute, based on evaluated expression

More information

Control Structures II. Repetition (Loops)

Control Structures II. Repetition (Loops) Control Structures II Repetition (Loops) Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1 to 100 The answer will be 1 + 2 + 3 + 4 + 5 + 6 + +

More information

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

Introduction to Computer Engineering. CS/ECE 252, Fall 2012 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison Introduction to Computer Engineering CS/ECE 252, Fall 2012 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison Chapter 8 & 9.1 I/O and Traps I/O: Connecting to Outside World So

More information

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/ CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference

More information

Lab 1. Warm-up : discovering the target machine, LC-3

Lab 1. Warm-up : discovering the target machine, LC-3 Lab 1 Warm-up : discovering the target machine, LC-3 Credits This sequence of compilation labs has been inspired by those designed by C. Alias and G. Iooss in 2013/14. In 2016/17 we changed the support

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

CPSC 213. Introduction to Computer Systems. Static Scalars and Arrays. Unit 1b

CPSC 213. Introduction to Computer Systems. Static Scalars and Arrays. Unit 1b CPSC 213 Introduction to Computer Systems Unit 1b Static Scalars and Arrays 1 Reading for Next 3 Lectures Companion 2.4.1-2.4.3 Textbook Array Allocation and Access 3.8 2 The Big Picture Build machine

More information

The MARIE Architecture

The MARIE Architecture The MARIE Machine Architecture that is Really Intuitive and Easy. We now define the ISA (Instruction Set Architecture) of the MARIE. This forms the functional specifications for the CPU. Basic specifications

More information

Guide to Using the Unix version of the LC-2 Simulator

Guide to Using the Unix version of the LC-2 Simulator Guide to Using the Unix version of the LC-2 Simulator by Kathy Buchheit The University of Texas at Austin copyright, Kathy Buchheit January 2001 Guide to Using the Unix version of the LC-2 Simulator The

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

More information

CS 241 Data Organization Binary

CS 241 Data Organization Binary CS 241 Data Organization Binary Brooke Chenoweth University of New Mexico Fall 2017 Combinations and Permutations In English we use the word combination loosely, without thinking if the order of things

More information

Implementing Functions at the Machine Level

Implementing Functions at the Machine Level Subroutines/Functions Implementing Functions at the Machine Level A subroutine is a program fragment that... Resides in user space (i.e, not in OS) Performs a well-defined task Is invoked (called) by a

More information

LC-3 Assembly Language. (Textbook Chapter 7)"

LC-3 Assembly Language. (Textbook Chapter 7) 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

More information

Computer Systems Architecture I. CSE 560M Lecture 3 Prof. Patrick Crowley

Computer Systems Architecture I. CSE 560M Lecture 3 Prof. Patrick Crowley Computer Systems Architecture I CSE 560M Lecture 3 Prof. Patrick Crowley Plan for Today Announcements Readings are extremely important! No class meeting next Monday Questions Commentaries A few remaining

More information

2.2 THE MARIE Instruction Set Architecture

2.2 THE MARIE Instruction Set Architecture 2.2 THE MARIE Instruction Set Architecture MARIE has a very simple, yet powerful, instruction set. The instruction set architecture (ISA) of a machine specifies the instructions that the computer can perform

More information

Outline. Program development cycle. Algorithms development and representation. Examples.

Outline. Program development cycle. Algorithms development and representation. Examples. Outline Program development cycle. Algorithms development and representation. Examples. 1 Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding).

More information

ECE 411 Exam 1. This exam has 5 problems. Make sure you have a complete exam before you begin.

ECE 411 Exam 1. This exam has 5 problems. Make sure you have a complete exam before you begin. This exam has 5 problems. Make sure you have a complete exam before you begin. Write your name on every page in case pages become separated during grading. You will have three hours to complete this exam.

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

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar S. Sohi TAs: Newsha Ardalani and Rebecca Lam Midterm Eamination 3 In Class (5 minutes) Friday, November 8,

More information

CHAPTER 2 PROBLEM SOLVING TECHNIQUES. Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042

CHAPTER 2 PROBLEM SOLVING TECHNIQUES. Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042 CHAPTER 2 PROBLEM SOLVING TECHNIQUES Mr Mohd Hatta Bin Hj Mohamed Ali Computer Programming BFC2042 Software Engineering vs Problem Solving Software Engineering - A branch of Computer Science & provides

More information

are Softw Instruction Set Architecture Microarchitecture are rdw

are Softw Instruction Set Architecture Microarchitecture are rdw Program, Application Software Programming Language Compiler/Interpreter Operating System Instruction Set Architecture Hardware Microarchitecture Digital Logic Devices (transistors, etc.) Solid-State Physics

More information

1/17/2018. Task: Print a Number in Binary. ECE 220: Computer Systems & Programming. First Step: Break the Task into a Sequence of Two

1/17/2018. Task: Print a Number in Binary. ECE 220: Computer Systems & Programming. First Step: Break the Task into a Sequence of Two University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming LC-3 I/O Usage Example Task: Print a Number in Binary Let s write some code

More information

9/23/2013. Chapter 2. Objectives. Introduction. Objectives (continued) Representing Algorithms. Representing Algorithms

9/23/2013. Chapter 2. Objectives. Introduction. Objectives (continued) Representing Algorithms. Representing Algorithms Chapter 2 The Algorithmic Foundations of Computer Science Objectives After studying this chapter, students will be able to: Explain the benefits of pseudocode over natural language or a programming language

More information