lecture_09 - ECE 190 Lecture 09 September 20, 2011 LC-3...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 190 Lecture 09 September 20, 2011 1 V. Kindratenko LC-3 Assembly language Lecture Topics LC-3 assembly language Example program written in LC-3 assembly language The assembly process Lecture materials Textbook Ch. 7 Homework/Projects MP1 is due this Wednesday Announcements Exam 1 is this upcoming Mon, Sept. 26 , 7-9:30pm It is designed to be a <90 minutes exam for a well-prepared student We give you up to 2.5 hours to complete it Let us know if you have a conflict by next Wednesday via a quiz on Compass Check https://wiki.engr.illinois.edu/display/ece190/Exams for updates Exams from prior years are posted here as well Exam topics include everything covered in lectures 1-9
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 190 Lecture 09 September 20, 2011 2 V. Kindratenko LC-3 assembly language LC-3 assembly language is a low-level language specifically invented for LC-3 computer o It is machine-specific; different processors have different assembly languages o Each assembly language instruction corresponds to a single ISA instruction Assembly language makes it much easier to program by using human-readable language instead of binary words, while still providing the programmer with the fine-grain control over the instructions and data Assembly language allows to refer to instructions , memory locations , and values symbolically . Program from last lecture, but now in LC-3 Assembly language ; Program to count occurrences of a character in a file ; ; 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 ; ; 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 ; ; Storage for pointer and ASCII template ; ASCII .FILL x0030 PTR .FILL x3016 .END
Background image of page 2
ECE 190 Lecture 09 September 20, 2011 3 V. Kindratenko Few observations from a visual examination of this program o Semicolon (;) is used to indicate a comment, as with the binary programming o Some lines contain familiar instructions, e.g., LD, ADD.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/24/2012 for the course ECE 190 taught by Professor Hutchinson during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 7

lecture_09 - ECE 190 Lecture 09 September 20, 2011 LC-3...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online