Midterm1_Slides

Midterm1_Slides

HKN ECE 220: Spring 2018 Midterm 1 Eric Roch, Hyun Soo Chung, Mrigank Bhardwaj, Vyom Thakkar 10 February, 2018 Pseudo-Ops .ORIG ;;the first instruction should be at x3000 x3000 ;;indicate this is the end of the program .END #-3 ;;#-3, #5, #0, xFFC0, xABCD, etc.

.FILL ;;how many memory location you want to .BLKW#3 put World! ;;Null-terminated .STRINGZ Hello, TRAP x25 ;;same as HALT Examples How to clear R0? AND R0, R0, #0

How to do copy R1 to R0? ADD R0, R1, #0 ;;remember: and <= 15 How to get R0? NOT R0, R0 ADD R0, R0, #1 -16 <= immediate value LC-3 Review: I/O I/O Interactions

Polling vs Interrupts Polling Loop indefinitely until data is available by checking status registers (KBSR, DSR) Interrupts

Allows program to perform other work while no data is available Upon reception of interrupt, pause current code execution and execute special interrupt handling functions Return to interrupted code once interrupt has been handled Will be covered in depth in ECE 391! LC-3 Review: I/O Memory Mapped I/O Map I/O to specific memory addresses Removes the need for dedicated I/O channels Accessing the mapped memory address gives access to the input or output device

Reading from xFE02 (KBDR) returns a char of what key was pressed on the keyboard Writing a to xFE06 (DDR) will display a on the display Check the status register (KBSR, DSR) of the respective input/output before reading or writing LC-3 Review: Keyboard Input Reading from the keyboard Poll KBSR until ready bit is set then access input data stored in lower 8 bits of KBDR

POLL LDI BRzp LDI R1, KBSR POLL R0, KBDR ; Check status register

; Loop while ready bit not set ; Get keyboard input KBSR .FILL xFE00 ; KBSR address KBDR

.FILL xFE02 ; KBDR address LC-3 Review: Display Output Writing to the display Poll DSR until ready bit is set then write display data to DDR POLL

LDI BRzp STI R1, DSR POLL R0, DDR ; Check status register ; Loop while ready bit not set ; Write display data DSR

.FILL xFE04 ; DSR address DDR .FILL xFE06

; DDR address TRAPS TRAP function Passes control to operating system Programmers can use complex operations without specialized knowledge TRAPS: How they work TRAP function is called by the user The 8-bit trap vector is used as the index of the service routines address in the trap vector table

- the table is stored in memory at 0x0000 0x00FF The PC is loaded with the address of the service routine After executing the service routine, control returns to the user program MAR <- ZEXT(trapvector) MDR <- MEM[MAR] R7 <- PC PC <- MDR Subroutines Similar to service routines but not part of the OS Useful if there is a code segment that needs to be executed multiple times Subroutines can be invoked by JSR or JSRR

Return is implemented with RET instruction TEMP <- PC If(IR[11] == 0) -PC

- R7 would need to be saved since JSR and JSRR overwrite its value Stacks Last-In-First-Out (LIFO) Stack operations Push: puts a new thing on top of the stack Pop: removes whatever is on the top of the stack IsEmpty: checks if the stack is empty IsFull: checks if the stack is full Example: Stacks(continued) Implementation

Keep elements stationary, just move the pointer More efficient than moving everything Example: Calculator Questions? Practice Questions Assuming 3 items have been pushed onto the stack. After a POP operation, will the last item pushed onto the stack be erased from memory? Explain. Is polling I/O is more efficient than interruptdriven I/O? Explain.

In LC-3, what is the benefit of using a subroutine? Explain what is a stack underflow. The input stream of a stack is a list of all the elements we pushed onto the stack, in the order that we pushed them. If the input stream is ZYXWVUTSR, create a sequence of pushes and pops such that the output stream is YXVUWZSRT.

IMPLEMENTING EUCLIDEAN ALGORITHM IN LC3 (GOOD CODING PRACTICE) -Reasonably fast algorithm for computing greatest common divisor of any two numbers. -Implement Modulo Subroutine, similar to the structure of subroutines implemented in MP2 (Stack Calculator) - General Algorithm: How many instructions, in terms of R1, are run in this program? LD R0, OP1 LD R2, OP2 ADD R1, R0, #0

TOP: ADD R2, R2, R0 ADD R1, R1, #-1 BRp TOP HALT OP1: .FILL #SOME_NUMBER OP2: .FILL #10 Tips .asm (PASS 1) : a symbol table is created (PASS2): .obj (the excutable)

Use LABELS Use semicolon to comment BR = BRnzp Draw a flow chart if necessary Try to remember what kind of numbers are in the registers that you are using. Write them down when calculation gets complicated. Assign different registers to specific functionality when the task is complex (R1 for row count, R2 for column count, etc) Make register table. Its extremely useful. R7 should not be changed. Ever!!! Dont get frustrated, breathe and start over.

Recently Viewed Presentations

  • All About Interfaces Jessica Sands, User Group 2011

    All About Interfaces Jessica Sands, User Group 2011

    If importing graphics, use the "Set transparent color" tool to make the white background disappear (to avoid covering text). Recommended graphic placement: along right side or bottom of slide Data Flow Between the Data Warehouse and Other Systems
  • Title of Presentation - University of Michigan

    Title of Presentation - University of Michigan

    Statewide Resources in Michigan MeL Databases - Gale LegalForms & LegalTrac Gale LegalForms - Provides copies of legal forms and documents in Word format on business, personal or litigation purposes. Also includes many Michigan documents. LegalTrac - Provides access to...
  • Introduction to health economics modelling

    Introduction to health economics modelling

    A decision model…. has a structure to represent clinical pathways. allows synthesis of evidence to estimate costs and effectiveness. weighs up risks and benefits of an intervention. can allow events occurring over time. allows an assessment of different types of...
  • Man Welding Understanding Arrows: Know Your Welding Symbols!

    Man Welding Understanding Arrows: Know Your Welding Symbols!

    Goudy Old Style Arial Calibri Rockwell Impact Inkwell 1_Inkwell 2_Inkwell 3_Inkwell 4_Inkwell 5_Inkwell 6_Inkwell 7_Inkwell 8_Inkwell 9_Inkwell 10_Inkwell 11_Inkwell 12_Inkwell Understanding Arrows: Know Your Welding Symbols!
  • Chapter 1 Uses of Accounting Information and the Basic ...

    Chapter 1 Uses of Accounting Information and the Basic ...

    Job Order Costing in a Service Organization OBJECTIVE 5 Apply job order costing to a service organization. Job Order Costing in Service Organizations Job order cost cards for service organizations can be modified to suit their needs, and to determine...
  • Executive Order 13508 Final Strategy Overview

    Executive Order 13508 Final Strategy Overview

    The 2011 Chesapeake Bay Blue Crab Stock Assessment was released by NOAA and was used by the states to establish a new adult, female-specific, blue crab abundance target of 215 million female crabs for the bay. The new target will...
  • Réz, arany, ezüst, higany

    Réz, arany, ezüst, higany

    Copper, gold, silver, mercury
  • BHASVIC MTHS A1 DOUBLES ASSIGNMENT 1B Skills 1

    BHASVIC MTHS A1 DOUBLES ASSIGNMENT 1B Skills 1

    This is a suvat table. Only model a situation with a suvat table if acceleration is . constant. s = displacement in metres, u = initial velocity in metres per second, v = final velocity in metres per second, a...