CS273

Quiz 5 Solution

 

Put your social security number in the right hand corner of the page of each page.  Please do not put your name anywhere on this quiz.  Failure to follow these instructions will cost you 1 point on the quiz.  Note: Be sure to show all your work and no calculators. You will have until the end of class to complete the quiz.

 

1.      (2 points) Add the two 2C binary numbers for each situation. 
    Also indicate the value (0 for false, or 1 for true) for each of the condition codes indicated.

       Note: Your answer should be in 2C binary (radix 2).
        

                                                                                                     N                Z                V           C
        a)          11111110

                  + 10011001
                   --------------

                     10010111                                                                1                 0                0            1

 

                                                                                                     N                Z                V           C
        b)          01101110

                  + 01100001
                   --------------

                     11001111                                                                1                 0                1            0

 

 

2.      (5 points)  We have seen five types of addressing so far  Immediate (IMM), Direct (DIR),
                        Extended(EXT), Inherent (INH), and Relative (REL).  For each situation (piece
                        of code) indicate its addressing mode abbreviation:

                                                                                                        Addressing Mode

a)    fred       staa    $1004                          EXT

b)                 bra      start                             REL

c)    start      ldab    #$aa                            IMM

d)    sam       beq     fred                              REL

e)                 subb    #%00010001                    IMM

f)                  tba                               INH

g)    lab1      ldab    $f9                         DIR

h)    lab2      nop                                    INH

i)                  adda    $feee                           EXT

j)     chuck    staa     $30                              DIR

CS273

Quiz 5 Continue

 

3.    (3 points) Hand assemble the following code into the listing table given:


0001

00e1

 

 

 

 

 

org

 

$00e1

0002

00e1

 

 

 

cnt

 

rmb

 

1

0003

f800

 

 

 

 

 

org

 

$f800

0004

f800

86

0c

 

start

 

ldaa

 

#$0c

0005

f802

97

e1

 

 

 

staa

 

cnt

0006

f804

20

fe

 

theend

 

bra

 

theend

 

 

 

4.  (5 points) Hand disassemble the following memory locations, then hand execute the program
                     instructions giving the value of the PC, B and CCR (N Z V C) if known:

 

                                                                                               

 

 

 

 

 

 

 

PC

B

CCR(NZVC)

 

 

 

 

org

$F805

 

F805

?

?

F805

F6

 

start

LDAB

 

 

F806

?

?

F806

FA

 

 

 

 

 

F807

?

?

F807

00

 

 

 

$FA00

 

F808

80

1 0 0 -

F808

5A

 

 

DECB

 

 

F809

7F

0 0 1 -

 

 

 

 

 

 

org

$FA00

FA00

80

 

 

fcb

$80