






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







This exercise has the following objectives: Introduce decrease (SUBA) Review decimal borrow concepts using decrease Introduce hex borrow using decrease Introduce 2’s complement negative hex numbers as decrease of zero with free borrow Show the 2-digit 2's complement negative hex numbers Show the decimal equivalent of the 2-digit hex decrease of zero and of 2-digit 2's complement negative hex numbers Note: To facilitate understanding, the same numbers are used in both decimal and the hex cases.
The program ex8.asm performs the following arithmetic operations: i) 7 – 1 = 6 (decimal) using the opcode mnemonics LDAA, SUBA ii) $07 - $01 = $06 (hex) using the opcode mnemonics LDAA, SUBA iii) 10 - 1 = 9 (decimal) using the opcode mnemonics LDAA, SUBA iv) $10 - $01 = $0f (hex) using the opcode mnemonics LDAA, SUBA v) $00 - $01 = $ff (hex) using the opcode mnemonics LDAA, SUBA vi) 0 - 1 = 255 (decimal equivalent of 2-digit hex arithmetic) using the opcode mnemonics LDAA, SUBA
Open THRSim11. Maximize THRSim11 window. Close the Commands window. Open ex8.asm. Assemble, tile the windows, set the breakpoint, and reset the registers. Your screen looks like this:
Set accA display to hex. Step through section ii) of the code. At the end of this section, your screen looks like this: During the execution of this section, hex number $07 was loaded into accA, and decreased by 1 to become $06. During the decrease, hex borrow did not need to happen.
Set accA display to decimal. Step through section iii) of the code. At the end of this section, your screen looks like this: During the execution of this section, decimal number 10 was loaded into accA, and decreased by 1 to become 9. During the decrease, decimal borrow happened because the LSD was 0.
Set accA display to hex. Step through section v) of the code. At the end of this section, your screen looks like this: During the execution of this section, hex number $00 was loaded into accA, and decreased by 1 to become $ff. During the decrease, hex borrow happened because the LSD was 0. Since MSD was also 0, a ‘free borrow’ beyond the MSD happened. Hence, the result of $00-$01 is the same as the result of $000+$100-$001=$0ff, i.e. $ff.
Set accA display to decimal. Step through section vi) of the code. At the end of this section, your screen looks like this: During the execution of this section, decimal number 0 was loaded into accA, and decreased by 1 to become 255. We notice that the operation is equivalent to 0+256-1=255. This indicates that, although the operation was displayed in decimal, a hex free borrow actually happened, since 256=$100.
Use your calculator to find the HEX equivalent of negative decimal number –100. Type –100 into your calculator, and convert to hex. After you have done this, you will see hex number F…FFF9C in your screen. (The number of F depends on the maximum display length of your calculator.) The last two digits, 9C, are the hex negative number of –100.
(This page is left intentionally blank)
EMCH 367 Fundamentals of Microcontrollers qkd5nb-825823-3288337-h-20example8-doc.doc