ICS 331: System Software

Midterm Exam Solution

Date: October 13, 1998                                                                                 Time: 75 minutes

Question 1

  1. Briefly explain each of the following addressing mode of the SIC/XE machine, indicating what bits will be set
    and if the index register can be used with this mode:                                                                         (12 Points)
  2. Extended mode: In this mode 20-bits direct memory address is used as the target address. Bit e is set to 1.
    Index register cannot be used with this mode.

    Immediate mode: In this mode the target address is used as the operand of the instruction. Bit n is set to 0
    and bit I is set to 1.
    Index register cannot be used with this mode.

    PC-based mode: In this mode the content of the PC is added to the displacement to calculate the target
    address. Bit P is set to 1. Index register can be used with this mode.

  3. Assume that the contents of the memory and registers for a SIC/XE assembly program are as follow:

(B) = 003000 (PC) = 001000 (X) = 000900

1030

001600

1600

005000

3C00

00C303

C303

001030

Knowing that the operation code for LDA instruction is 00, complete the following table (note that the first
column of the table contains the Hex representation of a machine instruction):                               (15 Points)

 

 

op

 

n

 

i

 

x

 

b

 

p

 

e

 

displacement/address

Target address

Value loaded into register A

0310C303

000000

1

1

0

0

0

1

0000 1100 0011 0000 0011

C303

001030

032600

000000

1

1

0

0

1

0

0110 0000 0000

1600

005000

010030

000000

0

1

0

0

0

0

0000 0011 0000

30

000030

03C300

000000

1

1

1

1

0

0

0011 0000 0000

3C00

00C303

022030

000000

1

0

0

0

1

0

0000 0011 0000

1600

005000

Question 2

Generate values for the Location Counter (LOCCTR) and object code for each statement in the following SIC/XE
program.                                                                          (8 points for the LOCCTR, 18 points for the object code)

Hints: 1. All opcodes needed to generate the object code are given

            2. CLEAR is a format 2 instruction that takes 2 bytes

            3. Register X has the register number 1

            4. The ASCII code for the character "0" is 30 hex.

            5. 8192 decimal is 2000 hex ; 256 decimal is 100 hex

Line

LOCCTR

Source Statements

Opcode

Object Code

1

0000

TEST

START

0

2

0005

COUNT

EQU

5

3

0000

CLEAR

X

B4

  B410

4

0002

LDA

=C'301'

00

  032007

5

0005

ADD

TAB1,X

18

  1BA016

6

0008

+STA

RES

0C

  0F10201E

7

LTORG

8

000C

*

=C'301'

  333031

9

000F

LDA

#10

00

  01000A

10

0012

SUB

#5

1C

  1D0005

11

0015

STA

@ICS

0C

  0E2003

12

0018

RSUB

4C

  4F0000

13

001B

ICS

RESW

1

14

001E

TAB1

RESB

8192

15

201E

RES

RESW

1

16

END

Question 3

  1. For the assembly program of Question 2 produce all the Object program records that may be generated by
    the SIC/XE assembler.                                                                                                                 (15 points)
  2.     H_TEST    _000000_002021

        T_000000_1B_B410_032007_1BA016_0F10201E_333031_01000A_1D0005_0E2004_4F0000

        M_000008_05

        E_000000

  3. For each of the following actions, indicate the pass in which it would be done within a 2-pass assembler:
    (circle your answer)                                                                                                                        (5 points)

            1.   Generate data values defined by BYTE, WORD etc.          Pass 1          Pass 2

            2.   Assign addresses to all statements in the program.          Pass 1          Pass 2

            3.   Store all literals in the literal table.                                       Pass 1         Pass 2

            4.   Write the object program.                                                      Pass 1         Pass 2

            5.   Generate modification records.                                            Pass 1         Pass 2

 

Question 4

  1. List three advantages of using program blocks in writing SIC/XE assembly programs.             (6 points)
  2.     1) Extended format instructions can be eliminated.

        2) The use of base registers can be eliminated.

        3) Data areas can still be used closer to the statements that reference them in the source program.

  3. Describe the purpose and list the fields of the tables used by the SIC/XE assembler.                 (9 points)
  4.     1) The Operation Table (OPTAB): stores the opcode for each assembly operation. It is used by the
            assembler to replace mnemonics by opcode. It has the following fields: Operation Opcode Length.

        2) The Symbol Table (SYMTAB): stores the address of each label/operand used in the program.
            It has the following fields: Symbol name Block name type Value Flags.

        3) The Literal Table (LITTAB): stores the literals used in the program with their addresses or
            values. It has the following fields: Literal Address/Value Length.

     

  5. Briefly explain how the SIC/XE assembler handles labels/operands used in various program blocks both in
    pass 1 and Pass 2.                                                                                                                     (12 points)

            1) In pass 1, the assembler stores each label in the symbol table together with its block #  and address
                relative to the beginning of that block

            2) In pass 2, the assembler replaces each operand by its actual address which is calculated by adding
                the relative address of the label in the SYMTAB to the starting address of the block containing that
                operand