Unformatted text preview:

Example 3ObjectiveprogramexecutionWhat you have learnedEMCH 367 Fundamentals of Microcontrollers Example 3EXAMPLE 3OBJECTIVEThis simple example has the following objectives:- Review the principles of the decimal numbers, i.e., in the range 0 – 9- Review the decimal carry concept, i.e., when a result is outside the 0 – 9 range.- Prepare the ground for hex arithmeticPROGRAMEx3.asm program is similar to ex2.asm, but uses numbers that give the result outside the 0 – 9 range. Itperforms the arithmetic operation 7 + 6 = 13. To achieve this, the program does the following:- Load the number 7 into accA using LDAA, i.e., 7  A- Load the number 6 into accB using LDAB, i.e., 6  B- Add the number in accA (i.e., 7) with the number in accB (i.e., 6) A + B  A A 13EXECUTIONOpen THRSim11. Maximize THRSim11 window. Close the Commands window. Open file Ex3.asm.Assemble file. Tile windows. Set break point at the line containing SWI. Set the display of A, B registersto ‘Decimal’. Reset registers D, X, Y. Your screen should look like this:Dr. Victor Giurgiutiu Page 1 1/13/2019EMCH 367 Fundamentals of Microcontrollers Example 3Use the ‘Step’ button to step through the program. Press the Step button once. The registers do notchange. Press again. Number 7 is loaded into accA. Press again. Number 6 is loaded into accB. Pressagain. AccA and AccB are added together. The result, 13, appears in accA. The number 6 is stillpreserved in AccB. Your screen should look like this: WHAT YOU HAVE LEARNEDIn this simple exercise, you have prepared the ground for understanding hex arithmetic by reviewingdecimal arithmetic with results outside the range 0 – 9. The things that you have reviewed are:- In decimal arithmetic, the base of the number system is ten- Ten independent symbols exist for representing the first ten numbers in the decimal system: 0,1, 2, 3, 4, 5, 6, 7, 8, 9. These symbols are called digits.- The greatest number that can be represented with a single decimal symbol is nine.- Numbers greater than nine are represented with two or more digits. For example, numberthirteen is represented as 13, i.e. with two digits. - The symbol furthest to the left is called the most significant digit (MSD). In number 13, the mostsignificant digit is 1. It signifies the number of tens contained in the number. In our case, wehave only one ten, since 1 x ten = ten- The symbol furthest to the right is called the least significant digit (LSD). In number 13, the leastsignificant digit is 3. It signifies the number of units contained in the number. In our case, wehave three units, since 3 x units = three.- The complete number is assembled by adding the contribution of all digits, from LSD throughMSD. In number 13 there are two digits, MSD = 1, LSD = 3. The complete number is 1 x ten + 3x units = ten + three = thirteen.- When the result of an addition is greater than nine, a carry occurs.- New words and notations: digits, most significant digit (MSD), least significant digit (LSD), carry.Dr. Victor Giurgiutiu Page 2 1/13/2019EMCH 367 Fundamentals of Microcontrollers Example 3Dr. Victor Giurgiutiu Page 1


View Full Document

SC EMCH 367 - EMCH 367 Study Notes

Download EMCH 367 Study Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view EMCH 367 Study Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EMCH 367 Study Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?