EER-018
Introduction to Digital Computers
Assignment #8

  1. Assume that the value of the accumulator, A, is $F3 (F3 in hex) before each of the following 6805 instructions are executed (it is NOT a sequence of instructions). Give the final value of the accumulator and the CCR flags, N, Z, C.

instruction:

ADD #$23

SUB #$23

EOR #$F3 

accumulator:

 

 

 

CCR flags:

 

 

 

  1. The following instructions occur in a sequence, one after the other. What is the final value of the A register?

LDA #$F3

SUB #$03

ADD #$80

RORA

ASRA

  1. Assume that there are two data values in memory at locations $C2 and $C3. Write a short program to add the two numbers and put the result in location $C4.
  2. What logic instructions would be required to do the following: Hint: Use immediate mode operands for some.
    a. clear all even bit positions of A to zero?


b. set the middle 4 bits of A to one without changing any of the other bits?

c. complement all the bits of A? 

d. complement only the rightmost 4 bits of A?

5.  Analyze the program shown below by filling in the worksheet that follows for each instruction that is fetched and executed. 
 

Address

Label

Instruction

Operand

Comment

$0200

START:

LDA 

#$60

; Load A immediate

$0202

 

AND

$0034

; AND with contents of RAM

$0204

 

LDX

#$4F

; Load X immediate

$0206

 

STX

$0036

; Store X in RAM

$0208

 

SUB

$0035

; Subtract M[0035] from A

$020A

 

STA

$0037

; Store A in RAM


 

Accumulator

Cond. Codes 
1  1  1  H  I  N  Z  C

Index Register

Program 
Counter

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Memory
Address

Memory
Contents

 

 

$0034 

$84

 

 

$0035 

$04

 

 

$0036

 

 

 

$0037 

 

 

 

6. Hand assemble the following short program and give the resulting addresses and machine code.
 

 

org

$300    ; put program in memory starting at location $300

start:

LDX

#$64

 

ROLX

 

 

STX

$C6

 

BSR

put_out

 

STOP

 

put_out:

LDA

#$FF

 

STA

$00

 

RTS

 

  7. Give the final values of the A and X registers and the memory locations shown when the program below terminates.
 

 

org

$3FF    ;initialize one data value in memory

 

data_v:

fcb

$67

 

 

org

$300   ;put program in memory at $300

Memory

start:

LDX

#$C0

address: contents

 

LDA

$3FF

$C0

 

STA

,X

$C1

 

LSRA

 

$C2

 

INCX

 

$C3

 

STA

,X

 

 

INCX

 

 

 

INCA

 

 

 

STA

,X

 

 

STOP

 

 

 

ORG

$7FE

 

 

FDB

START    ; to set the reset address