ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 9 Weeks Ago, 6 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 26 May 2017 My Price 8.00

write a sequence of PIC 16F1829

For each of the following complex operations, write a sequence of PIC 16F1829 instructions thatperforms an equivalent operation. Assume that X, Y, and Z are 16-bit values split into individualbytes as shown in the following cblock directive, which defines two additional variables you canuse:

 

cblock 0x70

XH, XL ; High and low bytes of X

YH, YL ; High and low bytes of Y

ZH, ZL ; High and low bytes of Z

TEMP ; Temporary byte, if needed

COUNT ; Loop counter, if needed

Endc

 

1. Perform the 16-bit addition: X = Y + Z. Do not change Y or Z when performing this

operation.

 

 

 

 

 

 

 

 

 

 

 

 

 

2. Perform the 16-bit subtraction: X = Y – Z. Do not change Y or Z when performing this

operation.

 

 

 

 

 

 

 

 

 

 

 

 

 

3. Perform a 16-bit arithmetic right shift: X = Y >> ZL. (Note that, because the shift amount isno greater than 15, a single byte is sufficient to hold that value.) Do not change Y or ZLwhen performing this operation.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4. Given an 8-bit variable, YL, perform the multiplication:

YL = YL * 10

 

Hint: Note that multiplication by a constant amount can be broken into a series of shift and addoperations. For example, in general:

 

X * 2 can be implemented by shifting X to the left by 1 (X << 1)

 

X * 5 can be implemented as (X * 4) + X = (X << 2) + X

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5. Given two 8-bit variables stored in XL and YL, copy the value of bit position YL within

variable XL into the carry flag. For example:

 

If XL = 0x03 and YL = 0x00, set C to the value of bit 0 within XL.

o Since XL = 0x03 = 0000 00112, C = 1

 

If XL = 0xC2 and YL = 0x04, set C to the value of bit 4 within XL.

o Since XL = 0xC2 = 1100 00112, C = 0

 

Note that:

* This operation is very similar to the bit test (BT) instruction in the x86 architecture.

* Since YL is not a constant, you cannot use the value of YL directly in any of the PIC bit

test instructions (for example, btfsc XL, YL is not a valid instruction).

* Your code should not modify either XL or YL.

Answers

(11)
Status NEW Posted 26 May 2017 02:05 AM My Price 8.00

-----------

Attachments

file 1495767092-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)