CMPEN 472
6. Write a short program to copy 12 bytes of data from a SOURCE memory locations to DEST
(20pt) memory locations. Please follow the specifications below:
Source data size: 12 bytes
Source data starting address: $3000
Destination address start: $30A8
Program start address: $3100
Work memory, TEMP: from $3040
Stack memory, StackSP at: $0080
Design your .asm source file a stand−alone program (same as your homework programs).
Define the labels SOURCE, DEST, TEMP, StackSP and others if you use them. Initialize
the necessary memory locations and registers if they are required for your program to
work correctly. Any assumptions you make, state it clearly. You may ask if you have
questions. Shorter programs are preferred for grading.
7. Convert the following decimal numbers into 8-bit 2’s complement numbers and perform the
(20pt) additions/subtractions indicated. Then answer the following questions for the result of each
operation. Carry/borrow bit generated? Overflow occurred? Is the 8-bit sum correct?
Show your work.
Addition:
Subtraction:
(+ 70)
+ (+ 60)
---------------------------
C=
V=
Sum Correct? Y/N
(+ 60)
+ ( - 70)
--------------------------
C=
V=
Sum Correct? Y/N
(- 60)
- (- 70)
---------------------------
C=
V=
Sum Correct? Y/N
(+ 70)
- ( - 60)
--------------------------
C=
V=
Sum Correct? Y/N
8. Assemble the MC9S12C128 assembly language program below which starts at
(20pt) address $3100. Show for each instruction the starting address and the instruction
bytes (opcode and operands (if any) in hexadecimal number.
Line Address Machine Language Assembly Language
1 3100 ORG $3100
2 StackST:
3 Entry:
LDS #StackST
LDAA #$01
STAA 2
mainLoop: ANDA 1,X+
NOP
BNE mainLoop
Done: SWI
9. Write a program that will run on the MC9S12C128 shown below to light the LED when the
(20pt) switch SW is on. Make the LED light directly indicate the SW state: LED ON when SW is ON
and LED OFF when SW is OFF. Write a short program including any necessary initialization.
Design your .asm source file a stand-alone program (same as the homework programs).
Assume ideal switch SW (no switch bouncing). Any additional assumption you make,
state it clearly. Please ask if you have questions.
10. We want to generate square wave on bit 0 of the port B on the MC9S12C128 chip.
(20pt) The continuous square wave has the period of 0.1sec: 5V output for 0.05sec and 0V output
for 0.05sec assuming 24MHz bus clock. Write the main program and the delay subroutine
for this task. Use the memory locations starting at $3100 for your program and at $3000 for
the data, if needed. Design your .asm source file as a stand-alone program (same as the
homework programs). Write a short program.