SlideShare a Scribd company logo
1 of 34
Assembly Language Instructions
& Programming
PART 1
INR R
• INR R – Increment the specified register
by 1.
– R ← R + 1
– R can be any of the general purpose registers
(A, B, C, D, E, H, L).
– Affects all the flags except CY.
– Register Addressing Mode.
– 1-byte instruction and takes 1 Machine Cycle
for execution.
– E.g. INR B, INR A.
– Amounts to 7 different Opcodes.
DCR R
• DCR R – Decrement the specified
register by 1.
– R ← R - 1
– R can be any of the general purpose registers
(A, B, C, D, E, H, L).
– Affects all the flags except CY.
– Register Addressing Mode.
– 1-byte instruction and takes 1 Machine Cycle
for execution.
– E.g. DCR C, DCR H.
– Amounts to 7 different Opcodes.
INR M
• INR M – Increment the content of
memory (location specified by HL Pair)
by 1.
– ((HL)) ← ((HL)) + 1
– Affects all the flags except CY.
– Indirect Addressing Mode.
– 1-byte instruction
– Takes 3 Machine Cycles (Fetch, Read and
Write) for execution.
DCR M
• DCR M – Decrement the indirect byte
by 1 (memory location specified by HL
Pair).
– ((HL)) ← ((HL)) – 1
– Affects all the flags except CY.
– Indirect Addressing Mode.
– 1-byte instruction
– Takes 3 Machine Cycles (Fetch, Read and
Write) for execution.
JMP Instruction
• JMP – Jump (Go) to an instruction to
execute.
E.g. JMP LABEL
• This instruction is used to change the
execution sequence.
• LABEL is a symbol placed before instruction
where processor has to jump.
• E.g. JMP HERE
• Next is a simple example for understanding
JMP
JMP (Contd.)
• Example of JMP
:
MOV A, B
JMP HERE
LDA 2500H
DCR B
HERE: INR A
MOV B, A
:
• Symbol HERE is
address where the
instruction INR A is
stored in memory.
• Execution of JMP
HERE, skips the
execution of LDA &
DCR in program.
JMP (Contd.)
• JMP ADDRESS – Jump (Go) to
ADDRESS to execute an instruction.
• ADDRESS is actually the memory address
where instruction INR A (Last Slide) is stored
in memory.
• E.g. JMP 5000H
• PCH ← 50H and PCL ← 00H, finally PC=5000H,
showing address of instruction to be executed.
• It takes 3 Machine Cycles for execution.
• Execution of JMP is shown next.
Conditional JMPs
• JZ – Jump (Go) to instruction to execute
if ZF=1.
E.g. JZ ADDRESS (Memory Address)
• Executes similar to JMP but checks ZF before jump. If
ZF=1 then jump otherwise don’t jump.
• JNZ– Jump (Go) to instruction to execute
if ZF=0.
E.g. JNZ ADDRESS (Memory Address)
• Executes similar to JZ but checks for ZF=0 before
jump. If ZF=0 then jump otherwise don’t jump.
Conditional JMPs (Contd.)
• Example of JZ
MVI A, 01
DCR A
JZ HERE
STAX D
DCR B
HERE: INR D
MOV C, A
:
• DCR A sets ZF=1.
• So JZ HERE makes a
jump.
• Execution of JZ
HERE, skips the
execution of STAX &
DCR in program.
Conditional JMPs (Contd.)
• Example of JZ
MVI A, 01
INR A
JZ HERE
STAX D
DCR B
HERE: INR D
MOV C, A
:
• INR A, sets ZF=0.
• So, JZ HERE does
not make a jump.
• Hence, STAX D and
DCR B is executed
next and so on.
Conditional JMPs (Contd.)
– JPE Jump on EVEN Parity
or Jump if Parity is SET
i.e. Jump on PF = 1.
– JPO Jump on ODD Parity
or Jump if Parity is NOT SET
i.e. Jump on PF = 0.
– JM Jump if Result is Minus (Negative)
i.e. Jump on SF = 1.
– JP Jump if Result is Positive
i.e. Jump on SF = 0
Conditional JMPs (Contd.)
– JC Jump if a Carry Generated
i.e. Jump on CF = 1.
– JNC Jump if Carry Not Generated
i.e. Jump on CF = 0.
A Simple Program (P6)
A data table containing 10 elements is
stored at memory location 2050H.
Write an 8085 ALP that will store 00 at
all the data positions.
Physical
Address
Data SYMBOL
2050H XX TABLE
2051H XX
2052H XX
2053H XX
2054H XX
2055H XX
2056H XX
2057H XX
2058H XX
2059H XX
Data Table (Program P6)
Base Address of TABLE
Program P6 (Contd.)
HL ← Base Address of TABLE
C ← Data Count (0AH)
A ← 00, Data to store
Increment Memory Pointer
i.e. HL ← HL +1
Decrement the data counter
i.e. C ← C - 1
All Data
Cleared?
N
Y
STOP
Store data into TABLE
i.e. ((HL)) ← A
Program P6 (Contd.)
START: LXI H, TABLE ; Initialize Memory Pointer.
MVI C, COUNT ; Init. Data Counter (0AH).
MVI A, 00 ; Clear Accumulator.
AGAIN: MOV M, A ; Clear memory using Acc.
INX H ; Point to Next Data
DCR C ; Decrement Count by 1
JNZ AGAIN ; All Data cleared?
; ‘NO’, Go back to clear again
HLT ; ‘YES’, STOP
Alternate Program P6 (Contd.)
START: LXI H, TABLE ; Initialize Memory Ptr.
MVI C, COUNT ; Init. Data Counter (0A)
AGAIN: MVI M, 00 ; Clear memory.
INX H ; Point to Next Data
DCR C ; Decrement Count by 1
JNZ AGAIN ; All Data cleared?
; ‘NO’, Go back to clear again
HLT ; ‘YES’, STOP
A Different Organization of Data Table
• First Location tells how
many data are there in
the given table.
• Program should use this
fact as the data starts
from next location.
• Write program to
clear this table.
Address Data Comments
2600 0AH DATA COUNT
2601 XX
2602 XX
2603 XX
2604 XX
2605 XX
2606 XX
2607 XX
2608 XX
2609 XX
260A XX
Program P6 (Contd.)
HL ← Base Address of TABLE
A ← 00, Data to store
Store data into TABLE
i.e. ((HL)) ← A
Decrement the data counter
i.e. C ← C - 1
All Data
Cleared?
N
Y
STOP
Increment Memory Pointer
i.e. HL ← HL +1
Store count into C
i.e. C ← ((HL))
Alternate Program P6 (Contd.)
START: LXI H, TABLE ; Initialize Memory Pointer.
MVI A, 00 ; Clear Accumulator.
MOV C, M ; Init. Data Counter (0AH).
AGAIN: INX H ; Point to Next Data location.
MOV M, A ; Clear memory using Acc.
DCR C ; Decrement Count by 1
JNZ AGAIN ; All Data cleared?
; ‘NO’, Go back to clear again
HLT ; ‘YES’, STOP
A data table containing 10 data items,
named TABLE1, is stored in memory.
Write an 8085 ALP to copy data from
TABLE1 to another table, namely
TABLE2.
Program (P7)
Data Table (P7)
Address Data Comments
2400 91H DATA1
2401 28H DATA2
: : :
: : :
2409 44H DATA10
: : :
: : :
2450 XX DATA1
: : :
2459 XX DATA10
Base Address of TABLE1
Base Address of TABLE2
Program P7 (Contd.)
HL ← Base Address of TABLE1
DE ← Base Address of TABLE2
C ← Data Count (0AH)
Get data from TABLE1
i.e. A ← ((HL))
Increment Memory Pointers
i.e. HL ← HL +1
DE ← DE + 1
Decrement the data counter
All Data
Copied?
N
Y
STOP
Store data into TABLE2
i.e. ((DE)) ← A
Program P7 (Contd.)
START: LXI H, TABLE1 ; Initialize TABLE1 Pointer.
LXI D, TABLE2 ; Initialize TABLE2 Pointer.
MVI C, 0AH ; Initialize Data Counter.
AGAIN: MOV A, M ; Get TABLE1 Data.
STAX D ; Store at TABLE2.
INX H ; Point to Next Data location.
INX D
DCR C ; Decrement Count by 1.
JNZ AGAIN ; All Data copied?
; ‘NO’, Go back to copy again
HLT ; ‘YES’, STOP
Two data tables containing 10 data
items, named TABLE1 and TABLE2, are
stored in memory. Write an 8085 ALP to
exchange the data of two tables.
Program (P8)
Data Table (P8)
Address Data Comments
2400 91H DATA1
2401 28H DATA2
: : :
: : :
2409 44H DATA10
: : :
: : :
2450 20H DATA1
: : :
2459 6AH DATA10
Base Address of TABLE1
Base Address of TABLE2
Program P8 (Contd.)
START: LXI H, TABLE1 ; Initialize TABLE1 Pointer.
LXI D, TABLE2 ; Initialize TABLE2 Pointer.
MVI C, 0AH ; Initialize Data Counter.
AGAIN: MOV B, M ; TABLE1 Data in B.
LDAX D ; TABLE2 Data in A.
MOV M, A ; Store TABLE2 Data at TABLE1.
MOV A, B ; TABLE1 Data in A.
STAX D ; Store TABLE1 Data at TABLE2.
INX H ; Point to Next Data location.
INX D
DCR C ; Decrement Count by 1.
JNZ AGAIN ; All Data copied?
; ‘NO’, Go back to copy again
HLT ; ‘YES’, STOP
Alternate Program P8
START: LXI H, TABLE1 ; Initialize TABLE1 Pointer.
LXI D, TABLE2 ; Initialize TABLE2 Pointer.
MVI C, 0AH ; Initialize Data Counter.
AGAIN: MOV B, M ; TABLE1 Data in B.
LDAX D ; TABLE2 Data in A.
XCGH ; Exchange the pointers.
MOV M, B ; TABLE1 Data at TABLE2.
STAX D ; Store TABLE2 Data at TABLE1.
XCHG ; Restore the pointers
INX H ; Point to Next Data location.
INX D
DCR C ; Decrement Count by 1.
JNZ AGAIN ; All Data copied? ‘NO’, Go back.
HLT ; ‘YES’, STOP
Program (P10)
Write an 8085 ALP to add two 8-bit numbers and result may
be 16-bit. Assuming data are stored in memory at locations
2500H and 2501H.
MVI C, 00 ; Initialize Carry Counter
LDA 2500H
MOV B, A ; Get DATA1 in B.
LDA 2501H ; Get DATA2 in A.
ADD B ; Add DATA1 and DATA2.
JNC DN1 ; Is CY=0? ‘YES’ Go to DN1.
INR C ; ‘NO’ Increment carry counter by 1.
DN1: STA 2502H ; Store the low byte of result in memory.
MOV A, C ; Get high byte of result in in A.
STA 2503H ; Store the high byte of result in memory.
HLT ; Stop
Alternate Program (P10)
MVI C, 00 ; Initialize Carry counter.
LXI H, 2500H ; Pointer to first data in memory.
MOV A, M ; Get DATA1 in A.
INX H ; Increment pointer to DATA2.
ADD M ; Add DATA1 and DATA2.
JNC DN1 ; Is CY=0? ‘YES’ Go to DN1.
INR C ; ‘NO’ Increment carry counter by 1.
DN1: INX H ; Increment Ptr to store low byte of result.
MOV M, A ; Store the low byte of result in memory.
INX H ; Increment Ptr to store high byte of result
MOV M, C ; Store the high byte of result in memory.
HLT ; Stop
Program (P11)
A data series of
integers is stored in
memory, as shown.
Write an 8085 ALP that
will add all the
elements of this series
and store the result in
memory. Result may
be 16-bit.
Address Data Comments
2500 09H ELEMENT
COUNT
2501 10H ELEMENT 1
2502 19H ELEMENT 2
2503 25H
2504 01H
2505 E1H
2506 11H
2507 06H
2508 00H
2509 F0H ELEMENT 9
Program (P11) (Contd.)
LXI H, 2500H ; Pointer to data series.
MOV B, M ; Get Element Count in B.
MVI C, 00 ; Initialize Carry counter.
MVI A, 00 ; Initial Sum=00 in A
NEXT: INX H ; Pointer to next data in series.
ADD M ; Add next element to previous sum.
JNC DN1 ; Is CY=0? ‘YES’ Go to DN1.
INR C ; ‘NO’ Increment carry counter by 1.
DN1: DCR B ; Decrement Element Counter.
JNZ NEXT ; All elements added? ‘NO’ Go back.
; ‘YES’ Store the result …..contd.
Program (P11) (Contd.)
INX H ; Pointer to store low byte of result.
MOV M, A ; Store the low byte of result.
INX H ; Pointer to store high byte of result.
MOV M, C ; Store the high byte of result.
HLT ; Stop

More Related Content

Similar to Assembly Language Instructions & Programming.pptx

Similar to Assembly Language Instructions & Programming.pptx (20)

Hemanth143
Hemanth143 Hemanth143
Hemanth143
 
8085 micro processor
8085 micro processor8085 micro processor
8085 micro processor
 
Class4
Class4Class4
Class4
 
Introduction to 8085 by adi ppt
Introduction to 8085 by adi pptIntroduction to 8085 by adi ppt
Introduction to 8085 by adi ppt
 
180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!
 
Assembly language programs
Assembly language programsAssembly language programs
Assembly language programs
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers final
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)
 
Intel codetable
Intel codetableIntel codetable
Intel codetable
 
Lec04
Lec04Lec04
Lec04
 
Lec04
Lec04Lec04
Lec04
 
8085 Assembly language programs.pdf
8085 Assembly language programs.pdf8085 Assembly language programs.pdf
8085 Assembly language programs.pdf
 
List of 8085 programs
List of 8085 programsList of 8085 programs
List of 8085 programs
 
Lecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of InstructionsLecture 03 Arithmetic Group of Instructions
Lecture 03 Arithmetic Group of Instructions
 

Recently uploaded

Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiRaviKumarDaparthi
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxMasterG
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch TuesdayIvanti
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...SOFTTECHHUB
 

Recently uploaded (20)

Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 

Assembly Language Instructions & Programming.pptx

  • 1. Assembly Language Instructions & Programming PART 1
  • 2. INR R • INR R – Increment the specified register by 1. – R ← R + 1 – R can be any of the general purpose registers (A, B, C, D, E, H, L). – Affects all the flags except CY. – Register Addressing Mode. – 1-byte instruction and takes 1 Machine Cycle for execution. – E.g. INR B, INR A. – Amounts to 7 different Opcodes.
  • 3. DCR R • DCR R – Decrement the specified register by 1. – R ← R - 1 – R can be any of the general purpose registers (A, B, C, D, E, H, L). – Affects all the flags except CY. – Register Addressing Mode. – 1-byte instruction and takes 1 Machine Cycle for execution. – E.g. DCR C, DCR H. – Amounts to 7 different Opcodes.
  • 4. INR M • INR M – Increment the content of memory (location specified by HL Pair) by 1. – ((HL)) ← ((HL)) + 1 – Affects all the flags except CY. – Indirect Addressing Mode. – 1-byte instruction – Takes 3 Machine Cycles (Fetch, Read and Write) for execution.
  • 5. DCR M • DCR M – Decrement the indirect byte by 1 (memory location specified by HL Pair). – ((HL)) ← ((HL)) – 1 – Affects all the flags except CY. – Indirect Addressing Mode. – 1-byte instruction – Takes 3 Machine Cycles (Fetch, Read and Write) for execution.
  • 6. JMP Instruction • JMP – Jump (Go) to an instruction to execute. E.g. JMP LABEL • This instruction is used to change the execution sequence. • LABEL is a symbol placed before instruction where processor has to jump. • E.g. JMP HERE • Next is a simple example for understanding JMP
  • 7. JMP (Contd.) • Example of JMP : MOV A, B JMP HERE LDA 2500H DCR B HERE: INR A MOV B, A : • Symbol HERE is address where the instruction INR A is stored in memory. • Execution of JMP HERE, skips the execution of LDA & DCR in program.
  • 8. JMP (Contd.) • JMP ADDRESS – Jump (Go) to ADDRESS to execute an instruction. • ADDRESS is actually the memory address where instruction INR A (Last Slide) is stored in memory. • E.g. JMP 5000H • PCH ← 50H and PCL ← 00H, finally PC=5000H, showing address of instruction to be executed. • It takes 3 Machine Cycles for execution. • Execution of JMP is shown next.
  • 9. Conditional JMPs • JZ – Jump (Go) to instruction to execute if ZF=1. E.g. JZ ADDRESS (Memory Address) • Executes similar to JMP but checks ZF before jump. If ZF=1 then jump otherwise don’t jump. • JNZ– Jump (Go) to instruction to execute if ZF=0. E.g. JNZ ADDRESS (Memory Address) • Executes similar to JZ but checks for ZF=0 before jump. If ZF=0 then jump otherwise don’t jump.
  • 10. Conditional JMPs (Contd.) • Example of JZ MVI A, 01 DCR A JZ HERE STAX D DCR B HERE: INR D MOV C, A : • DCR A sets ZF=1. • So JZ HERE makes a jump. • Execution of JZ HERE, skips the execution of STAX & DCR in program.
  • 11. Conditional JMPs (Contd.) • Example of JZ MVI A, 01 INR A JZ HERE STAX D DCR B HERE: INR D MOV C, A : • INR A, sets ZF=0. • So, JZ HERE does not make a jump. • Hence, STAX D and DCR B is executed next and so on.
  • 12. Conditional JMPs (Contd.) – JPE Jump on EVEN Parity or Jump if Parity is SET i.e. Jump on PF = 1. – JPO Jump on ODD Parity or Jump if Parity is NOT SET i.e. Jump on PF = 0. – JM Jump if Result is Minus (Negative) i.e. Jump on SF = 1. – JP Jump if Result is Positive i.e. Jump on SF = 0
  • 13. Conditional JMPs (Contd.) – JC Jump if a Carry Generated i.e. Jump on CF = 1. – JNC Jump if Carry Not Generated i.e. Jump on CF = 0.
  • 14. A Simple Program (P6) A data table containing 10 elements is stored at memory location 2050H. Write an 8085 ALP that will store 00 at all the data positions.
  • 15. Physical Address Data SYMBOL 2050H XX TABLE 2051H XX 2052H XX 2053H XX 2054H XX 2055H XX 2056H XX 2057H XX 2058H XX 2059H XX Data Table (Program P6) Base Address of TABLE
  • 16. Program P6 (Contd.) HL ← Base Address of TABLE C ← Data Count (0AH) A ← 00, Data to store Increment Memory Pointer i.e. HL ← HL +1 Decrement the data counter i.e. C ← C - 1 All Data Cleared? N Y STOP Store data into TABLE i.e. ((HL)) ← A
  • 17. Program P6 (Contd.) START: LXI H, TABLE ; Initialize Memory Pointer. MVI C, COUNT ; Init. Data Counter (0AH). MVI A, 00 ; Clear Accumulator. AGAIN: MOV M, A ; Clear memory using Acc. INX H ; Point to Next Data DCR C ; Decrement Count by 1 JNZ AGAIN ; All Data cleared? ; ‘NO’, Go back to clear again HLT ; ‘YES’, STOP
  • 18. Alternate Program P6 (Contd.) START: LXI H, TABLE ; Initialize Memory Ptr. MVI C, COUNT ; Init. Data Counter (0A) AGAIN: MVI M, 00 ; Clear memory. INX H ; Point to Next Data DCR C ; Decrement Count by 1 JNZ AGAIN ; All Data cleared? ; ‘NO’, Go back to clear again HLT ; ‘YES’, STOP
  • 19. A Different Organization of Data Table • First Location tells how many data are there in the given table. • Program should use this fact as the data starts from next location. • Write program to clear this table. Address Data Comments 2600 0AH DATA COUNT 2601 XX 2602 XX 2603 XX 2604 XX 2605 XX 2606 XX 2607 XX 2608 XX 2609 XX 260A XX
  • 20. Program P6 (Contd.) HL ← Base Address of TABLE A ← 00, Data to store Store data into TABLE i.e. ((HL)) ← A Decrement the data counter i.e. C ← C - 1 All Data Cleared? N Y STOP Increment Memory Pointer i.e. HL ← HL +1 Store count into C i.e. C ← ((HL))
  • 21. Alternate Program P6 (Contd.) START: LXI H, TABLE ; Initialize Memory Pointer. MVI A, 00 ; Clear Accumulator. MOV C, M ; Init. Data Counter (0AH). AGAIN: INX H ; Point to Next Data location. MOV M, A ; Clear memory using Acc. DCR C ; Decrement Count by 1 JNZ AGAIN ; All Data cleared? ; ‘NO’, Go back to clear again HLT ; ‘YES’, STOP
  • 22. A data table containing 10 data items, named TABLE1, is stored in memory. Write an 8085 ALP to copy data from TABLE1 to another table, namely TABLE2. Program (P7)
  • 23. Data Table (P7) Address Data Comments 2400 91H DATA1 2401 28H DATA2 : : : : : : 2409 44H DATA10 : : : : : : 2450 XX DATA1 : : : 2459 XX DATA10 Base Address of TABLE1 Base Address of TABLE2
  • 24. Program P7 (Contd.) HL ← Base Address of TABLE1 DE ← Base Address of TABLE2 C ← Data Count (0AH) Get data from TABLE1 i.e. A ← ((HL)) Increment Memory Pointers i.e. HL ← HL +1 DE ← DE + 1 Decrement the data counter All Data Copied? N Y STOP Store data into TABLE2 i.e. ((DE)) ← A
  • 25. Program P7 (Contd.) START: LXI H, TABLE1 ; Initialize TABLE1 Pointer. LXI D, TABLE2 ; Initialize TABLE2 Pointer. MVI C, 0AH ; Initialize Data Counter. AGAIN: MOV A, M ; Get TABLE1 Data. STAX D ; Store at TABLE2. INX H ; Point to Next Data location. INX D DCR C ; Decrement Count by 1. JNZ AGAIN ; All Data copied? ; ‘NO’, Go back to copy again HLT ; ‘YES’, STOP
  • 26. Two data tables containing 10 data items, named TABLE1 and TABLE2, are stored in memory. Write an 8085 ALP to exchange the data of two tables. Program (P8)
  • 27. Data Table (P8) Address Data Comments 2400 91H DATA1 2401 28H DATA2 : : : : : : 2409 44H DATA10 : : : : : : 2450 20H DATA1 : : : 2459 6AH DATA10 Base Address of TABLE1 Base Address of TABLE2
  • 28. Program P8 (Contd.) START: LXI H, TABLE1 ; Initialize TABLE1 Pointer. LXI D, TABLE2 ; Initialize TABLE2 Pointer. MVI C, 0AH ; Initialize Data Counter. AGAIN: MOV B, M ; TABLE1 Data in B. LDAX D ; TABLE2 Data in A. MOV M, A ; Store TABLE2 Data at TABLE1. MOV A, B ; TABLE1 Data in A. STAX D ; Store TABLE1 Data at TABLE2. INX H ; Point to Next Data location. INX D DCR C ; Decrement Count by 1. JNZ AGAIN ; All Data copied? ; ‘NO’, Go back to copy again HLT ; ‘YES’, STOP
  • 29. Alternate Program P8 START: LXI H, TABLE1 ; Initialize TABLE1 Pointer. LXI D, TABLE2 ; Initialize TABLE2 Pointer. MVI C, 0AH ; Initialize Data Counter. AGAIN: MOV B, M ; TABLE1 Data in B. LDAX D ; TABLE2 Data in A. XCGH ; Exchange the pointers. MOV M, B ; TABLE1 Data at TABLE2. STAX D ; Store TABLE2 Data at TABLE1. XCHG ; Restore the pointers INX H ; Point to Next Data location. INX D DCR C ; Decrement Count by 1. JNZ AGAIN ; All Data copied? ‘NO’, Go back. HLT ; ‘YES’, STOP
  • 30. Program (P10) Write an 8085 ALP to add two 8-bit numbers and result may be 16-bit. Assuming data are stored in memory at locations 2500H and 2501H. MVI C, 00 ; Initialize Carry Counter LDA 2500H MOV B, A ; Get DATA1 in B. LDA 2501H ; Get DATA2 in A. ADD B ; Add DATA1 and DATA2. JNC DN1 ; Is CY=0? ‘YES’ Go to DN1. INR C ; ‘NO’ Increment carry counter by 1. DN1: STA 2502H ; Store the low byte of result in memory. MOV A, C ; Get high byte of result in in A. STA 2503H ; Store the high byte of result in memory. HLT ; Stop
  • 31. Alternate Program (P10) MVI C, 00 ; Initialize Carry counter. LXI H, 2500H ; Pointer to first data in memory. MOV A, M ; Get DATA1 in A. INX H ; Increment pointer to DATA2. ADD M ; Add DATA1 and DATA2. JNC DN1 ; Is CY=0? ‘YES’ Go to DN1. INR C ; ‘NO’ Increment carry counter by 1. DN1: INX H ; Increment Ptr to store low byte of result. MOV M, A ; Store the low byte of result in memory. INX H ; Increment Ptr to store high byte of result MOV M, C ; Store the high byte of result in memory. HLT ; Stop
  • 32. Program (P11) A data series of integers is stored in memory, as shown. Write an 8085 ALP that will add all the elements of this series and store the result in memory. Result may be 16-bit. Address Data Comments 2500 09H ELEMENT COUNT 2501 10H ELEMENT 1 2502 19H ELEMENT 2 2503 25H 2504 01H 2505 E1H 2506 11H 2507 06H 2508 00H 2509 F0H ELEMENT 9
  • 33. Program (P11) (Contd.) LXI H, 2500H ; Pointer to data series. MOV B, M ; Get Element Count in B. MVI C, 00 ; Initialize Carry counter. MVI A, 00 ; Initial Sum=00 in A NEXT: INX H ; Pointer to next data in series. ADD M ; Add next element to previous sum. JNC DN1 ; Is CY=0? ‘YES’ Go to DN1. INR C ; ‘NO’ Increment carry counter by 1. DN1: DCR B ; Decrement Element Counter. JNZ NEXT ; All elements added? ‘NO’ Go back. ; ‘YES’ Store the result …..contd.
  • 34. Program (P11) (Contd.) INX H ; Pointer to store low byte of result. MOV M, A ; Store the low byte of result. INX H ; Pointer to store high byte of result. MOV M, C ; Store the high byte of result. HLT ; Stop

Editor's Notes

  1. Show animation of JMP after next slide