Introduction to Computer Engineering

Slides:



Advertisements
Similar presentations
Chapter 7 Introduction to LC-3 Assembly Language Assembly Language Assembly Process Using the Editor & Simulator for Assembly Language Programming.
Advertisements

Introduction to Computer Engineering ECE 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin –
1 System Calls (TRAPS) and Subroutines Patt and Patel Ch. 9.
Chapter 9 TRAP Routines and Subroutines. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9-2 Subroutines.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
LC-3 Assembly Language Programming Examples
Chapter 9 Overview Traps mechanism & RET Subroutines & JSR & JSRR & RET Interrupt mechanism & RTI.
Chapter 6 Programming in Machine Language The LC-3 Simulator
Chapter 9 TRAP Routines and Subroutines. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 9-2 System Calls.
Overview Projects The Assembly Process Programmed I/O Interrupt Driven I/O.
Chapter 8 Overview Programmed I/O Introduction to Interrupt Driven I/O Project 3.
Chapter 8 I/O Programming Chapter 9 Trap Service Routines Programmed I/O Interrupts Interrupt Driven I/O Trap Service Routines.
Introduction to Computing Systems and Programming Assembly Language.
The LC-3 – Chapter 7 COMP 2620 Dr. James Money COMP
Chapter 7 Assembly Language. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Our Bag of Tricks so far Control.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Chapter 9 Chapter 9 Subroutines and TRAPs l Privileged Instructions l TRAP Routines l Subroutines.
Chapter 9 TRAP Routines and Subroutines. 9-2 System Calls Certain operations require specialized knowledge and protection: specific knowledge of I/O device.
Introduction to Computing Systems and Programming Programming.
Computer Science 210 Computer Organization
Chapter 8 I/O.
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 & 9.2 Assembly Language
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
COSC121: Computer Systems: LC3 Traps and Subroutines
Chapter 7 Assembly Language
Computer Science 210 Computer Organization
Chapter 8 I/O.
Chapter 9 TRAP Routines and Subroutines
LC-3 Details and Examples
Chapter 8 I/O.
Chapter 7 LC-2 Assembly Language.
Computer Science 210 Computer Organization
Introduction to Computer Engineering
Chapter 9 TRAP Routines and Subroutines
Introduction to Computer Engineering
Computer Science 210 Computer Organization
Chapter 7 Assembly Language
Introduction to Computer Engineering
Chapter 9 TRAP Routines and Subroutines
TRAP Routines Subroutines Privileged Instructions
Chapter 9 TRAP Routines and Subroutines
Chapter 8 I/O.
Chapter 7 LC-2 Assembly Language.
Introduction to Computer Engineering
COSC121: Computer Systems
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Chapter 7 Assembly Language
TRAP Routines Privileged Instructions Subroutines
Chapter 9 TRAP Routines and Subroutines
Chapter 8 I/O.
Introduction to Computer Engineering
Chapter 7 Assembly Language An Hong 2016 Fall
Chapter 9 TRAP Routines and Subroutines
Chapter 9 TRAP Routines and Subroutines
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Introduction to Computer Engineering
Chapter 6 Programming.
Introduction to Computer Engineering
Chapter 7 Assembly Language
Chapter 9 TRAP Routines and Subroutines
Presentation transcript:

Introduction to Computer Engineering CS/ECE 252, Fall 2016 Kai Zhao Computer Sciences Department University of Wisconsin – Madison

Releasing Untested Software Boss pressuring you to release software Every day delay is $1 million in sales Is it okay to release software not fully tested? What if it’s a medical device? A number of patients receive up to 100x the intended dose of radiation therapy in 1985-1987. 3 died as a direct results and 21 died the following years A number of patients receive up to 100x the intended dose of radiation therapy in 1985-1987.

Ethics Wrapup Laws Ethics Discussion Set of rules with civil and/or criminal penalties can be enforced by governmental bodies Ethics Set of standards, usually voluntary Discussion Usually, no clear right and wrong Choose between competing interests

Recap Story behind Quote of the Day Quote of the Day: “It is a good thing for an uneducated man to read books of quotations.” -- Sir Winston Churchill 1874 - 1965

Chapter 1: Abstraction and Complexity Abstraction helps us manage complexity Complex interfaces Specify what to do Hide details of how Application Program CS302 Operating System CS537 Compiler CS536 Machine Language (ISA) CS/ECE354 Goal: Use abstractions yet still understand details Computer Architecture CS/ECE552 Scope of this course Digital Design CS/ECE352 Electronic circuits ECE340

Chapter 2: Number Representation 2’s complement representation -23 22 21 20 1 2 3 4 5 6 7 -23 22 21 20 1 -8 -7 -6 -5 -4 -3 -2 -1

Chapter 2: Hexadecimal and Operations Hexadecimal table Addition Binary Hex Decimal Unsigned 2’s complement 1000 8 -8 1001 9 -7 1010 A 10 -6 1011 B 11 -5 1100 C 12 -4 1101 D 13 -3 1110 E 14 -2 1111 F 15 -1 Binary Hex Decimal 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 01101000 (104) 11110110 (-10) + 11110000 (-16) + (-9) 01011000 (98) (-19)

Chapter 3: Transistor Gate Supply Voltage Output P-type transistor Ground N-type transistor Gate Behavior 1 Closed Output=0 Open Output=Z Gate Behavior Closed Output=1 1 Open Output=Z

Chapter 3: Building logic gates from transistors NOR gate A B C 1

Chapter 3: implementing truth tables w/ logic gates D 1 1. AND combinations that yield a "1" in the truth table. 2. OR the results of the AND gates.

Chapter 3: Memory R is used to “reset” or “clear” the element – set it to zero. S is used to “set” the element – set it to one. If both R and S are one, out could be either zero or one. “quiescent” state -- holds its previous value note: if a is 1, b is 0, and vice versa 1 1 1 1 1 1 1 out out 1 1

Chapter 3: Finite State Machine A description of a system with the following components: A finite number of states A finite number of external inputs A finite number of external outputs An explicit specification of all state transitions An explicit specification of what causes each external output value.

Chapter 4: Von Neumann Model

Chapter 5: LC-3 ISA

Chapter 6: Programming via Iterative Refinement Decompose task into a few simpler subtasks. There are three basic ways to decompose a task:

Chapter 6: Debug by Tracing execute instruction sequences set/display registers set/display memory set breakpoints

Chap7: Char Count in Assembly Language (1 of 3) ; ; Program to count occurrences of a character in a file. ; Character to be input from the keyboard. ; Result to be displayed on the monitor. ; Program only works if no more than 9 occurrences are found. ; Initialization .ORIG x3000 AND R2, R2, #0 ; R2 is counter, initially 0 LD R3, PTR ; R3 is pointer to characters GETC ; R0 gets character input LDR R1, R3, #0 ; R1 gets first character ; Test character for end of file TEST ADD R4, R1, #-4 ; Test for EOT (ASCII x04) BRz OUTPUT ; If done, prepare the output

Chap7: Char Count in Assembly Language (2 of 3) ; ; Test character for match. If a match, increment count. NOT R1, R1 ADD R1, R1, R0 ; If match, R1 = xFFFF NOT R1, R1 ; If match, R1 = x0000 BRnp GETCHAR ; If no match, do not increment ADD R2, R2, #1 ; Get next character from file. GETCHAR ADD R3, R3, #1 ; Point to next character. LDR R1, R3, #0 ; R1 gets next char to test BRnzp TEST ; Output the count. OUTPUT LD R0, ASCII ; Load the ASCII template ADD R0, R0, R2 ; Covert binary count to ASCII OUT ; ASCII code in R0 is displayed. HALT ; Halt machine Do comparison by adding not

Chapter 9.2 Subroutines ; CountChar: subroutine to count occurrences of a char CountChar ST R3, CCR3 ; save registers ST R4, CCR4 ST R7, CCR7 ; JSR alters R7 ST R1, CCR1 ; save original string ptr AND R4, R4, #0 ; initialize count to zero CC1 JSR FirstChar ; find next occurrence (ptr in R2) LDR R3, R2, #0 ; see if char or null BRz CC2 ; if null, no more chars ADD R4, R4, #1 ; increment count ADD R1, R2, #1 ; point to next char in string BRnzp CC1 CC2 ADD R2, R4, #0 ; move return val (count) to R2 LD R3, CCR3 ; restore regs LD R4, CCR4 LD R1, CCR1 LD R7, CCR7 RET ; and return

Chapter 8: I/O CPU Control/Status Registers Data Registers CPU tells device what to do -- write to control register CPU checks whether task is done -- read status register Data Registers CPU transfers data to/from device Device electronics performs actual operation pixels to screen, bits to/from disk, characters from keyboard Graphics Controller Control/Status CPU Electronics display Output Data

Chapter 9.1 TRAPs Code Equivalent Description HALT TRAP x25 Halt execution and print message to console. IN TRAP x23 Print prompt on console, read (and echo) one character from keybd. Character stored in R0[7:0]. OUT TRAP x21 Write one character (in R0[7:0]) to console. GETC TRAP x20 Read one character from keyboard. Character stored in R0[7:0]. PUTS TRAP x22 Write null-terminated string to console. Address of string is in R0.