Question: simulator is Codeworrior and need to update code in assembly language ; Lab_1_ASM_S12 ; Install & run Codeworrior and run the True Simulator ; This
simulator is Codeworrior and need to update code in assembly language ; Lab_1_ASM_S12 ; Install & run Codeworrior and run the True Simulator
; This lab turns ON the LEDs in an incrementing order: ;
;Assigment: ;Install CW IDE ;Using the simulator, modify the ASM code to turn ON the 4 LEDs in an alternative way every 2s, i.e.: ;10101010 --> 01010101 --> 10101010 --> 01010101 as discussed during the lab
; Define the entry point for the main program XDEF Entry
;******************************** ; Include files ;******************************** ; Register definitions BASE: EQU 0 ; Base address for registers PORTA: EQU BASE+0 ; Port A PORTB: EQU BASE+1 ; Port B DDRA: EQU BASE+2 ; Data Dir Reg A DDRB: EQU BASE+3 ; Data Dir Reg B
; Hint, you can use this starting pattern and consider using coma (complement) LED1: EQU $0; ; LED1 Pattern starting from 0 ; Hint: consider using an alternating LEDs pattern
;******************************** ; Constants definitions ;******************************** DELAY1: EQU $FFFF ; Inner loop counter DELAY2: EQU $0020 ; Outer loop counter
;******************************** ; Code Section ;******************************** Entry: ;******************************** ; Initialize stack pointer register lds #$2900 ;******************************** ldaa #$FF staa DDRA ldaa #0 ; Hint: Consider loading the pattern from above: LED1 (after modification)
main_loop:
; Display the current pattern on the LEDs staa PORTA
; Delay some time jsr delay_sub ; call this subroutine delay: return address is saved on the stack
; After the delay: Activate teh LEDs based on the new pattern: inca ; increment a, consider using an alternative operation
; Branch back to main_loop, bra main_loop
;******************************** ; End of the main Program
;******************************** ; Below are the subroutines to be called from the main program delay_sub: pshx ; Save the registers pshy ldy #DELAY2 ; Initialize outer loop counter
outer: ; WHILE the Y register is not zero ; Decrement the outer loop counter dey beq all_done ; Branch when Y equal to zero ; DO the inner loop ldx #DELAY1 ; Initialize inner loop counter
inner: ; WHILE the X register is not zero ; DO Decrement the inner loop counter dex bne inner ; Branch when X NOT equal to zer0 ; ENDWHILE X not zero bra outer ; ENDWHILE Y not zero
all_done: puly ; Restore the registers pulx rts
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
