Microproccesor Applications

profilefaghnlimoh97
ECE332_fall2018_hwk03_set.pdf

ECE332 - 2018 Fall - homework set 3 Assigned: Friday Oct. 5 Due in Blackboard: Friday Oct. 12, 2018

Homework Exercises:

1. In your own words, explain the conceptual difference between unsigned branch instructions ( bhi, bhs, blo, bls ) and signed branch instructions (bge, bgt, ble, blt ). Also, for the following which instruction, blo or blt would branch and which would not? Explain your answer.

ldaa #$1A cmpa #$FF ; BRANCH_INSTRUCTION

2. Consider the given code snippet. Based on the value in the A register, execution will proceed to one of three target addresses (Targ1, Targ2. Or Targ3). Determine the set of values in the A register for execution to proceed to each target address.

Test: tsta bmi Target1 cmpa #$65 blo Target2 adda #$D4 bra Target3

3. The following example program uses labels. You will perform two-pass assembly to produce a list file, with machine code to left and source code to the right.

a. Write what the list file looks like after you completed the first pass. For each label referenced leave a blank or blanks in the corresponding memory locations. Also write after each instruction its addressing mode.

b. Give the symbol table, that is, list the labels and address value assigned to each c. Write the final list file. Write after each instruction its effective address. d. Inspect the program and produce the final value in the D register. Without $ the given values are

in decimal

; Ex0404.asm - Name - Date ORG $0800 Sum: DS.W 1

; code section ORG $4000 Start: ldaa Valx ; ldab #27 ; mul ; std Sum ;

Part2: ldaa Valx+1 ; ldab #51 ; addd Sum ; Done: bra Done ; Valx: DC.B 13,15

ORG $FFFE DC.W Start

2. In your own words, explain why a branch instruction can branch forward as much as 127 bytes and back 128 bytes.

3. Complete the following table by using the ABOT equation. If there any branch instructions that are out of range, indicate each in turn.

Branch Instruction

Branch Address (A)

Branch Bytes (B)

Offset Byte (O)

Target Address(Tn)

bls T1 $2b3d $4a blt T2 $a4 $c22c bgt T3 $4589 $459a bmi T4 $43a3 $439a

4. Consider the following list file

|; Hwk03 – main.asm – Name – Date |; Homework exercise | ORG $0800 0800 |RamAdx: DS.B 1 | | ORG $4000 4000 86 A5 |Start: ldaa #$A5 ; 4002 44 |Top: lsra ; 4003 84 03 | anda #$03 ; 4005 26 FB | bne Top ; | 4007 20 FE |Done: bra Done ; 4009 A5 |RomVx: DC.B $A5 | | ORG $FFFE FFFE 40 00 | DC.W Start

a. Write a memory dump for the given program. Have 8 memory bytes per line, include addresses higher than or equal to $4000, and show ?? for each unknown byte value

b. Write the addressing mode for each instruction as well as and the effective address for those that have one. For the branch instruction give the target address.

c. List the labels and give the address value assigned to each

d. Fill in an execution history, listing the values for PC, A, B, C-flag, [$0800], [$0801]. Stop once the bra instruction executes once.

PC A Z-flag Next Inst

$4000 ?? ?

5. Draw a flowchart that corresponds to the code given in the prior exercise

6. The following memory dump contains a small 9S12 program in machine language

4000: 86 01 7A 08 - 00 48 89 00 4008: 20 F8 ?? ?? – ?? ?? ?? ??

FFF8: ?? ?? ?? ?? – ?? ?? 40 00

a) Disassemble the dump file into a simple assembly list file, like that in the class notes. b) Write the addressing mode and effective address or target address for each instruction. c) Explain what instruction in the program is able to propagate the C-flag value?

Written by Prof. Hill for ECE332 which is a course in the Electrical and Computer Engineering and Technology at the University of Hartford, in Connecticut, USA. Revised: Friday Oct. 5, 2018

Fahad Khaleefoh
Fahad Khaleefoh
  • ECE332 - 2018 Fall - homework set 3
    • Homework Exercises: