2
EGEE 280 Microcontroller HW#1 Fall 2013 Name: Ryne Lu Due: 9AM, Mon., Sep. 23, 2013 For this homework, please type in your answers in this document and submit it electronically in Titanium using Homework Assignment Tool If you need to use Code Warrior on you home computer for completing this homework. Please see below the web site for downloading the free Code Warrior special edition: http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=01272600610BF1 and select the following version to install, Special Edition: CodeWarrior for HCS12(X) Microcontrollers (Classic) HW Problems: 1. Given decimal value 42 in accumulator A. We want to double this value by 2 using a shifting instruction. What is the proper shifting instruction to complete it? ROL 2. Suppose accumulator A and accumulator B contains $27 and $62, respectively. What values will you find in accumulator A and B after executing the ABA instruction? A = $89 ; B = $62 3. Suppose we want to divide a 32-bit signed number $0010A120 with a 16-bit signed number $1080. How can we perform this task? Please write the code for this task. 4. Assume M[$2000] = $56, accumulator B = $A9. What is the result of executing the following code? ORAB $2000 Result: M[$2000] = 56; B = FF; And, what is the result of executing the following code for the same conditions? ANDB $2000 1

EE280_HW1_Fall13

Embed Size (px)

DESCRIPTION

EE280

Citation preview

Page 1: EE280_HW1_Fall13

EGEE 280 Microcontroller HW#1Fall 2013

Name: Ryne Lu Due: 9AM, Mon., Sep. 23, 2013

For this homework, please type in your answers in this document and submit it electronically in Titanium using Homework Assignment Tool

If you need to use Code Warrior on you home computer for completing this homework. Please see below the web site for downloading the free Code Warrior special edition:

http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=01272600610BF1

and select the following version to install,

Special Edition: CodeWarrior for HCS12(X) Microcontrollers (Classic)

HW Problems:

1. Given decimal value 42 in accumulator A. We want to double this value by 2 using a shifting instruction. What is the proper shifting instruction to complete it?

ROL

2. Suppose accumulator A and accumulator B contains $27 and $62, respectively. What values will you find in accumulator A and B after executing the ABA instruction?

A = $89 ; B = $62

3. Suppose we want to divide a 32-bit signed number $0010A120 with a 16-bit signed number $1080. How can we perform this task? Please write the code for this task.

4. Assume M[$2000] = $56, accumulator B = $A9. What is the result of executing the following code?

ORAB $2000Result: M[$2000] = 56; B = FF;

And, what is the result of executing the following code for the same conditions?ANDB $2000Result: M[$2000] = 56; B = 0;

5. Suppose M[$2000] = $56,What is the result of executing the following code?

BCLR $2000, $35Result: M[$2000] = 42;

And, what is the result of executing the following code?BSET $2000, $35Result: M[$2000] = 77;

6. Suppose you are required to load an 8-bit value from memory location $2000 into accumulator A, and load another 8-bit value from memory location $2003 into accumulator B using the index addressing mode. How will you do this? Please write the code for this task.

1

Page 2: EE280_HW1_Fall13

Code:LDX #$2000LDAA $0, XLDAB $3, X

7. Suppose accumulator A contains hexadecimal number $20 and after executing instruction ADDA #$E0. What will be the values for the H, Z, N and C bits in CCR as the result of this instruction?

H=0, Z=0, N=1, C=1

8. Suppose accumulator A contains $56. If we perform instruction SUBA #$55, which of the following branch instructions will be activated? BGE, BNE, BLT, BHS, BLE, why?

BHS because SUBA #55 results in $01 and is an unsigned number higher than zero.

2