Unit 3 Exercises 1 Consider the following program What numbers are in C100 and C101 at the end Verify your answer using the THRSim11 Simulator F00D C100 0 X LDD LDX STD BSET 0 X 44 BCLR 1 X 11 the is optional here 2 Consider the following instruction sequences Determine the label values and all allocated memory locations and their contents Note EQU does not reserve any memory bytes a b c VAR MAR RUN ORG FCB ORG EQU FCC 00 12 00 A1 C000 1234 Ab2 ORG RMB LOOP FDB F1 3 18 125B 3 Consider the following assembly program What are the values of the labels count list and moon after assembling the program Find the contents of ACCA ACCB the X register and locations C003 through C007 after executing the program Verify your answer using the THRSim11 Simulator moon ORG count list EQU C003 RMB FCB LDAA LDX LDAB SWI END FF 2 12 C0 04 moon list 1 1 X 4 Find the values of all labels in Programming Example 3 Unit 3 Also determine the hex code for the operands of all three branch instructions 5 Write a flowchart for a program that multiplies the number NUM times 4 by adding it to itself three times Write the corresponding assembly program Use the label NUM and assign it to memory location 00B0 Start the program at 0010 The result is to be saved at 00B1 6 What does the following program accomplish Verify it on the THRSim11 simulator or the M6800 simulator Note the M6800 simulator does not allow for labels So they need to be dropped the operand of the branch instruction should be replaced by the appropriate hex or signed decimal value 60 9F X ZAP START LDX CLR ZAP DEX BNE WAI END 7 Verify the look up table of squares program listed below using the THRSim11 Simulator Note that the simulator allows the user to change the content of registers and memory while a program is running on the simulator C000 Program to compute the square of a number 0 15 Input is assumed to be placed at 0001 Output goes to ACCA loop ORG LDAB 00 STAB 0000 LDX 0000 LDAA 96 X BRA ORG FCB FCB END loop 96 00 01 04 09 10 19 24 31 40 51 64 79 90 A9 C4 E1 8 Calculate the number of E cycles and the time it takes to execute the following program segment on a 68HC11 running at 0 5 s E cycle Assume D012 0A count LDAA D012 DECA CMPA 00 count BNE 9 Compare the precision of the following 10s delay program to the one in Huang s text p 82 correction first instruction should read LDAB in Huang s program outer loop inner loop LDAB 60 LDX DEX BNE DECB BNE END 55554 inner loop outer loop 10 Write a program that converts an 8 bit binary number in the range 00 through 63 i e 0 99 decimal stored at 0000 to BCD Store the result at 0001 Hint save all 2 digit BCD codes representing the numbers 0 through 99 in a list in memory and employ indexed addressing to point and pick the proper BCD code for the input hexadecimal number stored at 0000 11 Write a program to set bit seven MSB of a byte at location 0000 so that it contains odd parity That is the number of bits that are 1 in 0000 must become odd at the end of the program e g 0F becomes 8F 01 does not change etc Assume that the original number at 0000 is a positive number less than 80 12 Modify Programming Example 2 Unit 3 so that it works for signed numbers Verify it on the THRSim11 Simulator 13 The following program computes the square root or a good approximation of the square root of a number stored at 0000 The result is saved at 0001 Analyze this program and generate a flowchart and the algorithm used to find the square root Demonstrate this algorithm by hand on the number 25 decimal Test the program on one of the simulators ORG LDAA LDAB SBA again BCS INCB INCB BRA finished LSRB STAB WAI END C000 00 01 finished again 01
View Full Document