Please write in HCS12 assembly code! 5. The following assembly code will allow you to turn on
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 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.
Principles Of Managerial Finance
ISBN: 978-0136119463
13th Edition
Authors: Lawrence J. Gitman, Chad J. Zutter