0% found this document useful (0 votes)
22 views

04 Assimpler1

The document discusses systems programming and assemblers. It covers basic assembler functions like indexed addressing and comments. It describes how a two-pass assembler works by doing one pass to assign addresses and a second pass to do the actual translation. It discusses the object code file format and key assembler data structures like the operation code table and symbol table that are used during the two passes. Examples are provided of assembler output from the first and second passes for simple SIC/XE assembly programs.

Uploaded by

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

04 Assimpler1

The document discusses systems programming and assemblers. It covers basic assembler functions like indexed addressing and comments. It describes how a two-pass assembler works by doing one pass to assign addresses and a second pass to do the actual translation. It discusses the object code file format and key assembler data structures like the operation code table and symbol table that are used during the two passes. Examples are provided of assembler output from the first and second passes for simple SIC/XE assembly programs.

Uploaded by

ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Systems Programming

Basic Assembler Function


Assembler Program

 Modifier X used for indexed addressing


 Dot (.) used for comments
 Assembler directives are used
Assembler Program

 The program use routine reads records from


input device (F1) to output device (05)
 RDREC is a subroutine Reads a record from
input to buffer
 WRREC is a subroutine Writes a record from
buffer to output
 It sends one char. At a time using RD and
WD instructions
 at end of each record put a null char. (Hex
00)
 (EOF) is char used as end of file
A simple SIC assembler

 This is the program with object code


 The program starts at address 1000
 To get object code the assembler do
Two pass Assembler

 RETADR is a forward reference defined later.


 We do not know the address will be assigned to RETADR
 So most assemblers do two passes over the source
program
 1st pass scans source Prog. For labels and assign
addresses
 2nd pass do the actual translation
 Assembler process the directives (not translated to
machine code)
 Examples (BYTE, WORD, RESB, RESW, START,
END)
The object code file

 The object file format contains three types of records


HEADER, TEXT, and END
The object code file
Two pass Assemblers functions
 The functions of the 2 pass assemblers are
Assemblers Data Structure

Operation Code Table (OPTAB)


 Lookup mnemonic operation codes and translate them to Machine code
 Also contains instruction format and length
 In Pass1 : lookup and validate op codes in source program
 In pass 2: Translates the op codes to machine languages
 Usually organized as hash table
Assemblers Data Structure
Symbol Table (SYMTAB)
 Store addresses assigned to labels (Name, Value) pair
 Contains Error Flags (e.g., a symbol defined in two different places)
 In Pass1 : Labels are entered to SYMTAB with there assigned addresses
 In pass 2: lookup the label address and insert it to the instruction
 Usually organized as hash table

Location Counter (LOCCTR)


 VARIABLE used in assigning addresses and initialized by the address in START
statement
Example 1
Example 1
 Pass 1 output
Example 1
 Pass 2 output
Machine dependent Assembler features
 Examining the effect of extended hardware in SIC/XE machine on the structure and function of the
assembler
 The same program rewritten by taken the advantages of SIC/XE instructions (e.g., Register-
Register instructions)
Machine dependent Assembler features
 Indirect addressing referred by @ sign to operand
 Immediate operand referred by # sign
 If the address is too big Format 4 instruction is used (prefix +)
Instruction format and addressing modes

 There different instruction format and


addressing modes
 Start address is zero (Relocatable program)
 Register to register (e.g. COMPR) 
OPCODE + EACH REGISTER CODE
 SYMTAB is loaded with reg. names and
corresponding codes (A,X,etc.)  (0,1,etc.)
Instruction format and addressing modes

 Register to Memory is (PC) relative or (B) relative


 So displacement need to be calculated to be part of
object code
 If displacement too large format 4 instruction(20 bit
address) must be used

 1036 is the address and e=1 for format 4


 Programmer uses + prefix to indicate format 4
instruction
Instruction format and addressing modes

 This is program counter (PC) relative


instruction
 (PC) contains the address of the next
instruction (0003)
 RETADR (line 95) is assigned the address
0030 (from SYMTAB)
 So, the displacement = 30-3=2D
 Bit p is set to 1 (PC relative)
Example 2
 Write the output of pass 1 and pass 2 for the following SIC/XE assembly program
Example 2: Pass1
Example 2 : Pass 2
Example 3
 Write the output of pass 1 and pass 2 for the following SIC/XE assembly program
Example 3: Pass1
Example 3: Pass 2
Example 3: Pass 2
Example 3: Pass 2

You might also like