70 likes | 170 Views
Midterm Solutions. 1.2. MidTerm Discussion. 4.1 Write a code-snippet that will load two number from “register memory” into the CPU, and add them together, then store the result back to “register memory”. ldaa num1 ldab num2 aba staa result. Optional: Num1 equ $03 num2 equ $05
E N D
MidTerm Discussion 4.1 Write a code-snippet that will load two number from “register memory” into the CPU, and add them together, then store the result back to “register memory” ldaa num1 ldab num2 aba staa result Optional: Num1 equ $03 num2 equ $05 result equ $00
4.2 Write a code-snippet, that will implement a loop that iterates 5 times. ldaa #$05 loop: deca bne loop
68HC11 5.1 Write a code-snippet, that will implement a delay loop in a subroutine. The delay loop must execute FF times. delay: ldaa #$FF loop: deca bne loop rts
68HC11 5.2 Write a code-snippet, that will implement a delay loop in a subroutine. The delay loop must execute AFFFF times. delay: ldaa #$0A oloop: ldx #$FFFF iloop: decx bne iloop deca bne oloop rts
68HC11 6.1 Write a code-snippet, that will turn on PA6, call a delay subrouting, then turn on PA4 and 5. You can assume the delay subroutine is written for you, and that port_a is a label that is set correctly. ldaa #$04 ;value to disable timed interrupt staa $3F ;disable timed interrupt lds #$FF ;set stack start ldaa #$40 ;value to turn on just PA6 staa port_a ;set PA so just 6 is on bsr delay ;call delay subroutine ldaa #$30 ;value to turn on just PA4&PA5 staa port_a ;turn on PA4&5 #$40 = 0100 0000 bits 7654 3210 #$30 = 0011 0000