DOC PREVIEW
UIUC ECE 190 - Programming Studio 5

This preview shows page 1-2-3-4 out of 12 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Programming Studio #5ECE 190Thursday, February 18, 2010Programming Studio #5• Topics this week:• LC-3 Assembly• I/O• Strings• In Studio Assignment– Lookup tables in LC3-b assemblerThursday, February 18, 2010Announcements• Exam 1 – Thurs 2/25 – 7pm-9pm– Location: ASL 131 & 150, WOHLR 141– Review Session: Mon Feb 22 6-8pm, EL 151– HKN Review: Tue Feb 23 6-8pm, MSEB 100• Conflict Exam - Mon 2/22 6-8pm EL 165Thursday, February 18, 2010Exam 1 Topics•Binary•Logic•Memory•Von Neumann Model•LC3 ISA•Systematic Decomposition•Assembly•MP1/MP2•Debugging•Code OptimizationThursday, February 18, 2010LC-3 Assembly• Write out code in plain language– No need to encode into binary• Symbols make programming easier– Use a label to specify an address– Specify an immediate in decimal or hex• What is loaded into R0 in each example?LD R0, x3VAL0 .FILL x25F3VAL1 .FILL xF5D6VAL3 .FILL x0000VAL4 .FILL x1234 LD R0, VAL4VAL0 .FILL x25F3VAL1 .FILL xF5D6VAL3 .FILL x0000VAL4 .FILL x1234 LD R0, #3VAL0 .FILL x25F3VAL1 .FILL xF5D6VAL3 .FILL x0000VAL4 .FILL x1234 Thursday, February 18, 2010Example: Multiplication• The example from last week in AssemblyBinary0011 0000 0000 00000101 010 010 1 000000010 100 0 1111 11100010 101 0 1111 11100001 010 010 0 00 1000001 101 101 1 111110000 001 1 1111 11010011 010 0 1111 10111111 0000 0010 0101Assembly.ORIG x3000 AND R2, R2, #0 LD R4, INPUT0 LD R5, INPUT1LOOP ADD R2, R2, R4 ADD R5, R5, #-1 BRp LOOP ST R2, RESULT TRAP x25INPUT0 x0003INPUT1 x000ARESULT x0000.ENDComment; Initialize; Load INPUT0; Load INPUT1; Add to running sum; Decrement counter; Check if counter == 0; Store result in RESULT; HaltThursday, February 18, 2010I/O• I/O is used for sending and receiving messages from the user• Use memory locations to represent display and keyboard– Both also contain status registers to indicate when they are ready to write/readThursday, February 18, 2010Example: Echo• We want to create a program that will display the keyboard key being pressedRead in a keyboard keyDisplay character to screen• What is missing?Thursday, February 18, 2010Echo DecompositionStore input to registerWrite character to displayHas key been pressed?Is display ready?NoNoYesYesThursday, February 18, 2010Echo AssemblySTART LDI R1, KBSR ; Test for character input BRzp START LDI R0, KBDR ; R0 = Keyboard character ECHO LDI R1, DSR ; Test output register ready BRzp ECHO STI R0, DDR ; Send R0 to display BRnzp START KBSR .FILL xFE00 ; Address of KBSR KBDR .FILL xFE02 ; Address of KBDR DSR .FILL xFE04 ; Address of DSR DDR .FILL xFE06 ; Address of DDR • Download file from ECE 190 website• lc3as echo.asm• lc3sim-tk echo.objThursday, February 18, 2010Strings• A string is a sequence of ASCII characters represented by hex numbers– Digits 0-9: x30 – x39– Lowercase Letters a-z: x61 – x7A– Uppercase Letters A-Z: x41 - x5A• Each string terminates with a null character (x0000)• .STRINGZ is used to specify a stringThursday, February 18, 2010In-studio Assignment• Assignment: Write a program to compute f(x), where f is stored in a lookup table – Assume 1:1 mapping between lookup table and function entries– Input: 16 bit integer x at x4000– Output: 16 bit integer f(x) at x4001– Fill the lookup table with: .STRINGZ “this is function data” after your halt instruction: f(x) is defined in range [0, 21)• Write a system decomposition before codingThursday, February 18,


View Full Document
Download Programming Studio 5
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Programming Studio 5 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Programming Studio 5 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?