COE 538 Quiz

 

Name: _____________________________     Student #: __________________     Time: 50 min.

 

 

Notes:

 

1.      Close book

2.      Write the answers in the space provided

3.      Show the process that is used to derive your answers

 

 

1.      Write two assembler directives to initialize memory at locations $6000 and $6001 to $1025.

[1 mark]

 

 

                                                ORG   $6000

                                                FDB    $1025

 

 

 

 

2.      Given bit N of the Condition Code Register (CCR) is set to 1, bit V is set to 1, and the Program Counter (PC) is set to $6000. Calculate the value stored in PC after the following instruction is executed:

 

bge      $20                                                                                          [2 marks]

 

 

                                                PC = $6020

 

 

 

 

 

3.      Given the value stored in Accumulator A is $18 and the value stored in Accumulator B is %01001100, calculate the value stored in Accumulator D. Write down the value using decimal representation.                                                                                         [2 marks]

 

 

 

            0001 1000 0100 1100 2 = 6220 10

 

 

 

 

 

 

 

 

 

 

 

 

 

4.      Write one instruction to accomplish each of the following tasks:                                    [4 marks]

a)      Add the content of Accumulator B to Accumulator A.

 

 

                                                ABA

 

 

 

 

b)      Branch to memory location [PC] + $60.

 

 

                                                BRA    $60

 

 

 

 

c)      Set the most significant three bits of Accumulator B to 1.

 

 

                                                ORAB #%1110 0000

 

 

 

 

d)      Clear the least significant two bits of Accumulator A to 0.

 

 

                                                ANDA #%111 1100

 

 

 

 

5.      Given the program listing below, trace the results for each instruction from start to end. Use the table provided below to indicate the values stored in register A, B, D, X, and memory location $6050 and $6051 after the execution of each instruction. Show all numbers using hexdecimal representation.                                                                        [6 marks]

 

                        org       $6000

values              fcb       $23, $D1, $A2, $3F

 

                        org       $6050

result               fcb       $00, $00

                       

                                    org       $6100

            start                 clra                                          a=0

                                    clrb                                          b=0

ldx        #values                        x=$6000

                                    ldd       values                          d=$23D1

                                    addb    1,x                               b=A2, c=1

                                    adca    2,x                               a=C6=1100 0110

                                    asra                                         a=1110 0011=E3

                                    std       result                           [6050]=$E3     [6051]=$A2

            end                  swi

 

Instructions

A

B

D

X

[$6050]

[$6051]

ldx #values

00

00

00

6000

00

00

ldd values

23

D1

23D1

6000

00

00

addb 1,x

23

A2

23A2

6000

00

00

adca 2,x

C6

A2

C6A2

6000

00

00

asra

E3

A2

E3A2

6000

00

00

std result

E3

A2

E3A2

6000

E3

A2

 

 

 

 

 

 

 

 

 

 

6.      Write an instruction sequence to find the sum of the first N numbers in the following number sequence: 2, 4, 6, 8, 10…                                                                                          [10 marks]

 

 

 

 

 

 

                                                CLRA

                                                CLRB

                                    m1       ADDA  #2

                                                INCB

                                                CMPB #N

                                                BNE    m1

                                                SWI