SlideShare a Scribd company logo
1 of 40
ASSEMBLER
FUNCTION OF AN ASSEMBLER
ASSEMBLY
LANGUAGE
PROGRAM
ASSEMBLER
MACHINE
LANGUAGE
PROGRAM
DATABASES
ELEMENTS OF ASSEMBLY LANGUAGE
• MNEMONIC OPERATION CODES
• SYMBOLIC OPERANDS
• DATA DECLARATIONS
INSTRUCTION SET
INSTRUCTION OPCODE ASSEMBLY MNEMONIC REMARKS
00 STOP Stop execution
01 ADD First operand modified
02 SUB Condition code set
03 MULT
04 MOVER Memory to register move
05 MOVEM Register to memory move
06 COMP Compare(sets condition code)
07 BC Branch on condition
08 DIV
09 READ First operand is not used
10 PRINT
CONDITION CODES
CONDITION CODE
MNEMONIC
CODE PURPOSE
LT 1 Less than
LE 2 Less than or Equal to
EQ 3 Equal to
GT 4 Greater than
GE 5 Greater than or Equal to
ANY 6 Any
ASSEMBLY LANGUAGE STATEMENTS
• Imperative statements(IS)
Ex : ADD, SUB, etc..
• Declaration statements(DL)
[label] DS <constant>
[label] DC <value>
• Assembler directives(AD)
Declaration statements(DL)
i) Declare Storage(DS)
Ex : A DS 1
ii) Declare Constant(DC)
Ex : ONE DC ‘1’
Contd..
Assembler Directives(AD)
START <constant>
END [<operand specification>]
ORIGIN <address specification>
EQU
<symbol> EQU <operand specification>
LTORG
USING
DROP
GENERAL DESIGN PROCEDURE
• Specify the problem.
• Specify data structures.
• Define format of data structure.
• Specify the algorithm.
• Look for modularity(ie., capability of one
program to be subdivided into independent
programming units)
• Repeat one through five on modularity.
DESIGN OF AN ASSEMBLER
SOURCE PROGRAM :
JOHN START 0
USING *,15
L 1, FIVE
A 1, FOUR
ST 1, TEMP
FOUR DC F’4’
FIVE DC F’5’
TEMP DS 1F
END
Pseudo-op : START, USING, END, EQU
Symbols/Labels : FOUR, FIVE, TEMP, JOHN
Machine opcode : A, L, ST
FIRST PASS
Relative Address Mnemonic Instruction
0 L 1, -(0,15)
4 A 1,-(0,15)
8 ST 1,-(0,15)
12 4
16 5
20 -
SECOND PASS
Relative Address Mnemonic Instruction
0 L 1, 16(0,15)
4 A 1,12(0,15)
8 ST 1,20(0,15)
12 4
16 5
20 -
TASK OF AN ASSEMBLER
• Generate instructions
a) Evaluate the mnemonic in the operation
field to produce its machine code.
b) Evaluate the subfields – find the value of
each symbol, process literals, and assign
addresses.
• Process pseudo-ops.. ie., Check what was
given as Base Register, where is the
rel.address location starting from.
PASS 1 : Define symbols and literals
• Determine length of machine
instructions(MOTGET1)
• Keep track of Location Counter(LC)
• Remember values of symbols until
pass2(STSTO)
• Process some pseudo-ops, eg.,EQU,
DS(POTGET1)
• Remember literals(LITSIO)
PASS 2 – Generate object program
• Look up value of symbols(STGET)
• Generate instructions(MOTGET2)
• Generate data(for DS, DC, and literals)
• Process pseudo-ops(POTGET2)
3.ASSEMBLERS.docx
DATA STRUCTURE
PASS 1 DATA BASES
• Input source program.
• A Location Counter(LC).
• A table, Machine-Operation table(MOT).
• A table, Pseudo-Operation table(POT).
• A table, Symbol table(ST).
• A table, Literal table(LT).
• A copy of the input to be used later by Pass 2.
DATA STRUCTURE
PASS 2 DATA BASES
• Copy of source program input to pass1.
• Location Counter(LC).
• A table, Machine-Operation table(MOT).
• A table, Pseudo-Operation table(POT).
• A table, Symbol table(ST).
• A table, the Base table(BT).
• A Workspace, INST, that is used to hold each
instruction as its various parts are being assembled.
• A workspace, PRINTLINE.
• A workspace, PUNCH CARD.
• An Output deck of assembled instructions in the
format needed by the loader.
MACHINE-OP TABLE FOR PASS 1 &
PASS2
<-----------------------------------------6 BYTES PER ENTRY-------------------------------------------->
MNEMONIC
OP-CODE
(4-BYTES)
(CHARACTERS)
BINARY OP-
CODE(1-BYTE)
(HEXADECIMAL
)
INSTRUCTION
LENGTH(2-
BITS) (BINARY)
INSTRUCTION
FORMAT(3-
BITS) (BINARY)
NOT USED IN
THIS DESIGN(3-
BITS)
“Abbb” 5A 10 001
“AHbb” 4A 10 001
“ALbb” 5E 10 001
“ALRb” 1E 01 000
……
“MVCb” D2 11 100
....
CODES:
Instruction Length
01 = 1 half words = 2 bytes
10 = 2 half words = 4 bytes
11 = 3 half words = 6 bytes
Instruction Format
000 = RR
001 = RX
010 = RS
011 = SI
100 = SS
PSEUDO – OP TABLE (POT)FOR PASS1
<----------------------------------8 BYTES PER ENTRY-------------------------------------------------->
PSEUDO-OP (5 - BYTES) CHARACTER) ADDRESS OF ROUTINE TO PROCESS
PSEUDO – OP (3 BYTES = 24 BIT ADDRESS)
“DROPb” P1DROP
“ENDbb” P1END
“EQUbb” P1EQU
“START” P1START
“USING” P1USING
SYMBOL TABLE (ST) FOR PASS1 AND
PASS2
<----------------------------------14 BYTES PER ENTRY--------------------------------------------->
SYMBOL (8 BYTES)
(CHARACTERS)
VALUE (4 BYTES)
(HEXADECIMAL)
LENGTH (1 BYTE)
(HEXADECIMAL)
RELOCATION (1
BYTE) (CHARACTER)
“JOHNbbbb” 0000 01 “R”
“FOURbbbb” 000C 04 “R”
“FIVEbbbb” 0010 04 “R”
“TEMPbbbb” 0014 04 “R”
BASE TABLE(BT) FOR PASS2
<------------------------------------------4 BYTES PER ENTRY----------------------------------------->
AVAILABILITY
INDICATOR (1 -
BYTE)
(CHARACTER)
DESIGNATED
REL.ADDRESS
CONTENTS OF BASE
REGISTER (3 BYTES
= 24 BIT ADDRESS)
(HEXADECIMAL)
1 “N” -
2 “N” - 15
: : ENTRIES
14 “N” -
15 “Y” 00 00 00
SAMPLE ASSEMBLY SOURCE PROGRAM
STATEMENT
1 PRGAM START 0
2 USING *, 15
3 LA 15, SETUP
4 SR TOTAL, TOTAL
5 AC EQU 2
6 INDEX EQU 3
7 TOTAL EQU 4
8 DATABASE EQU 13
9 SETUP EQU *
10 USING SETUP, 15
11 L DATABASE, =A(DATA1)
12 USING DATAAREA, DATABASE
13 SR INDEX, INDEX
14 LOOP L AC, DATA1(INDEX)
CONTD..
15 AR TOTAL, AC
16 A AC, =F’5’
17 ST AC, SAVE(INDEX)
18 A INDEX, =F’4’
19 C INDEX, =F’8000’
20 BNE LOOP
21 LR 1, TOTAL
22 BR 14
23 LTORG
24 SAVE DS 2000F
25 DATAAREA EQU *
26 DATA1 DC F’25, 26, 97, 101, ……..
[2000 NUMBERS]
27 END
VARIABLE TABLES
SYMBOL TABLE
SYMBOL VALUE LENGTH RELOCATION
PRGAM2 0 1 R
AC 2 1 A
INDEX 3 1 A
TOTAL 4 1 A
DATABASE 13 1 A
SETUP 6 1 R
LOOP 12 4 R
SAVE 64 4 R
DATAAREA 8064 1 R
DATA1 8064 4 R
LITERAL TABLE
A(DATA) 48 4 R
F’5’ 52 4 R
F’4’ 56 4 R
F’8000’ 60 4 R
BASE TABLE (SHOWING ONLY BASE
REGISTERS IN USE)
1) AFTER STATEMENT 2 :
BASE CONTENTS
15 0
2) AFTER STATEMENT 10 :
BASE CONTENTS
15 6
3) AFTER STATEMENT 12
BASE CONTENTS
13 8064
15 6
GENERATED “MACHINE” CODE
CORRESPONDING
STMT NO.
LOCATION INSTRUCTION/DATUM
3 0 LA 15, 6(0, 15)
4 4 SR 4, 4
11 6 L 13, 42(0, 15)
13 10 SR 3, 3
14 12 L 2, 0(3, 13)
15 16 AR 4, 2
16 18 A 2, 46(0, 15)
17 22 ST 2, 58(3, 15)
18 26 A 3, 50(0, 15)
19 30 C 3, 54(0, 15)
20 34 BC 7, 6(0, 15)
21 38 LR 1, 4
22 40 BCR 15, 14
CONTD..
23 48 8064
52 X’00000005’
56 X’00000004’
60 8000
24 64 .
. .
. .
25 8064 X’00000019’
.
.
.
• 3.ASSEMBLERS.docx
LINEAR SEARCH
LA 4, SYMTBL
LOOP CLC 0(8,4), SYMBOL
BE SYMFOUND
A 4, =F’14’
C 4, LAST
BNE LOOP
NOTFOUND . (symbol not found)
.
.
SYMFOUND (symbol found)
.
.
.
SYMBOL DS CL14
SYMTBL DS 100CL14
LAST DC A(----)
BINARY SEARCH
L 5 , SIZE
SRL 5, 1
LR 6,5
LOOP SRL 6, 1
LA 4, SYMTBL(5)
CLC 0(8,4), SYMBOL
BE FOUND
BH TOOHIGH
TOOLOW AR 5, 6
B TESTEND
TOOHIGH SR 5, 6
TESTEND LTR 6, 6
BNZ LOOP
NOTFOUND (symbol not found)
.
.
.
FOUND (symbol found)
INTERCHANGE SORT EXAMPLE IN 360 ASSEMBLY CODE
L 5, LAST
LA 4, SYMTBL
LOOP CLC 0(8, 4), 14(4) COMPARE ADJACENT SYMBOLS – 8 BYTES
BNH OK CORRECT ORDER
MVC TEMP(14), 0(4) SWITCH ENTRIES
MVC 0(14, 4) ……
OK MVC 14(14, 4), TEMP ……
A 4, =F’14’ MOVE TO NEXT ENTRY
C 4, LAST IS IT LAST ENTRY
BNE LOOP NO
:
SYMTBL DS 0F SYMBOL TABLE
DS 100CL14 14 BYTES PER ENTRY
TEMP DS CL14 TEMPORARY ENTRY
LAST DC A(-----) LOCATION OF NEXT FREE ENTRY IN TABLE
RADIX EXCHANGE SORT
PASS 1
19 10011
13 01101
05 00101
27 11011
01 00001
26 11010
31 11111
16 10000
02 00010
09 01001
11 01011
21 10101
PASS 2
01011
01101
00101
01001
00001
00010
11111
10000
11010
11011
10011
10101
PASS 3
00010
00001
00101
01001
01101
01011
10101
10000
10011
11011
11010
11111
PASS 4
00010
00001
00101
01001
01011
01101
10011
10000
10101
11011
11010
11111
PASS 5
00001
00010
00101
01001
01011
10000
10011
10101
11011
11010
11111
00001 01
00010 02
00101 05
01001 09
01011 11
01101 13
10000 16
10011 19
10101 21
11010 26
11011 27
11111 31
COMPARISON OF SORTS
TYPE AVERAGE TIME EXTRA STORAGE (WASTED
SPACE)
INTERCHANGE A * N2 NONE + 1
SHELL B * N * (log2(N))2 NONE
RADIX C * N * logp(K) N * p
RADIX EXCHANGE D * N * log2(N) k + 1
ADDRESS CALCULATION E * N 2.2 * N (approximate)
EXAMPLE OF ADDRESS CALCULATION SORT
DATA NO. 1 2 3 4 5 6 7 8 9 10 11 12
DATA 19 13 05 27 01 26 31 16 02 09 11 21
CALCULATED
ADDRESS
6 4 1 9 0 8 10 5 0 3 3 7
TABLE
0 -- -- -- -- 01 01 01 01 *01 01 01 01
1 -- -- 05 05 05 05 05 05 02 02 02 02
2 -- -- -- -- -- -- -- -- 05 *05 05 05
3 -- -- -- -- -- -- -- -- -- 09 *09 09
4 -- 13 13 13 13 13 13 13 13 13 11 11
5 -- -- -- -- -- -- -- 16 16 16 13 13
6 19 19 19 19 19 19 19 19 19 19 16 16
7 -- -- -- -- -- -- -- -- -- -- 19 *19
8 -- -- -- -- -- 26 26 26 26 26 26 21
9 -- -- -- 27 27 27 27 27 27 27 27 26
10 -- -- -- -- -- -- 31 31 31 31 31 27
11 -- -- -- -- -- -- -- -- -- -- -- 31
OPEN ADDRESSING 19,13,05,27,01,26,31,16,02,09,11,21
POSITION ITEM PROBES TO FIND PROBES TO FIND NOT
0 - - 1
1 01 1 6
2 19, 02* 1 5
3 02 2 4
4 21 1 3
5 05 1 2
6 1
7 1
8 1
9 26, 09* 1 7
10 27, 09* 1 6
11 09, 11* 3 5
12 11 2 4
13 13 1 3
14 31 1 2
15 1
16 16 1 1
16 54

More Related Content

Similar to 3.ASSEMBLERS.pptx

Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...Hsien-Hsin Sean Lee, Ph.D.
 
ARM Architecture Instruction Set
ARM Architecture Instruction SetARM Architecture Instruction Set
ARM Architecture Instruction SetDwight Sabio
 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructionsRavi Anand
 
Basic computer organization design
Basic computer organization designBasic computer organization design
Basic computer organization designndasharath
 
ARM AAE - Intrustion Sets
ARM AAE - Intrustion SetsARM AAE - Intrustion Sets
ARM AAE - Intrustion SetsAnh Dung NGUYEN
 
Bca 2nd sem-u-3.2-basic computer programming and micro programmed control
Bca 2nd sem-u-3.2-basic computer programming and micro programmed controlBca 2nd sem-u-3.2-basic computer programming and micro programmed control
Bca 2nd sem-u-3.2-basic computer programming and micro programmed controlRai University
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed controlRai University
 
Online Approximate OLAP in SparkSQL
Online Approximate OLAP in SparkSQLOnline Approximate OLAP in SparkSQL
Online Approximate OLAP in SparkSQLDataWorks Summit
 
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...Hsien-Hsin Sean Lee, Ph.D.
 
B.sc cs-ii-u-3.2-basic computer programming and micro programmed control
B.sc cs-ii-u-3.2-basic computer programming and micro programmed controlB.sc cs-ii-u-3.2-basic computer programming and micro programmed control
B.sc cs-ii-u-3.2-basic computer programming and micro programmed controlRai University
 
4,encoder & decoder MUX and DEMUX EEng - Copy.pdf
4,encoder & decoder MUX and DEMUX EEng - Copy.pdf4,encoder & decoder MUX and DEMUX EEng - Copy.pdf
4,encoder & decoder MUX and DEMUX EEng - Copy.pdfDamotTesfaye
 
1st course summary.pptx
1st course summary.pptx1st course summary.pptx
1st course summary.pptxHebaEng
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald PartitioningInSync Conference
 
Assembler numericals by aniket bhute
Assembler numericals by aniket bhuteAssembler numericals by aniket bhute
Assembler numericals by aniket bhuteAniket Bhute
 

Similar to 3.ASSEMBLERS.pptx (20)

Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
Lec5 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Branch Pred...
 
ARM Architecture Instruction Set
ARM Architecture Instruction SetARM Architecture Instruction Set
ARM Architecture Instruction Set
 
Microprocessor 8086 instructions
Microprocessor 8086 instructionsMicroprocessor 8086 instructions
Microprocessor 8086 instructions
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
Basic computer organization design
Basic computer organization designBasic computer organization design
Basic computer organization design
 
ARM AAE - Intrustion Sets
ARM AAE - Intrustion SetsARM AAE - Intrustion Sets
ARM AAE - Intrustion Sets
 
74ls390
74ls39074ls390
74ls390
 
Bca 2nd sem-u-3.2-basic computer programming and micro programmed control
Bca 2nd sem-u-3.2-basic computer programming and micro programmed controlBca 2nd sem-u-3.2-basic computer programming and micro programmed control
Bca 2nd sem-u-3.2-basic computer programming and micro programmed control
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
 
Online Approximate OLAP in SparkSQL
Online Approximate OLAP in SparkSQLOnline Approximate OLAP in SparkSQL
Online Approximate OLAP in SparkSQL
 
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
Lec7 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Dynamic Sch...
 
B.sc cs-ii-u-3.2-basic computer programming and micro programmed control
B.sc cs-ii-u-3.2-basic computer programming and micro programmed controlB.sc cs-ii-u-3.2-basic computer programming and micro programmed control
B.sc cs-ii-u-3.2-basic computer programming and micro programmed control
 
Sort presentation
Sort presentationSort presentation
Sort presentation
 
4,encoder & decoder MUX and DEMUX EEng - Copy.pdf
4,encoder & decoder MUX and DEMUX EEng - Copy.pdf4,encoder & decoder MUX and DEMUX EEng - Copy.pdf
4,encoder & decoder MUX and DEMUX EEng - Copy.pdf
 
ARM instruction set
ARM instruction  setARM instruction  set
ARM instruction set
 
crack satellite
crack satellite crack satellite
crack satellite
 
1st course summary.pptx
1st course summary.pptx1st course summary.pptx
1st course summary.pptx
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald Partitioning
 
Assembler numericals by aniket bhute
Assembler numericals by aniket bhuteAssembler numericals by aniket bhute
Assembler numericals by aniket bhute
 
Microprocessors 1-8086
Microprocessors 1-8086Microprocessors 1-8086
Microprocessors 1-8086
 

Recently uploaded

costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Recently uploaded (20)

costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

3.ASSEMBLERS.pptx

  • 1. ASSEMBLER FUNCTION OF AN ASSEMBLER ASSEMBLY LANGUAGE PROGRAM ASSEMBLER MACHINE LANGUAGE PROGRAM DATABASES
  • 2. ELEMENTS OF ASSEMBLY LANGUAGE • MNEMONIC OPERATION CODES • SYMBOLIC OPERANDS • DATA DECLARATIONS
  • 3. INSTRUCTION SET INSTRUCTION OPCODE ASSEMBLY MNEMONIC REMARKS 00 STOP Stop execution 01 ADD First operand modified 02 SUB Condition code set 03 MULT 04 MOVER Memory to register move 05 MOVEM Register to memory move 06 COMP Compare(sets condition code) 07 BC Branch on condition 08 DIV 09 READ First operand is not used 10 PRINT
  • 4. CONDITION CODES CONDITION CODE MNEMONIC CODE PURPOSE LT 1 Less than LE 2 Less than or Equal to EQ 3 Equal to GT 4 Greater than GE 5 Greater than or Equal to ANY 6 Any
  • 5. ASSEMBLY LANGUAGE STATEMENTS • Imperative statements(IS) Ex : ADD, SUB, etc.. • Declaration statements(DL) [label] DS <constant> [label] DC <value> • Assembler directives(AD) Declaration statements(DL) i) Declare Storage(DS) Ex : A DS 1 ii) Declare Constant(DC) Ex : ONE DC ‘1’
  • 6. Contd.. Assembler Directives(AD) START <constant> END [<operand specification>] ORIGIN <address specification> EQU <symbol> EQU <operand specification> LTORG USING DROP
  • 7. GENERAL DESIGN PROCEDURE • Specify the problem. • Specify data structures. • Define format of data structure. • Specify the algorithm. • Look for modularity(ie., capability of one program to be subdivided into independent programming units) • Repeat one through five on modularity.
  • 8. DESIGN OF AN ASSEMBLER SOURCE PROGRAM : JOHN START 0 USING *,15 L 1, FIVE A 1, FOUR ST 1, TEMP FOUR DC F’4’ FIVE DC F’5’ TEMP DS 1F END Pseudo-op : START, USING, END, EQU Symbols/Labels : FOUR, FIVE, TEMP, JOHN Machine opcode : A, L, ST
  • 9. FIRST PASS Relative Address Mnemonic Instruction 0 L 1, -(0,15) 4 A 1,-(0,15) 8 ST 1,-(0,15) 12 4 16 5 20 -
  • 10. SECOND PASS Relative Address Mnemonic Instruction 0 L 1, 16(0,15) 4 A 1,12(0,15) 8 ST 1,20(0,15) 12 4 16 5 20 -
  • 11. TASK OF AN ASSEMBLER • Generate instructions a) Evaluate the mnemonic in the operation field to produce its machine code. b) Evaluate the subfields – find the value of each symbol, process literals, and assign addresses. • Process pseudo-ops.. ie., Check what was given as Base Register, where is the rel.address location starting from.
  • 12. PASS 1 : Define symbols and literals • Determine length of machine instructions(MOTGET1) • Keep track of Location Counter(LC) • Remember values of symbols until pass2(STSTO) • Process some pseudo-ops, eg.,EQU, DS(POTGET1) • Remember literals(LITSIO)
  • 13. PASS 2 – Generate object program • Look up value of symbols(STGET) • Generate instructions(MOTGET2) • Generate data(for DS, DC, and literals) • Process pseudo-ops(POTGET2) 3.ASSEMBLERS.docx
  • 14. DATA STRUCTURE PASS 1 DATA BASES • Input source program. • A Location Counter(LC). • A table, Machine-Operation table(MOT). • A table, Pseudo-Operation table(POT). • A table, Symbol table(ST). • A table, Literal table(LT). • A copy of the input to be used later by Pass 2.
  • 15. DATA STRUCTURE PASS 2 DATA BASES • Copy of source program input to pass1. • Location Counter(LC). • A table, Machine-Operation table(MOT). • A table, Pseudo-Operation table(POT). • A table, Symbol table(ST). • A table, the Base table(BT). • A Workspace, INST, that is used to hold each instruction as its various parts are being assembled. • A workspace, PRINTLINE. • A workspace, PUNCH CARD. • An Output deck of assembled instructions in the format needed by the loader.
  • 16. MACHINE-OP TABLE FOR PASS 1 & PASS2 <-----------------------------------------6 BYTES PER ENTRY--------------------------------------------> MNEMONIC OP-CODE (4-BYTES) (CHARACTERS) BINARY OP- CODE(1-BYTE) (HEXADECIMAL ) INSTRUCTION LENGTH(2- BITS) (BINARY) INSTRUCTION FORMAT(3- BITS) (BINARY) NOT USED IN THIS DESIGN(3- BITS) “Abbb” 5A 10 001 “AHbb” 4A 10 001 “ALbb” 5E 10 001 “ALRb” 1E 01 000 …… “MVCb” D2 11 100 ....
  • 17. CODES: Instruction Length 01 = 1 half words = 2 bytes 10 = 2 half words = 4 bytes 11 = 3 half words = 6 bytes Instruction Format 000 = RR 001 = RX 010 = RS 011 = SI 100 = SS
  • 18. PSEUDO – OP TABLE (POT)FOR PASS1 <----------------------------------8 BYTES PER ENTRY--------------------------------------------------> PSEUDO-OP (5 - BYTES) CHARACTER) ADDRESS OF ROUTINE TO PROCESS PSEUDO – OP (3 BYTES = 24 BIT ADDRESS) “DROPb” P1DROP “ENDbb” P1END “EQUbb” P1EQU “START” P1START “USING” P1USING
  • 19. SYMBOL TABLE (ST) FOR PASS1 AND PASS2 <----------------------------------14 BYTES PER ENTRY---------------------------------------------> SYMBOL (8 BYTES) (CHARACTERS) VALUE (4 BYTES) (HEXADECIMAL) LENGTH (1 BYTE) (HEXADECIMAL) RELOCATION (1 BYTE) (CHARACTER) “JOHNbbbb” 0000 01 “R” “FOURbbbb” 000C 04 “R” “FIVEbbbb” 0010 04 “R” “TEMPbbbb” 0014 04 “R”
  • 20. BASE TABLE(BT) FOR PASS2 <------------------------------------------4 BYTES PER ENTRY-----------------------------------------> AVAILABILITY INDICATOR (1 - BYTE) (CHARACTER) DESIGNATED REL.ADDRESS CONTENTS OF BASE REGISTER (3 BYTES = 24 BIT ADDRESS) (HEXADECIMAL) 1 “N” - 2 “N” - 15 : : ENTRIES 14 “N” - 15 “Y” 00 00 00
  • 21. SAMPLE ASSEMBLY SOURCE PROGRAM STATEMENT 1 PRGAM START 0 2 USING *, 15 3 LA 15, SETUP 4 SR TOTAL, TOTAL 5 AC EQU 2 6 INDEX EQU 3 7 TOTAL EQU 4 8 DATABASE EQU 13 9 SETUP EQU * 10 USING SETUP, 15 11 L DATABASE, =A(DATA1) 12 USING DATAAREA, DATABASE 13 SR INDEX, INDEX 14 LOOP L AC, DATA1(INDEX)
  • 22. CONTD.. 15 AR TOTAL, AC 16 A AC, =F’5’ 17 ST AC, SAVE(INDEX) 18 A INDEX, =F’4’ 19 C INDEX, =F’8000’ 20 BNE LOOP 21 LR 1, TOTAL 22 BR 14 23 LTORG 24 SAVE DS 2000F 25 DATAAREA EQU * 26 DATA1 DC F’25, 26, 97, 101, …….. [2000 NUMBERS] 27 END
  • 23. VARIABLE TABLES SYMBOL TABLE SYMBOL VALUE LENGTH RELOCATION PRGAM2 0 1 R AC 2 1 A INDEX 3 1 A TOTAL 4 1 A DATABASE 13 1 A SETUP 6 1 R LOOP 12 4 R SAVE 64 4 R DATAAREA 8064 1 R DATA1 8064 4 R
  • 24. LITERAL TABLE A(DATA) 48 4 R F’5’ 52 4 R F’4’ 56 4 R F’8000’ 60 4 R
  • 25. BASE TABLE (SHOWING ONLY BASE REGISTERS IN USE) 1) AFTER STATEMENT 2 : BASE CONTENTS 15 0 2) AFTER STATEMENT 10 : BASE CONTENTS 15 6 3) AFTER STATEMENT 12 BASE CONTENTS 13 8064 15 6
  • 26. GENERATED “MACHINE” CODE CORRESPONDING STMT NO. LOCATION INSTRUCTION/DATUM 3 0 LA 15, 6(0, 15) 4 4 SR 4, 4 11 6 L 13, 42(0, 15) 13 10 SR 3, 3 14 12 L 2, 0(3, 13) 15 16 AR 4, 2 16 18 A 2, 46(0, 15) 17 22 ST 2, 58(3, 15) 18 26 A 3, 50(0, 15) 19 30 C 3, 54(0, 15) 20 34 BC 7, 6(0, 15) 21 38 LR 1, 4 22 40 BCR 15, 14
  • 27. CONTD.. 23 48 8064 52 X’00000005’ 56 X’00000004’ 60 8000 24 64 . . . . . 25 8064 X’00000019’ . . .
  • 29. LINEAR SEARCH LA 4, SYMTBL LOOP CLC 0(8,4), SYMBOL BE SYMFOUND A 4, =F’14’ C 4, LAST BNE LOOP NOTFOUND . (symbol not found) . . SYMFOUND (symbol found) . . . SYMBOL DS CL14 SYMTBL DS 100CL14 LAST DC A(----)
  • 30. BINARY SEARCH L 5 , SIZE SRL 5, 1 LR 6,5 LOOP SRL 6, 1 LA 4, SYMTBL(5) CLC 0(8,4), SYMBOL BE FOUND BH TOOHIGH TOOLOW AR 5, 6 B TESTEND TOOHIGH SR 5, 6 TESTEND LTR 6, 6 BNZ LOOP NOTFOUND (symbol not found) . . . FOUND (symbol found)
  • 31. INTERCHANGE SORT EXAMPLE IN 360 ASSEMBLY CODE L 5, LAST LA 4, SYMTBL LOOP CLC 0(8, 4), 14(4) COMPARE ADJACENT SYMBOLS – 8 BYTES BNH OK CORRECT ORDER MVC TEMP(14), 0(4) SWITCH ENTRIES MVC 0(14, 4) …… OK MVC 14(14, 4), TEMP …… A 4, =F’14’ MOVE TO NEXT ENTRY C 4, LAST IS IT LAST ENTRY BNE LOOP NO : SYMTBL DS 0F SYMBOL TABLE DS 100CL14 14 BYTES PER ENTRY TEMP DS CL14 TEMPORARY ENTRY LAST DC A(-----) LOCATION OF NEXT FREE ENTRY IN TABLE
  • 32. RADIX EXCHANGE SORT PASS 1 19 10011 13 01101 05 00101 27 11011 01 00001 26 11010 31 11111 16 10000 02 00010 09 01001 11 01011 21 10101
  • 37. 00001 01 00010 02 00101 05 01001 09 01011 11 01101 13 10000 16 10011 19 10101 21 11010 26 11011 27 11111 31
  • 38. COMPARISON OF SORTS TYPE AVERAGE TIME EXTRA STORAGE (WASTED SPACE) INTERCHANGE A * N2 NONE + 1 SHELL B * N * (log2(N))2 NONE RADIX C * N * logp(K) N * p RADIX EXCHANGE D * N * log2(N) k + 1 ADDRESS CALCULATION E * N 2.2 * N (approximate)
  • 39. EXAMPLE OF ADDRESS CALCULATION SORT DATA NO. 1 2 3 4 5 6 7 8 9 10 11 12 DATA 19 13 05 27 01 26 31 16 02 09 11 21 CALCULATED ADDRESS 6 4 1 9 0 8 10 5 0 3 3 7 TABLE 0 -- -- -- -- 01 01 01 01 *01 01 01 01 1 -- -- 05 05 05 05 05 05 02 02 02 02 2 -- -- -- -- -- -- -- -- 05 *05 05 05 3 -- -- -- -- -- -- -- -- -- 09 *09 09 4 -- 13 13 13 13 13 13 13 13 13 11 11 5 -- -- -- -- -- -- -- 16 16 16 13 13 6 19 19 19 19 19 19 19 19 19 19 16 16 7 -- -- -- -- -- -- -- -- -- -- 19 *19 8 -- -- -- -- -- 26 26 26 26 26 26 21 9 -- -- -- 27 27 27 27 27 27 27 27 26 10 -- -- -- -- -- -- 31 31 31 31 31 27 11 -- -- -- -- -- -- -- -- -- -- -- 31
  • 40. OPEN ADDRESSING 19,13,05,27,01,26,31,16,02,09,11,21 POSITION ITEM PROBES TO FIND PROBES TO FIND NOT 0 - - 1 1 01 1 6 2 19, 02* 1 5 3 02 2 4 4 21 1 3 5 05 1 2 6 1 7 1 8 1 9 26, 09* 1 7 10 27, 09* 1 6 11 09, 11* 3 5 12 11 2 4 13 13 1 3 14 31 1 2 15 1 16 16 1 1 16 54