PS05-soln - ECE 109 Spring 2010 Name:_ Section:_ Problem...

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

View Full Document Right Arrow Icon
Spring 2010 Name:__________________________________________ Section:______________________ Mar 5-8, 2010 1 Problem Session 5 1. Count characters (60 pts 20 pts for flowchart, 40 pts for assembly language code): Draw a flowchart and write an LC-3 assembly language program that counts (and prints) the number of characters typed by the user. The user types a sequence of characters on the keyboard, ending with a linefeed (ENTER). The program counts the number of characters typed, not including the linefeed. The ASCII code for linefeed is 10 (decimal). Assume that the user will type between 0 and 9 characters, inclusive. The program prints the number of characters typed to the console. START (x3000) =LF? Increment count. HALT TRUE FALSE Set counter (R1) to zero. Get character (R0), and echo to console. Convert count to ASCII; put in R0. Print character. .ORIG x3000 AND R1, R1, #0 ; counter = 0 NewChar GETC ; read and echo OUT ADD R2, R0, #-10 ; compare to 10 BRz PrCount ADD R1, R1, #1
Background image of page 1

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

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

This note was uploaded on 04/18/2010 for the course ECE 109 taught by Professor Bradley during the Spring '08 term at N.C. State.

Page1 / 2

PS05-soln - ECE 109 Spring 2010 Name:_ Section:_ Problem...

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

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