Microprocessors: From Assembly Language to C Using thePIC18Fxx2

I.4: CHAPTER 4

I.4 CHAPTER 4

1.

Instruction: subwf j,f

2.

Instruction: addwf i, f

3.

Instruction: andwf i,w

4.

Instruction: iorwf j,w

5.

Instruction: movff 0x04E, 0x04F

6.

Instruction: bsf i,3

7.

Instruction: bcf j,4

8.

Instruction: btg j, 7

9.

Instruction: rlcf j, w

10.

Instruction: rrcf i, w

11.

Instruction: xorlw 0x4E

Answers

1.

Location 0x001 = (0x001) - W = 0x7A 0xD7 = 0xA3. Flags are C = 0 (borrow), Z = 0.

2.

3.

W = (0x000) & 0xD7 = 0xA0 & 0xD7 = 0x80. Flags are C = 0, Z = 0.

4.

5.

Location 0x4F changed to 0x00. No flags are affected, so C = 0, Z = 0.

6.

7.

Bit 4 of location 0x001 is cleared, so new value of 0x001 is 0x6A. No flags affected, so C = 0, Z = 0.

8.

9.

W = (0x001) << 1 (shift left) = 0x7A << 1 = 0xF4. Flags are C = 0, Z = 0.

10.

11.

w = (W) ^ 0x4E = 0xD7 ^ 0x4E = 0x99. Flags are C = 0, Z = 0.

12.

Code fragment:

k = i + (j << 1);

13.

Code fragment:

i = (i >> 1)  k;

14.

Code fragment:

if (i > k){   k = i << 2;} else { j = k ^ j;}

15.

Code fragment:

i = 0;while (i != k) {  k++; i = i << 1;}

16.

Code fragment:

do {  i =...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Thermocouple Temperature Transmitters
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.