

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Giurgiutiu; Class: MICROCNTROLLRS MECH ENGR; Subject: Mechanical Engineering; University: University of South Carolina - Columbia; Term: Fall 2009;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


This simple example has the following objectives: Review 2-digit decimal arithmetic with carry to prepare the ground for 2-digit hex arithmetic with carry.
Ex5.asm program is similar to ex3.asm, but uses numbers outside the 0 – 9 range. It performs the arithmetic operation 9 + 8 = 17. To achieve this, the program does the following: Load 9 into accA using LDAA, i.e., 9 A Load 8 into accB using LDAB, i.e., 8 B Add accA (i.e., 9) with accB (i.e., 8) A + B A A 17
Open THRSim11. Maximize THRSim11 window. Close the Commands window. Open file Ex5.asm. Assemble file. Tile windows. Set break point at the line containing SWI. Set the display of A, B registers to ‘Decimal’. Reset registers D, X, Y. Your screen should look like this:
Use the ‘Step’ button to step through the program. Press the Step button once. The registers do not change. Press again. Number 9 is loaded into accA. Press again. Number 8 is loaded into accB. Press again. AccA and AccB are added together. The result, 17, appears in accA. The number 8 is still preserved in AccB. Your screen should look like this: During the addition 9 + 8 = 17, decimal arithmetic with carry has been performed. The numbers nine and eight, when added, give the number seventeen, which is greater than nine. Since the greatest number that can be represented with just one decimal digit is nine, a carry to the next level, tens, had to be enacted. In words: “nine plus eight makes seven carry one”. In symbols: 9 + 8 = 17.
In this simple exercise, you have reviewing decimal arithmetic with carry to prepare the ground for understanding hex arithmetic with carry. The things that you have reviewed are: The greatest number that can be represented with a single decimal digit is nine. Numbers greater than nine are represented with two or more digits. For example, number seventeen is represented as 17, i.e. with two digits. When the result of adding two decimal numbers is greater than nine, a carry takes place. New words and notations: addition with carry.