Question: Please write in HCS12 assembly code! 5. The following assembly code will allow you to turn on the LEDS by writing to PORTB, and read

Please write in HCS12 assembly code!

5. The following assembly code will allow you to turn on the LEDS by writing to PORTB, and read the values on the DIP switches by accessing PTH (PORT H).

;Configure LEDS

MOVB #$FF, DDRB ;output mode for all 8 bits of portB

MOVB #$02, DDRJ ;PJ1 must be set to 0

BCLR PRTJ, #$02 ; clear bitl of port J (set to 0)

CLR PORTB ;Set all LEDs off initially

;Configure DIPs

MOVB #$00, DDRH ;input mode for all 8 bits of portH

LDAA PTH ;Read the values in portH

6. Write the assembly instructions necessary to perform the following operations:

• Add the instructions from Step 5 above at the start of your program.

• Load register A with 2. Set a code label Loop: on this instruction.

• Load register B with the values from PTH.

• Multiply the values in registers A and B together using the MUL instruction.

• Store the value in register B to PORTB.

• Branch back to the Loop: code label.

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

HCS12 Assembly programming LDAA Load accumulator A with ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Engineering Questions!