0% found this document useful (0 votes)
11 views7 pages

Module3 Part1

The document covers machine-dependent assembler features, focusing on instruction formats and addressing modes for SIC and SIC/XE systems. It details program relocation, explaining how relocatable programs can be loaded into different memory locations and the necessity of modification records for direct addresses. Additionally, it includes previous year university questions related to instruction formats, addressing modes, and program relocation concepts.

Uploaded by

THEJALAKSHMI P K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Module3 Part1

The document covers machine-dependent assembler features, focusing on instruction formats and addressing modes for SIC and SIC/XE systems. It details program relocation, explaining how relocatable programs can be loaded into different memory locations and the necessity of modification records for direct addresses. Additionally, it includes previous year university questions related to instruction formats, addressing modes, and program relocation concepts.

Uploaded by

THEJALAKSHMI P K
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Module System Software(S5

II CSE)
MODULE III

o Machine dependent assembler features


 Instruction Format and Addressing Modes (Hand assembly of SIC/XE program
MODULE 2)
 Program Relocation
 Machine Dependent Assembler Features
o Instruction Format and Addressing Modes
 SIC
 Word size = 3 bytes
 Memory size = 215 bytes
 It has only 5 registers: A,X,L,PC and SW
 Supports only one instruction format: 3 byte instruction
 Addressing modes supported: Direct and Indexed
 SIC/XE
 Memory size = 220 bytes
 This supports four different types of instruction types
o 1 byte instruction
o 2 byte instruction
o 3 byte instruction
o 4 byte instruction
 Instructions can be:
o Instructions involving register to register
o Instructions with one operand in memory, the other in Accumulator
o Extended instruction format
 Addressing Modes are:
o Index Addressing: Opcode m, x
o Indirect Addressing: Opcode @m
o PC-relative: Opcode m
o Base relative: Opcode m
o Immediate addressing: Opcode #c
o Extended instruction: +opcode m
 Register-to-register instructions are used wherever possible. Register-to-
register instructions are faster than the corresponding register-to-memory
operations because they are shorter and do not require another memory
reference.
o Assembler converts the mnemonic operation code to machine language
using OPTAB.
o Assembler changes each register mnemonic to its numeric equivalent. To
do this SYMTAB would be preloaded with the register names(A,X, etc.)
and their values(0,1, etc.).
 Eg: COMPR A,S
 Its object code is A004
 Consider the following statement

o START specifies the beginning of the program


1
Module System Software(S5
II CSE)
o 0 indicates it is a relocatable program
 Register to memory instructions
o Instructions that refer to memory are normally assembled using either
program counter relative or base relative mode.
o The correct target address is calculated by adding the displacement to the
contents of Program Counter(PC) or Base Register(B).
 Program Counter Relative: -2048 ≤ displacement ≤ +2047
 Base Relative: 0≤displacement ≤ 4095
o If displacements are too large, then the 4-byte extended instruction
format must be used. It contains 20 bit address field.
o The assembler directive BASE is used in conjunction with base relative
addressing.

 Program-Counter Relative Addressing Mode


o Usually format-3 instruction format is used.

-2048 ≤ disp ≤ 2047


o Target Address(TA) = (PC) + disp
o disp = TA – (PC)
o Eg: 0000 FIRST STL RETADR
- - - - - - -
- - - - - - -
0030 RETADR - - - - -- --
 Translate FIRST STL RETADR
 Hex code for STL is 14 => 0001 0100
 This is 8 bit wide. Delete the rightmost 2 bits and place the
remaining part in op fields.
 TA = address of RETADR (from SYMTAB)= (0030)16
 After fetching this instruction (PC) = (0003) 16
 disp = TA – (PC) = (0030)16 - (0003) 16= (002D) 16
 Take the rightmost 12 bit disp (02D)
 If n=i, this instruction is neither indirect nor immediate addressing
mode.

o Eg:
0006 CLOOP- - - -
- - - - - - -
- - - - - - -
0017 J CLOOP
 Translate J CLOOP
 Hex code for J is 3C => 0011 1100
 This is 8 bit wide. Delete the rightmost 2 bits and place the
remaining part in op fields.
2
Module System Software(S5
II CSE)
 TA = address of CLOOP (from SYMTAB)= (0006)16
 After fetching this instruction (PC) = (001A) 16
 disp = TA – (PC) = (0006)16 - (001A) 16= (FFEC) 16
 Take the rightmost 12 bit disp (FEC)

 Base Relative Addressing Mode


o The base register is under the control of the programmer. The
programmer must tell the assembler what the base register will contain
during the execution of the program.
o Base register is used to mention the displacement value.
o TA = (B) + disp
o Assembler directives used are:
 BASE: Informs the assembler that the base register will contain the
address of #operand
 NOBASE: Inform the assembler that the content of base register
can no longer be used for addressing.
o Eg:
0003 LDB #LENGTH
BASE LENGTH
---------------------
---------------------
0033 LENGTH RESW 1
0036 BUFFER RESW 4096
---------------------
---------------------
104E STCH BUFFER,X
---------------------
---------------------
 Translate STCH BUFFER,X
 LDB instruction loads the address of LENGTH in the base register.
 BASE directive explicitly tells the assembler that it has the value of
LENGTH.
 Hex code for STCH is 54 => 0101 0100
 This is 8 bit wide. Delete the rightmost 2 bits and place the
remaining part in op fields.
 TA = address of BUFFER (from SYMTAB)= (0036)16
 (B) = (0033)16
 disp = TA – (B) = (0036)16 - (0033) 16= (0003) 16
 Take the rightmost 12 bit disp (003)

 Immediate Addressing Mode


3
Module System Software(S5
II CSE)
o No memory reference is involved
o Eg:
0020 LDA #3
 Hex code for LDA is 00 => 0000 0000
 disp = TA = (0003)16

 Immediate with PC-relative mode


o Eg:
0003 LDB #LENGTH
---------------------
---------------------
0033 LENGTH RESW 1
 Translate LDB #LENGTH
 Hex code for LDB is 68 => 0110 1000
 TA = address of LENGTH = 0033
 After fetching this instruction (PC) = 0006
 disp = TA – (PC) = (0033)16– (0006)16 = (002D)16

 Indirect with PC-relative mode


o Eg:
002A J @RETADR
---------------------
---------------------
0030 RETADR RESW 1
 Translate J @RETADR
 Hex code for J is 3C => 0011 1100
 TA = address of RETADR = 0030
 After fetching this instruction (PC) = (002D)16
 disp = TA – (PC) = (0030)16– (002D)16 = (0003)16

 Extended Instruction Format


o Eg: +LDT #4096
 Hex code for LDT is 74 => 0111 0100
 TA = (01000)16

o Program Relocation
 Absolute Program
4
Module System Software(S5
II CSE)
 The program must be loaded at the address that specified at assembly time.
 Need for program relocatable
 Sometimes it is required to load and run several programs at the same time.
 The system must be able to load these programs wherever there is place in the
memory.
 The exact starting is not known until the load time.
 Consider the following SIC\XE program
COPY START 0
0000 - - - - - - - - - - - - - - - - - - - - -
---------------------
0006 CLOOP +JSUB RDREC 4B101036
---------------------
---------------------
1036 RDREC CLEAR X B410

 The above diagram shows the concept of relocation. Initially the program is
loaded at location 0000. The instruction JSUB is loaded at location 0006. The
address field of this instruction contains 01036, which is the address of the
instruction labeled RDREC.
 The second figure shows that if the program is to be loaded at new location
5000. The address of the instruction JSUB gets modified to new location 6036.
 The third figure shows that if the program is relocated at location 7420, the
JSUB instruction would need to be changed to 4B108456 that correspond to
the new address of RDREC.

 Some instructions do not require modification.


o Instruction operand is not a memory address.
 Eg: LDA #3
o Instruction address is specified using PC relative or Base relative
 Eg: STL RETADR
It is assembled using PC or Base relative addressing.
5
Module System Software(S5
II CSE)
 The only part of the program that require modification at load time are those
that specify direct addresses.
 The assembler can identify those part of object program that need
modification.
 Relocatable program is a program that can be loaded into memory where
there is a room, rather than specifying a fixed address at assembly time.
 Relocatable programs use a Modification record to store the starting location
and the length of the address field to be modified.
 Modification Record format:

o It is placed in between last text record and end record.


o One modification record is created for each address to be modified.
o The length is stored in half-bytes (4 bits).
o The starting location is the location of the byte containing the leftmost
bits of the address field to be modified. If the length field contains an odd
number of half-bytes, the starting location begins in the middle of the
first byte.
 Object Program Format is:

 The object program is:

6
Module System Software(S5
II CSE)

Previous Year University Questions


1. Explain with suitable examples, how the different instruction formats and addressing
modes of SIC/XE is handled during assembling.
2. Suppose the address associated with the symbol RETADR is 0030 and the machine
equivalent code for STL is 14. Assemble the given SIC/XE instruction, by clearly
indicating the instruction format, addressing mode and the setting of different flag bits,
given the address value assigned to RETADR is 0030.

3. With suitable example, explain the concept of Program Relocation.


4. Write down the format of Modification record. Describe each field with the help of an
example
5. What will happen if a SIC program is loaded in a location different from the starting address
specified in the program? Will the program work properly? Justify your answer
6. Explain program relocation with examples. Is there a need to use modification records for the
given SIC/XE program segment? Explain your answer. If yes, show the contents of
modification record
7. What is a relocatable program? Do all instructions of SIC/XE machine program need
modification because of relocation? Justify your answer

You might also like