Unformatted text preview:

Example 5ObjectiveprogramexecutionWhat you have learnedEMCH 367 Fundamentals of Microcontrollers Example 5EXAMPLE 5OBJECTIVEThis simple example has the following objectives:- Review 2-digit decimal arithmetic with carry to prepare the ground for 2-digit hex arithmetic withcarry.PROGRAMEx5.asm program is similar to ex3.asm, but uses numbers outside the 0 – 9 range. It performs thearithmetic 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 17EXECUTIONOpen 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 registersto ‘Decimal’. Reset registers D, X, Y. Your screen should look like this:Dr. Victor Giurgiutiu Page 1 1/15/2019EMCH 367 Fundamentals of Microcontrollers Example 5Dr. Victor Giurgiutiu Page 2 1/15/2019EMCH 367 Fundamentals of Microcontrollers Example 5Use the ‘Step’ button to step through the program. Press the Step button once. The registers do notchange. Press again. Number 9 is loaded into accA. Press again. Number 8 is loaded into accB. Pressagain. AccA and AccB are added together. The result, 17, appears in accA. The number 8 is stillpreserved in AccB. Your screen should look like this: During the addition 9 + 8 = 17, decimal arithmetic with carry has been performed. The numbers nineand eight, when added, give the number seventeen, which is greater than nine. Since the greatestnumber that can be represented with just one decimal digit is nine, a carry to the next level, tens, had tobe enacted. In words: “nine plus eight makes seven carry one”. In symbols: 9 + 8 = 17.WHAT YOU HAVE LEARNEDIn this simple exercise, you have reviewing decimal arithmetic with carry to prepare the ground forunderstanding 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, numberseventeen 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.Dr. Victor Giurgiutiu Page 3 1/15/2019EMCH 367 Fundamentals of Microcontrollers Example 5Dr. 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?