SlideShare a Scribd company logo
1 of 73
 An assembly language program statement consists of three fields: Labels, instructions and
comments. The arrangement of these three fields in a program is shown below.
1. label assigns a name to a memory location or program statement. It must be followed by the colon
symbol “:”. While using label as a part of an instruction, the colon symbol should not be used.
 They are also used to define the symbols. The name of any register or an instruction of a
microcontroller cannot be used as a label.
2. Instruction
 Each instruction has two parts; one is operation to be performed called as operation code (op-code). For
example, ADD,
MOV, INC, etc.
 The second part is data on which operation is to be performed called as operands.
 There are two types of operands:
1. Source operand(s): The operands that are input for an operation. The operation may involve one or two
operands.
2. Destination operand(s): These operands will store the result of an operation.
ORG 0100H
It should be noted that the access to memory locations between 80H to FFH that do not exist physically
will result into errors
Can we modify P (parity) bit by writing data directly in to PSW? What will be status of P flag after
execution of each of the following instructions?
MOV A, # 07H
MOV PSW, #00H
Copy the contents of the DPTR to internal RAM address 10H (DPL) and 11H (DPH)
EXTERNAL MEMORY DATA MOVEMENTS
• The external memory in the 8051 based system may be either data memory (RAM) or program memory
(ROM).
• Instructions that access external memory always use indirect addressing mode.
• Two different set of instructions are used to transfer data to/from data memory and from program
memory.
• Data Memory Access
• The data memory can be as large as 64 Kbytes.
• Register R0, R1 and DPTR can be used as a pointer (indirect addressing) to access data bytes from
the external RAM.
• R0 and R1 have limitation to access only address range from 00H to FFH because they are 8-bit
register (using 8-bit, we can access 28 locations, i.e. 256 bytes – 00H to FFH).
• DPTR can address any location from 0000H to FFFFH (64 Kbytes, 216 locations).
• Again to remind, only R0 and R1 can be used with indirect addressing mode
• Mnemonic used for external data memory transfer is MOVX. The letter ‘X’ in the mnemonic indicates
the external data memory
DPTR or Ri register should be initialized with address of the desired data.
Note that all data transfer in this group occurs through Accumulator only, i.e. all external data
movements require the A register either as source or destination operand.
Program
The word ‘HI’ is burned (written) in the flash ROM address 100H (‘H’) and 101H (‘I’). Copy this
word in to internal RAM address 10H and 11H.
Exchange the contents of the PSW and internal RAM address 50H
PUSH AND POP INSTRUCTIONS
 It is associated with stack operation. Using these instructions, the data is transferred between
stack and specified direct address.
 The stack is a special memory area in the internal RAM that is used for temporary storage and
retrieval of the data, while the execution of a program.
 It is Last In First Out (LIFO) type memory.
 The data stored in the stack can be numbers or address. The stack is accessed with the help of
stack pointer (SP) register.
 SP holds address (of internal RAM) where data from source operand will be saved (pushed) or
data to destination address will be retrieved (popped).
 Stack pointer always points to top of the stack, i.e. last memory address accessed.
 It should be initialized to a defined value (default value of SP is 07H).
Copy the contents of registers R0 to R7 into internal RAM addresses 40H to
47H respectively using PUSH instructions
Write program to add two 16-bit numbers 42E1H and 255CH
Write
instructions to
subtract 10H
from 30H using
immediate and
register
addressing
Represent –6 and –128 in 8–bit binary using 2’s complement representation.
Multiply the contents of R0 and R1 and place the result into R2 (MSByte) and R3 (LSByte)
Assume that a switch is connected to pin P1.1 and the LED is connected to pin P1.2. Write a program
to read the status of switch and send this status to LED.

More Related Content

Similar to Assembly program instructions

Addressing Modes
Addressing ModesAddressing Modes
Addressing ModesMayank Garg
 
advancsed microprocessor and interfacing
advancsed microprocessor and interfacingadvancsed microprocessor and interfacing
advancsed microprocessor and interfacing@zenafaris91
 
Microcontroller directives
Microcontroller directivesMicrocontroller directives
Microcontroller directivesManoj Harsule
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxDr.YNM
 
micro chapter 3jjgffffyeyhhuyerfftfgggffgjj
micro chapter 3jjgffffyeyhhuyerfftfgggffgjjmicro chapter 3jjgffffyeyhhuyerfftfgggffgjj
micro chapter 3jjgffffyeyhhuyerfftfgggffgjjTadeseBeyene
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdfSrikrishna Thota
 
Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdfHimanshuPant41
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085ShivamSood22
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)Ashim Saha
 
the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1Basel Mansour
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)Mahesh Kumar Attri
 

Similar to Assembly program instructions (20)

Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
addressing-mode-of-8051.pdf
addressing-mode-of-8051.pdfaddressing-mode-of-8051.pdf
addressing-mode-of-8051.pdf
 
Micro 8051
Micro 8051Micro 8051
Micro 8051
 
advancsed microprocessor and interfacing
advancsed microprocessor and interfacingadvancsed microprocessor and interfacing
advancsed microprocessor and interfacing
 
Internal microprocessor architecture
Internal microprocessor architectureInternal microprocessor architecture
Internal microprocessor architecture
 
Microcontroller directives
Microcontroller directivesMicrocontroller directives
Microcontroller directives
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
 
micro chapter 3jjgffffyeyhhuyerfftfgggffgjj
micro chapter 3jjgffffyeyhhuyerfftfgggffgjjmicro chapter 3jjgffffyeyhhuyerfftfgggffgjj
micro chapter 3jjgffffyeyhhuyerfftfgggffgjj
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf
 
Microcontroller1
Microcontroller1Microcontroller1
Microcontroller1
 
microprocessor
 microprocessor microprocessor
microprocessor
 
Advanced micro -processor
Advanced micro -processorAdvanced micro -processor
Advanced micro -processor
 
Co&al lecture-05
Co&al lecture-05Co&al lecture-05
Co&al lecture-05
 
Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdf
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085
 
Microcontroller .pptx
Microcontroller .pptxMicrocontroller .pptx
Microcontroller .pptx
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 
the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1the-cpu-design-central-processing-unit-design-1
the-cpu-design-central-processing-unit-design-1
 
intel 8086 introduction
intel 8086 introductionintel 8086 introduction
intel 8086 introduction
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)
 

Recently uploaded

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
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
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
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 

Recently uploaded (20)

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
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
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
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
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
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 

Assembly program instructions

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.  An assembly language program statement consists of three fields: Labels, instructions and comments. The arrangement of these three fields in a program is shown below. 1. label assigns a name to a memory location or program statement. It must be followed by the colon symbol “:”. While using label as a part of an instruction, the colon symbol should not be used.  They are also used to define the symbols. The name of any register or an instruction of a microcontroller cannot be used as a label. 2. Instruction  Each instruction has two parts; one is operation to be performed called as operation code (op-code). For example, ADD, MOV, INC, etc.  The second part is data on which operation is to be performed called as operands.  There are two types of operands: 1. Source operand(s): The operands that are input for an operation. The operation may involve one or two operands. 2. Destination operand(s): These operands will store the result of an operation.
  • 9.
  • 10.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. It should be noted that the access to memory locations between 80H to FFH that do not exist physically will result into errors Can we modify P (parity) bit by writing data directly in to PSW? What will be status of P flag after execution of each of the following instructions? MOV A, # 07H MOV PSW, #00H Copy the contents of the DPTR to internal RAM address 10H (DPL) and 11H (DPH)
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. EXTERNAL MEMORY DATA MOVEMENTS • The external memory in the 8051 based system may be either data memory (RAM) or program memory (ROM). • Instructions that access external memory always use indirect addressing mode. • Two different set of instructions are used to transfer data to/from data memory and from program memory. • Data Memory Access • The data memory can be as large as 64 Kbytes. • Register R0, R1 and DPTR can be used as a pointer (indirect addressing) to access data bytes from the external RAM. • R0 and R1 have limitation to access only address range from 00H to FFH because they are 8-bit register (using 8-bit, we can access 28 locations, i.e. 256 bytes – 00H to FFH). • DPTR can address any location from 0000H to FFFFH (64 Kbytes, 216 locations). • Again to remind, only R0 and R1 can be used with indirect addressing mode • Mnemonic used for external data memory transfer is MOVX. The letter ‘X’ in the mnemonic indicates the external data memory
  • 28. DPTR or Ri register should be initialized with address of the desired data. Note that all data transfer in this group occurs through Accumulator only, i.e. all external data movements require the A register either as source or destination operand.
  • 29.
  • 30. Program The word ‘HI’ is burned (written) in the flash ROM address 100H (‘H’) and 101H (‘I’). Copy this word in to internal RAM address 10H and 11H.
  • 31. Exchange the contents of the PSW and internal RAM address 50H
  • 32. PUSH AND POP INSTRUCTIONS  It is associated with stack operation. Using these instructions, the data is transferred between stack and specified direct address.  The stack is a special memory area in the internal RAM that is used for temporary storage and retrieval of the data, while the execution of a program.  It is Last In First Out (LIFO) type memory.  The data stored in the stack can be numbers or address. The stack is accessed with the help of stack pointer (SP) register.  SP holds address (of internal RAM) where data from source operand will be saved (pushed) or data to destination address will be retrieved (popped).  Stack pointer always points to top of the stack, i.e. last memory address accessed.  It should be initialized to a defined value (default value of SP is 07H).
  • 33.
  • 34. Copy the contents of registers R0 to R7 into internal RAM addresses 40H to 47H respectively using PUSH instructions
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40. Write program to add two 16-bit numbers 42E1H and 255CH
  • 41.
  • 42. Write instructions to subtract 10H from 30H using immediate and register addressing
  • 43.
  • 44. Represent –6 and –128 in 8–bit binary using 2’s complement representation.
  • 45.
  • 46.
  • 47.
  • 48. Multiply the contents of R0 and R1 and place the result into R2 (MSByte) and R3 (LSByte)
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73. Assume that a switch is connected to pin P1.1 and the LED is connected to pin P1.2. Write a program to read the status of switch and send this status to LED.