MODERNIZED PROGRAM
INTRODUCTION TO COMPUTING SYSTEM COURSE
LC3 & C PROGRAMMING LAB
REQUIREMENTS
Present at lab room on time.
Create a subdirectory studentname_code in the D:/Clabs directory and save all
your files inside it.
You can create further subdirectory labn , n =1..5 is the lab index.
Try to do all questions step by step.
Show all your results to TA at the end of the lab.
LAB 0:
EDITING, COMPILING, AND SIMULATING LC3 PROGRAMS
Exercise 1
Write and simulate a program using the LC-3 Assembly language:
- Input 1 lowercase ASCII letter (between ‘a’ and ‘z’)
- Change lowercase ASCII letter to uppercase ASCII letter.
- Output them on screen.
Exercise 2
Write and simulate a program using the LC-3 Assembly language:
- Input 1 characters (between ‘A’ and ‘Z’) and 1 positive number (between 0 and
9).
- Output them on screen.
Exercise 3
Write and simulate a program using the LC-3 Assembly language:
- Input 3 bits A, B and C.
-
BCAD +=
- Output the result on screen.
things go wrong and why?
Restore the correct name of the main function. Modify the program so that it works in
centimeters rather than in inches. Now make it take the radius value in centimeters but
display the result in square inches. One inch is 2.54 centimeters.
Modify the program so that it can do the inverse process, area is the input and radius is
the output. You must check all cases of the input (in centimeters).
Exercise 2
Compile the program sqrt.c
. Note the error message you receive.
This links in the math library in which the sqrt function is defined. How can you link
the math library to your program? Run the program and input a few different numbers.
What happens when the input number is negative? Try to treat this situation.
Exercise 3
Compile and run the following programs. See how much of the program text you
understand and check the output result with some inputs.
define.c
overflow.c
sizes.c
anatomy.c
Explain the purpose of these programs.
LAB 2: BASIC OPERATORS AND INPUT/OUTPUT
Exercise 1
Compile and run the program floatari.c
. Modify it to get results with more decimal
digits than you get from the original version.
Modify the program prepost.c
Now replace this statement with the following one:
x = scanf("%i",&x);