SlideShare a Scribd company logo
1 of 63
Module -II
Assembler
BLDEA'S CET MCA
System Programming
1.Explain the SIC Machine Architecture.
2. Explain the SIC/ XE Machine Architecture.
3.Write an algorithm for pass1 and pass2 of assemblers and explain.
4.Explain the Fallowing1.LDA 2.Jsub 3.TIX 4.Symbol Table
5.Forward reference.
5. Define system software,. Differentiate system software and
application software with examples
6.What is an Assembler directive? Explain the fallowing directive
with example. (1).START (2).BYTE (3).WORD (4).RESB
System Programming
Hypothetical machine
Processor architecture
Main
memory
Simplified
Instructional
Computer
(SIC)
Size=64K
B
Memory Address
=2 Bytes
Word length
Accumulator, Registers X,
L
Main Memory
4000
4003
4006
4009
4012
3 BytesByte Byte Byte
Byte Byte Byte
Address:
2 bytes
Assembler Directives
 Assembler directives are pseudo instructions
◦ They will not be translated into machine instructions.
◦ They only provide instruction/direction/information to
the assembler.
 Basic assembler directives :
◦ START :
 Specify name and starting address for the program
 Ex: COPY START 1000
◦ END :
 Indicate the end of the source program, and (optionally)
the first executable instruction in the program.
 Ex: END FIRST
BLDEA'S CET MCA
System Programming
Assembler Directives
(cont’d)
◦ BYTE :
 Generate character or hexadecimal constant, occupying as
many bytes as needed to represent the constant.
 Ex: EOF BYTE C’EOF’
◦ WORD :
 Generate one-word integer constant
 Ex: THREE WORD 3
◦ RESB :
 Reserve the indicated number of bytes for a data area
 Ex: BUFFER RESB 4096
◦ RESW :
 Reserve the indicated number of words for a data area
 Ex: LENGTH RESW 1
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
E=69(ASCII)=45 O=79(ASCII)=4F, F=70(ASCII)=46
BLDEA'S CET MCA
System Programming
Object code for SIC
System Programming
System Programming
• Convert mnemonic operation codes to their machine language
equivalents.
Ex: translate STL to 14(line 10).
• Convert symbolic operands to their equivalent machine addresses
Ex: translate RETADR to 1033(line 10).
• Build the machine instructions in the proper format.
• Convert the data constants specified in the source program into their
to internal machine representations
Ex: translate EOF to 454F46 (Line 80).
• Write the object program and the assembly listing .
Steps to Generate Object code
BLDEA'S CET MCA
System Programming
Object Program Format
 Header
Col. 1 H
Col. 2~7 Program name
Col. 8~13 Starting address of object program (hex)
Col. 14-19 Length of object program in bytes (hex)
 Text
Col.1 T
Col.2~7 Starting address for object code in this record (hex)
Col. 8~9 Length of object code in this record in bytes (hex)
Col. 10~69 Object code, represented in hexa (2 col. per byte)
 End
Col.1 E
Col.2~7 Address of first executable instruction in object program
(hex)
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
Three Main Data Structures
 Operation Code Table (OPTAB)
 Symbol Table (SYMTAB)
 Location Counter (LOCCTR)
BLDEA'S CET MCA
System Programming
OPTAB (operation code
table)
 Content
◦ The mapping between mnemonic and machine
code. Also include the instruction format, available
addressing modes, and length information.
 Characteristic
◦ Static table. The content will never change.
 Implementation
◦ Array or hash table. Because the content will never
change, we can optimize its search speed.
 In pass 1, OPTAB is used to look up and
validate mnemonics in the source program.
 In pass 2, OPTAB is used to translate
mnemonics to machine instructions.
BLDEA'S CET MCA
System Programming
Instruction Op code Addressing
modes
Length
(bytes)
ADD m 18 D 3
LDA m 00 D 3
BLDEA'S CET MCA
System Programming
Symbol Table (SYMTAB)
 Content
◦ Include the label name and value (address) for
each label in the source program.
◦ Include type and length information (e.g., int64)
◦ With flag to indicate errors (e.g., a symbol
defined in two places)
 Characteristic
◦ Dynamic table (I.e., symbols may be inserted,
deleted, or searched in the table) , The content
will change.
 Implementation
◦ Hash table can be used to speed up search
◦ Because variable names may be very similar
(e.g., LOOP1, LOOP2), the selected hash
function must perform well with such non-
random keys.
COPY 1000
FIRST 1000
CLOOP 1003
ENDFIL 1015
EOF 1024
THREE 102D
ZERO 1030
RETADR 1033
LENGTH 1036
BUFFER 1039
RDREC 2039
BLDEA'S CET MCA
System Programming
Location Counter (LOCCTR)
 This variable can help in the assignment of
addresses.
 It is initialized to the beginning address
specified in the START statement.
 After each source statement is processed,
the length of the assembled instruction and
data area to be generated is added to
LOCCTR.
 Thus, when we reach a label in the source
program, the current value of LOCCTR gives
the address to be associated with that label.
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
The Pseudo Code for Pass 1
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
The Pseudo Code for Pass 2
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
Assembler – Machine Dependent
Features
• Instruction formats and addressing
modes
• Program relocation.
BLDEA'S CET MCA
System Programming
Object code for SIC/XE
Example
BLDEA'S CET MCA
System Programming
SIC/XE Example
BLDEA'S CET MCA
System Programming
SIC/XE Example
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
Instruction Format and Addressing
Mode
 SIC/XE
◦ PC-relative or Base-relative addressing: op m
◦ Indirect addressing: op @m
◦ Immediate addressing: op #c
◦ Extended format: +op
m
◦ Index addressing: op
m,x
◦ Rule Table……..
BLDEA'S CET MCA
System Programming
Addressing
modes
Simple n=1 i=1
@Indirect
addressing
n=1 i=0
#Immediate
addressing
n=0 i=1
Indexed
addressing
x=1
Base Relative b=1 p=0
Program
counter
Relative
b=0 p=1
Direct b=0 p=1
OPCODE e Address
6 bits 12 bits
n i x b p
1 1 1 1 1 1
BLDEA'S CET MCA
System Programming
Format3 vs Format4
OPCODE e Address
6 bits 12 bits
n i x b p
1 1 1 1 1 0
OPCODE e Address
6 bits 20 bits
n i x b p
1 1 1 1 1 1
Format3
Format4
BLDEA'S CET MCA
System Programming
A Case of Object Code Generation
 Figure 2.6, Line 10
STL RETADR  17 20 2D
STL opcode 14
 The mode bit p=1, meaning PC relative
addressing mode.
OPCODE e Address
6 bits 12 bits
n i x b p
0001 01 0 0000 0010 11011 1 0 0 1
17 2D20
TA=(PC)+Displacement
Displacement = TA-(PC)
Displacement= RETADR - PC = 30-3 = 2D
1 1 1 1 1 1
bits
BLDEA'S CET MCA
System Programming
# Immediate Address Translation
 Immediate addressing
◦ 25 000D COMP #0 290000
◦ COMP opcode 28
◦ 2 9 0 0 0 0
◦ 55 0020 LDA #3 010003
OPCODE e Addressn i x b p
0010 10 0 0000 0000 00000 1 0 0 0
OPCODE e Addressn i x b p
0000 00 0 (003)160 1 0 0 0 BLDEA'S CET MCA
System Programming
# Immediate Address Translation
◦ 133 103C +LDT #4096
75101000
OPCODE e Addressn i x b p
0111 01 1 0000 0001 0000 0000 0000160 1 0 0 0
7 5 1 0 1 0 0 0
BLDEA'S CET MCA
System Programming
# Immediate Address Translation
(conti….) Immediate addressing
◦ 12 0003 LDB #LENGTH 69202D
 The immediate operand is the symbol LENGTH
 The address of this symbol LENGTH is loaded into register B
 LENGTH=0033 PC=0006
 TA=(PC)+Displacement
 Displacement = TA-(PC)
 Displacement= LENGTH - PC = 0033-0006 = 2D
OPCODE e Addressn i x b p
0110 10 0 0000 0010 11010 1 0 0 1
BLDEA'S CET MCA
System Programming
0 2 D296
@ Indirect Address
Translation
 Indirect addressing
◦ Target addressing is computed as usual
(PC-relative or BASE-relative)
◦ Only the n bit is set to 1
◦ 70 002A J @RETADR
3E2003
 J=3C , TA=RETADR=0030
 TA=(PC)+disp=0030=002D+disp
 disp=0030-002D=3
OPCODE e Addressn i x b p
0011 11 0 (003)161 0 0 0 1
BLDEA'S CET MCA
System Programming
Base relative Address
BLDEA'S CET MCA
System Programming
Base relative Address
 12 bits displacement (0 ~ 4095)
 Base register is under the control of the programmer.
◦ The programmer must tell the assembler what the base
register will contain during execution of program.
 Assembler directive
 BASE: tell the assembler what the base register will contain
 NOBASE: tell the assembler that the contents of the base
register can no longer be used for addressing.
 When based register can be relied upon, the assembler can use
base relative, otherwise only the PC-relative can be used
 The assembler first choose PC-relative; if displacement is not
enough, choose base relative BLDEA'S CET MCA
System Programming
Base relative :ex1
12 0003 LDB #LENGTH 69202D
13 BASE LENGTH
: :
100 0033 LENGTH RESW 1
105 0036 BUFFER RESB 4096
: :
160 104E STCH BUFFER,X 57C003
165 1051 TIXR T B850
BLDEA'S CET MCA
System Programming
Base relative
 PC-relative is no longer applicable
 (0036)-(1051) = -4123 < (-2048)
 LDB loads the address of LENGTH into base
register during execution
 BASE directive explicitly informs the assembler
that the base register will contain the address
of LENGTH
System Programming
BLDEA'S CET MCA
System Programming
Base relative :ex2
=-4134(10)
BLDEA'S CET MCA
System Programming
Base-Relative Addressing
Modes Base-relative
◦ Base register is under the control of the programmer
◦ 1056 STX LENGTH
1 3 4 0 0 0
OPCODE e Addressn i x b p
0001 00 0 0000 0000 00001 1 0 1 0
TA=(B)+Displacement
Displacement = TA-(B)
Displacement= LENGTH- B = 0033-0033= 0000
BLDEA'S CET MCA
System Programming
PC-relative v/s Base Relative
1. Programmer must specify the extended
format (4-byte) by using the prefix +
2. If not, assembler first attempts PC-relative
3. If the required displacement is out of range,
use
base relative addressing can be use
4. Otherwise, generate an error message
BLDEA'S CET MCA
System Programming
Register-register Address Translation
Mnemonic Number Use
A 0 Accumulator; used for arithmetic operati
X 1 Index register; used for addressing
L 2 Linkage register; JSUB
PC 8 Program counter
B 3 Base register
S 4 General working register
T 5 General working register
F 6 Floating-point accumulator (48 bits)
BLDEA'S CET MCA
System Programming
Register-register instruction object
code
 Convert the mnemonic name to their
number equivalents
 Register name (A, X, L, B, S, T, F, PC,
SW) and their values (0, 1, 2, 3, 4, 5,
6, 8, 9)
 May implement in a separate table or
preload the register names and values to
SYMTAB
BLDEA'S CET MCA
System Programming
OPCODE e RDREC (Address)n i x b p
0100 10 1 0000 0001 0000 0011 0110161 1 0 0 0
Program Relocation
+JSUB RDREC (Jump to the adress,1036)
opcode for JSUB =48
4 B 1 0 1 0 3 6
+JSUB WRREC (Jump to the adress,105D)
opcode for JSUB =48
OPCODE e WRREC(Address)n i x b p
0100 10 1 0000 0001 0000 0101 1101161 1 0 0 0
4 B 1 0 1 0 5 DBLDEA'S CET MCA
System Programming
Program Relocation
BLDEA'S CET MCA
System Programming
 Example Fig. 2.7
◦ Except for absolute address, the rest of the
instructions need not be modified
 not a memory address (immediate addressing)
 PC-relative, Base-relative
◦ The only parts of the program that require
modification at load time are those that specify
direct addresses
BLDEA'S CET MCA
System Programming
Relocatable Program
Modification record
◦ Col 1 M
◦ Col 2-7 Starting location of the address field to be
modified, relative to the beginning of the program
◦ Col 8-9 length of the address field to be modified, in half-
bytes
BLDEA'S CET MCA
System Programming
Object Code
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
BLDEA'S CET MCA
System Programming
System Programming
Implementation Examples
 Microsoft MASM Assembler
 Sun Sparc Assembler
Microsoft MASM Assembler
1.MASAM assembler is written for Pentium and other x86
systems.
2.Since x86 system views memory as a collection of
segments.
3.An MASM assembler language program is written as a
collection of segments.
4.Each segment is defined as belonging to a particular
class: CODE, DATA, CONST, STACK
System Programming
Microsoft MASM Assembler
 SEGMENT
◦ a collection segments, each segment is defined as
belonging to a particular class, CODE, DATA,
CONST, STACK
◦ registers: CS (code), SS (stack), DS (data), ES, FS,
GS
System Programming
Microsoft MASM Assembler
Jump instructions are assembled in 2 different ways:
1.Near jump: jump to a target in the same code segment o
2- or 3-byte instruction
Ex:JMP SHORT TARGET
2. Far jump: jump to a target in a different code segment o
5-byte instruction
EX:JMP FAR PTR TARGET
Jump with forward reference
MASM assumes that a forward jump is a near jump
If it is a far jump, programmer must tell the assembler
E.g. JMP FAR PTR TARGET
System Programming
Sun Sparc Assembler
 SPARC (Scalable Processor Architecture) IS originally developed
by Sun Microsystems.
Sections
.TEXT //Executable instructions
.DATA //Initialized read/write data
.RODATA //Read only data
.BSS //uninitialized data areas
System Programming

More Related Content

What's hot

Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)bolovv
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 
Unit 6 assembly language programming
Unit 6   assembly language programmingUnit 6   assembly language programming
Unit 6 assembly language programmingKartik Sharma
 
Chapter 2 instructions language of the computer
Chapter 2 instructions language of the computerChapter 2 instructions language of the computer
Chapter 2 instructions language of the computerBATMUNHMUNHZAYA
 
11 instruction sets addressing modes
11  instruction sets addressing modes 11  instruction sets addressing modes
11 instruction sets addressing modes Sher Shah Merkhel
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formatsMazin Alwaaly
 
Chapter Seven(1)
Chapter Seven(1)Chapter Seven(1)
Chapter Seven(1)bolovv
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programmingMakerere university
 
PLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe ProgrammersPLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe ProgrammersSrinimf-Slides
 
Program execution, straight line sequence and branching
Program execution, straight line sequence and branchingProgram execution, straight line sequence and branching
Program execution, straight line sequence and branchingJyotiprakashMishra18
 
Notes fp201-pointer notes
Notes fp201-pointer notesNotes fp201-pointer notes
Notes fp201-pointer notesSiti Nadirah
 
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlB.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlRai University
 

What's hot (20)

Chapter Seven(2)
Chapter Seven(2)Chapter Seven(2)
Chapter Seven(2)
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
Introduction to HDLs
Introduction to HDLsIntroduction to HDLs
Introduction to HDLs
 
Unit 6 assembly language programming
Unit 6   assembly language programmingUnit 6   assembly language programming
Unit 6 assembly language programming
 
Sp chap2
Sp chap2Sp chap2
Sp chap2
 
Assembler
AssemblerAssembler
Assembler
 
Chapter 2 instructions language of the computer
Chapter 2 instructions language of the computerChapter 2 instructions language of the computer
Chapter 2 instructions language of the computer
 
C language
C languageC language
C language
 
11 instruction sets addressing modes
11  instruction sets addressing modes 11  instruction sets addressing modes
11 instruction sets addressing modes
 
Assembler
AssemblerAssembler
Assembler
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
Chapter Seven(1)
Chapter Seven(1)Chapter Seven(1)
Chapter Seven(1)
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
Mips
MipsMips
Mips
 
PLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe ProgrammersPLI Presentation for Mainframe Programmers
PLI Presentation for Mainframe Programmers
 
Lec02
Lec02Lec02
Lec02
 
Program execution, straight line sequence and branching
Program execution, straight line sequence and branchingProgram execution, straight line sequence and branching
Program execution, straight line sequence and branching
 
Notes fp201-pointer notes
Notes fp201-pointer notesNotes fp201-pointer notes
Notes fp201-pointer notes
 
Compilers
CompilersCompilers
Compilers
 
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed controlB.sc cs-ii-u-3.1-basic computer programming and micro programmed control
B.sc cs-ii-u-3.1-basic computer programming and micro programmed control
 

Similar to System Software

assembler_full_slides.ppt
assembler_full_slides.pptassembler_full_slides.ppt
assembler_full_slides.pptAshwini864432
 
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics Felipe Prado
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler ProgrammingOmar Sanchez
 
8086 module 1 & 2 work
8086 module 1 & 2   work8086 module 1 & 2   work
8086 module 1 & 2 workSuhail Km
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly LanguageAhmed M. Abed
 
Introduction to computer architecture .pptx
Introduction to computer architecture .pptxIntroduction to computer architecture .pptx
Introduction to computer architecture .pptxFatma Sayed Ibrahim
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorDarling Jemima
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Siraj Ahmed
 
8086 Micro-processor and MDA 8086 Trainer Kit
8086 Micro-processor and MDA 8086 Trainer Kit8086 Micro-processor and MDA 8086 Trainer Kit
8086 Micro-processor and MDA 8086 Trainer KitAmit Kumer Podder
 
Pai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadPai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadYogesh Deshpande
 
Computer Organization & Architecture (COA)Unit 4
Computer Organization & Architecture (COA)Unit 4Computer Organization & Architecture (COA)Unit 4
Computer Organization & Architecture (COA)Unit 4parthivrathodlits
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.pptJaya Chavan
 
Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and designmahesh kumar prajapat
 

Similar to System Software (20)

assembler_full_slides.ppt
assembler_full_slides.pptassembler_full_slides.ppt
assembler_full_slides.ppt
 
Assembler
AssemblerAssembler
Assembler
 
Assembler
AssemblerAssembler
Assembler
 
Assembler
AssemblerAssembler
Assembler
 
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler Programming
 
8086 module 1 & 2 work
8086 module 1 & 2   work8086 module 1 & 2   work
8086 module 1 & 2 work
 
Lecture9
Lecture9Lecture9
Lecture9
 
amba.ppt
amba.pptamba.ppt
amba.ppt
 
Part III: Assembly Language
Part III: Assembly LanguagePart III: Assembly Language
Part III: Assembly Language
 
Introduction to computer architecture .pptx
Introduction to computer architecture .pptxIntroduction to computer architecture .pptx
Introduction to computer architecture .pptx
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
 
8086 Micro-processor and MDA 8086 Trainer Kit
8086 Micro-processor and MDA 8086 Trainer Kit8086 Micro-processor and MDA 8086 Trainer Kit
8086 Micro-processor and MDA 8086 Trainer Kit
 
Pai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_uploadPai unit 1_l1-l2-l3-l4_upload
Pai unit 1_l1-l2-l3-l4_upload
 
Computer Organization & Architecture (COA)Unit 4
Computer Organization & Architecture (COA)Unit 4Computer Organization & Architecture (COA)Unit 4
Computer Organization & Architecture (COA)Unit 4
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.ppt
 
Basic computer organization and design
Basic computer organization and designBasic computer organization and design
Basic computer organization and design
 
Ch2 csda
Ch2 csdaCh2 csda
Ch2 csda
 
C programming part2
C programming part2C programming part2
C programming part2
 

Recently uploaded

UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

System Software

  • 1. Module -II Assembler BLDEA'S CET MCA System Programming
  • 2. 1.Explain the SIC Machine Architecture. 2. Explain the SIC/ XE Machine Architecture. 3.Write an algorithm for pass1 and pass2 of assemblers and explain. 4.Explain the Fallowing1.LDA 2.Jsub 3.TIX 4.Symbol Table 5.Forward reference. 5. Define system software,. Differentiate system software and application software with examples 6.What is an Assembler directive? Explain the fallowing directive with example. (1).START (2).BYTE (3).WORD (4).RESB System Programming
  • 4. Word length Accumulator, Registers X, L Main Memory 4000 4003 4006 4009 4012 3 BytesByte Byte Byte Byte Byte Byte Address: 2 bytes
  • 5. Assembler Directives  Assembler directives are pseudo instructions ◦ They will not be translated into machine instructions. ◦ They only provide instruction/direction/information to the assembler.  Basic assembler directives : ◦ START :  Specify name and starting address for the program  Ex: COPY START 1000 ◦ END :  Indicate the end of the source program, and (optionally) the first executable instruction in the program.  Ex: END FIRST BLDEA'S CET MCA System Programming
  • 6. Assembler Directives (cont’d) ◦ BYTE :  Generate character or hexadecimal constant, occupying as many bytes as needed to represent the constant.  Ex: EOF BYTE C’EOF’ ◦ WORD :  Generate one-word integer constant  Ex: THREE WORD 3 ◦ RESB :  Reserve the indicated number of bytes for a data area  Ex: BUFFER RESB 4096 ◦ RESW :  Reserve the indicated number of words for a data area  Ex: LENGTH RESW 1 BLDEA'S CET MCA System Programming
  • 8. E=69(ASCII)=45 O=79(ASCII)=4F, F=70(ASCII)=46 BLDEA'S CET MCA System Programming Object code for SIC
  • 11. • Convert mnemonic operation codes to their machine language equivalents. Ex: translate STL to 14(line 10). • Convert symbolic operands to their equivalent machine addresses Ex: translate RETADR to 1033(line 10). • Build the machine instructions in the proper format. • Convert the data constants specified in the source program into their to internal machine representations Ex: translate EOF to 454F46 (Line 80). • Write the object program and the assembly listing . Steps to Generate Object code BLDEA'S CET MCA System Programming
  • 12. Object Program Format  Header Col. 1 H Col. 2~7 Program name Col. 8~13 Starting address of object program (hex) Col. 14-19 Length of object program in bytes (hex)  Text Col.1 T Col.2~7 Starting address for object code in this record (hex) Col. 8~9 Length of object code in this record in bytes (hex) Col. 10~69 Object code, represented in hexa (2 col. per byte)  End Col.1 E Col.2~7 Address of first executable instruction in object program (hex) BLDEA'S CET MCA System Programming
  • 13. BLDEA'S CET MCA System Programming
  • 14. Three Main Data Structures  Operation Code Table (OPTAB)  Symbol Table (SYMTAB)  Location Counter (LOCCTR) BLDEA'S CET MCA System Programming
  • 15. OPTAB (operation code table)  Content ◦ The mapping between mnemonic and machine code. Also include the instruction format, available addressing modes, and length information.  Characteristic ◦ Static table. The content will never change.  Implementation ◦ Array or hash table. Because the content will never change, we can optimize its search speed.  In pass 1, OPTAB is used to look up and validate mnemonics in the source program.  In pass 2, OPTAB is used to translate mnemonics to machine instructions. BLDEA'S CET MCA System Programming
  • 16. Instruction Op code Addressing modes Length (bytes) ADD m 18 D 3 LDA m 00 D 3 BLDEA'S CET MCA System Programming
  • 17. Symbol Table (SYMTAB)  Content ◦ Include the label name and value (address) for each label in the source program. ◦ Include type and length information (e.g., int64) ◦ With flag to indicate errors (e.g., a symbol defined in two places)  Characteristic ◦ Dynamic table (I.e., symbols may be inserted, deleted, or searched in the table) , The content will change.  Implementation ◦ Hash table can be used to speed up search ◦ Because variable names may be very similar (e.g., LOOP1, LOOP2), the selected hash function must perform well with such non- random keys. COPY 1000 FIRST 1000 CLOOP 1003 ENDFIL 1015 EOF 1024 THREE 102D ZERO 1030 RETADR 1033 LENGTH 1036 BUFFER 1039 RDREC 2039 BLDEA'S CET MCA System Programming
  • 18. Location Counter (LOCCTR)  This variable can help in the assignment of addresses.  It is initialized to the beginning address specified in the START statement.  After each source statement is processed, the length of the assembled instruction and data area to be generated is added to LOCCTR.  Thus, when we reach a label in the source program, the current value of LOCCTR gives the address to be associated with that label. BLDEA'S CET MCA System Programming
  • 19. BLDEA'S CET MCA System Programming
  • 20. BLDEA'S CET MCA System Programming
  • 21. The Pseudo Code for Pass 1 BLDEA'S CET MCA System Programming
  • 22. BLDEA'S CET MCA System Programming
  • 23. BLDEA'S CET MCA System Programming
  • 24. The Pseudo Code for Pass 2 BLDEA'S CET MCA System Programming
  • 25. BLDEA'S CET MCA System Programming
  • 26. BLDEA'S CET MCA System Programming
  • 27. Assembler – Machine Dependent Features • Instruction formats and addressing modes • Program relocation. BLDEA'S CET MCA System Programming
  • 28. Object code for SIC/XE Example BLDEA'S CET MCA System Programming
  • 29. SIC/XE Example BLDEA'S CET MCA System Programming
  • 30. SIC/XE Example BLDEA'S CET MCA System Programming
  • 31. BLDEA'S CET MCA System Programming
  • 32. Instruction Format and Addressing Mode  SIC/XE ◦ PC-relative or Base-relative addressing: op m ◦ Indirect addressing: op @m ◦ Immediate addressing: op #c ◦ Extended format: +op m ◦ Index addressing: op m,x ◦ Rule Table…….. BLDEA'S CET MCA System Programming
  • 33. Addressing modes Simple n=1 i=1 @Indirect addressing n=1 i=0 #Immediate addressing n=0 i=1 Indexed addressing x=1 Base Relative b=1 p=0 Program counter Relative b=0 p=1 Direct b=0 p=1 OPCODE e Address 6 bits 12 bits n i x b p 1 1 1 1 1 1 BLDEA'S CET MCA System Programming
  • 34. Format3 vs Format4 OPCODE e Address 6 bits 12 bits n i x b p 1 1 1 1 1 0 OPCODE e Address 6 bits 20 bits n i x b p 1 1 1 1 1 1 Format3 Format4 BLDEA'S CET MCA System Programming
  • 35. A Case of Object Code Generation  Figure 2.6, Line 10 STL RETADR  17 20 2D STL opcode 14  The mode bit p=1, meaning PC relative addressing mode. OPCODE e Address 6 bits 12 bits n i x b p 0001 01 0 0000 0010 11011 1 0 0 1 17 2D20 TA=(PC)+Displacement Displacement = TA-(PC) Displacement= RETADR - PC = 30-3 = 2D 1 1 1 1 1 1 bits BLDEA'S CET MCA System Programming
  • 36. # Immediate Address Translation  Immediate addressing ◦ 25 000D COMP #0 290000 ◦ COMP opcode 28 ◦ 2 9 0 0 0 0 ◦ 55 0020 LDA #3 010003 OPCODE e Addressn i x b p 0010 10 0 0000 0000 00000 1 0 0 0 OPCODE e Addressn i x b p 0000 00 0 (003)160 1 0 0 0 BLDEA'S CET MCA System Programming
  • 37. # Immediate Address Translation ◦ 133 103C +LDT #4096 75101000 OPCODE e Addressn i x b p 0111 01 1 0000 0001 0000 0000 0000160 1 0 0 0 7 5 1 0 1 0 0 0 BLDEA'S CET MCA System Programming
  • 38. # Immediate Address Translation (conti….) Immediate addressing ◦ 12 0003 LDB #LENGTH 69202D  The immediate operand is the symbol LENGTH  The address of this symbol LENGTH is loaded into register B  LENGTH=0033 PC=0006  TA=(PC)+Displacement  Displacement = TA-(PC)  Displacement= LENGTH - PC = 0033-0006 = 2D OPCODE e Addressn i x b p 0110 10 0 0000 0010 11010 1 0 0 1 BLDEA'S CET MCA System Programming 0 2 D296
  • 39. @ Indirect Address Translation  Indirect addressing ◦ Target addressing is computed as usual (PC-relative or BASE-relative) ◦ Only the n bit is set to 1 ◦ 70 002A J @RETADR 3E2003  J=3C , TA=RETADR=0030  TA=(PC)+disp=0030=002D+disp  disp=0030-002D=3 OPCODE e Addressn i x b p 0011 11 0 (003)161 0 0 0 1 BLDEA'S CET MCA System Programming
  • 40. Base relative Address BLDEA'S CET MCA System Programming
  • 41. Base relative Address  12 bits displacement (0 ~ 4095)  Base register is under the control of the programmer. ◦ The programmer must tell the assembler what the base register will contain during execution of program.  Assembler directive  BASE: tell the assembler what the base register will contain  NOBASE: tell the assembler that the contents of the base register can no longer be used for addressing.  When based register can be relied upon, the assembler can use base relative, otherwise only the PC-relative can be used  The assembler first choose PC-relative; if displacement is not enough, choose base relative BLDEA'S CET MCA System Programming
  • 42. Base relative :ex1 12 0003 LDB #LENGTH 69202D 13 BASE LENGTH : : 100 0033 LENGTH RESW 1 105 0036 BUFFER RESB 4096 : : 160 104E STCH BUFFER,X 57C003 165 1051 TIXR T B850 BLDEA'S CET MCA System Programming
  • 43. Base relative  PC-relative is no longer applicable  (0036)-(1051) = -4123 < (-2048)  LDB loads the address of LENGTH into base register during execution  BASE directive explicitly informs the assembler that the base register will contain the address of LENGTH System Programming BLDEA'S CET MCA System Programming
  • 44. Base relative :ex2 =-4134(10) BLDEA'S CET MCA System Programming
  • 45. Base-Relative Addressing Modes Base-relative ◦ Base register is under the control of the programmer ◦ 1056 STX LENGTH 1 3 4 0 0 0 OPCODE e Addressn i x b p 0001 00 0 0000 0000 00001 1 0 1 0 TA=(B)+Displacement Displacement = TA-(B) Displacement= LENGTH- B = 0033-0033= 0000 BLDEA'S CET MCA System Programming
  • 46. PC-relative v/s Base Relative 1. Programmer must specify the extended format (4-byte) by using the prefix + 2. If not, assembler first attempts PC-relative 3. If the required displacement is out of range, use base relative addressing can be use 4. Otherwise, generate an error message BLDEA'S CET MCA System Programming
  • 47. Register-register Address Translation Mnemonic Number Use A 0 Accumulator; used for arithmetic operati X 1 Index register; used for addressing L 2 Linkage register; JSUB PC 8 Program counter B 3 Base register S 4 General working register T 5 General working register F 6 Floating-point accumulator (48 bits) BLDEA'S CET MCA System Programming
  • 48. Register-register instruction object code  Convert the mnemonic name to their number equivalents  Register name (A, X, L, B, S, T, F, PC, SW) and their values (0, 1, 2, 3, 4, 5, 6, 8, 9)  May implement in a separate table or preload the register names and values to SYMTAB BLDEA'S CET MCA System Programming
  • 49. OPCODE e RDREC (Address)n i x b p 0100 10 1 0000 0001 0000 0011 0110161 1 0 0 0 Program Relocation +JSUB RDREC (Jump to the adress,1036) opcode for JSUB =48 4 B 1 0 1 0 3 6 +JSUB WRREC (Jump to the adress,105D) opcode for JSUB =48 OPCODE e WRREC(Address)n i x b p 0100 10 1 0000 0001 0000 0101 1101161 1 0 0 0 4 B 1 0 1 0 5 DBLDEA'S CET MCA System Programming
  • 50. Program Relocation BLDEA'S CET MCA System Programming
  • 51.  Example Fig. 2.7 ◦ Except for absolute address, the rest of the instructions need not be modified  not a memory address (immediate addressing)  PC-relative, Base-relative ◦ The only parts of the program that require modification at load time are those that specify direct addresses BLDEA'S CET MCA System Programming
  • 52. Relocatable Program Modification record ◦ Col 1 M ◦ Col 2-7 Starting location of the address field to be modified, relative to the beginning of the program ◦ Col 8-9 length of the address field to be modified, in half- bytes BLDEA'S CET MCA System Programming
  • 53. Object Code BLDEA'S CET MCA System Programming
  • 54. BLDEA'S CET MCA System Programming
  • 55. BLDEA'S CET MCA System Programming
  • 56. BLDEA'S CET MCA System Programming
  • 57. BLDEA'S CET MCA System Programming
  • 58. BLDEA'S CET MCA System Programming
  • 59. System Programming Implementation Examples  Microsoft MASM Assembler  Sun Sparc Assembler
  • 60. Microsoft MASM Assembler 1.MASAM assembler is written for Pentium and other x86 systems. 2.Since x86 system views memory as a collection of segments. 3.An MASM assembler language program is written as a collection of segments. 4.Each segment is defined as belonging to a particular class: CODE, DATA, CONST, STACK System Programming
  • 61. Microsoft MASM Assembler  SEGMENT ◦ a collection segments, each segment is defined as belonging to a particular class, CODE, DATA, CONST, STACK ◦ registers: CS (code), SS (stack), DS (data), ES, FS, GS System Programming
  • 62. Microsoft MASM Assembler Jump instructions are assembled in 2 different ways: 1.Near jump: jump to a target in the same code segment o 2- or 3-byte instruction Ex:JMP SHORT TARGET 2. Far jump: jump to a target in a different code segment o 5-byte instruction EX:JMP FAR PTR TARGET Jump with forward reference MASM assumes that a forward jump is a near jump If it is a far jump, programmer must tell the assembler E.g. JMP FAR PTR TARGET System Programming
  • 63. Sun Sparc Assembler  SPARC (Scalable Processor Architecture) IS originally developed by Sun Microsystems. Sections .TEXT //Executable instructions .DATA //Initialized read/write data .RODATA //Read only data .BSS //uninitialized data areas System Programming