Practice Problems for LDC Assembly Language Programming

Practice Problems for DRC Assembly Language Programming

1.  Write a program that takes two numbers from locations 25 and 26, puts their sum in location 27 and their difference M25 – M26 in memory location 28.

2.  Write a program that takes two numbers from memory locations 40 and 41 and exchanges them. I.e. it puts the number from memory location 40 into 41 and from memory location 41 into 40.

3.  Write a program that examines all the numbers stored in locations 41 .. 45, and if any number is negative, replaces that memory location with the number that is the absolute value of the number (i.e. a 5 would not change but a –3 would become a 3).

4.  Write a program that examines the numbers stored in locations 41 .. 45, selects the largest of the group and puts it in location 50.

5.  Write a division program using the assembly language of DRC. It should solve a problem like x/y. To start, the program should store x in location 40 and y in location 41. Load the numbers into registers and subtract the number in location 41 (i.e. x) from the number in location 40 until the subtraction can't be done without giving a negative result. (Hint: you might have to go one step too far to see how many times it can be done.) Store the answer (the number of "legal" subtractions) in memory location 42 and the remainder in memory location 43. Test your program with various types data such as

x y

100  15

100  20

15 100