SlideShare a Scribd company logo
1 of 33
Program Control Instructions A Course in Microprocessor Electrical Engineering Dept. University of Indonesia
The Jump Group ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Jump Group (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Jump Group (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Jump Group (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Jump Group (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Controlling the Flow of an  Assembly Language Program ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Procedures ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Procedures  (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to Interrupt ,[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to Interrupt (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to Interrupt (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to Interrupt (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to Interrupt (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Machine Control and Miscellanous Instructions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Machine Control and  Miscellanous Instructions  (cont’d) ,[object Object],[object Object],[object Object],[object Object],[object Object]
 
 
 
0000  33 DB  XOR  BX,BX 0002  B8 0001  START:  MOV AX,1 0005  03 C3  ADD AX,BX 0007  EB 17  JMP SHORT NEXT   0020  8B D8  NEXT  :  MOV BX,AX 0022  E8 DE  JMP START Example 6.1 0000  33 DB    XOR  BX,BX 0002  B8 0001  START:  MOV AX,1 0005  03 C3  ADD AX,BX 0007  E9 0200 R  JMP  NEXT   0020  8B D8  NEXT  :  MOV BX,AX 0022  E9 0002 R  JMP START   Example 6.2
Example 6.3     EXTRN UP : FAR 0000  33 DB  XOR  BX,BX 0002  B8 0001  START: MOV AX,1 0005  03 C3  ADD AX,BX 0007  E9 0200 R  JMP  NEXT   0020  8B D8  NEXT  :  MOV BX,AX 0022  E9 0002  ---- R  JMP FAR PTR START   0207  EA 0000 ---- E  JMP UP  
  ;A program that reads 1, 2 or 3 from the keyboard  ;if 1, 2 or 3 is typed , a 1, 2 or 3 is displayed ; .MODEL SMALL  ;select small model 0000   .DATA start of data segment 0000 0030 R TABLE  DW  ONE ;define lookup table 0002 0034 R DW  TWO 0004 0038 R  DW  THREE 0000 .CODE start code segment STARTUP ;start of program 0017 TOP: 0017 B4  01  MOV  AH,1 ;read key into AL 0019 CD 21  INT 21H   001B 2C 31  SUB  AL,31H ;convert to biner 001D 72 F8 JB  TOP ;if below ‘1’ typed 001F 3C 02 CMP AL,2 0021 77 F4 JA  TOP ;if above ‘3’ typed   0023 B4 00 MOV  AH,00H ;double to 0, 2  or 4 0025 03 C0 ADD  AX,AX 0027 BE 0000 R MOV  SI,OFFSET TABLE  ;address lookup table 002A 03 F0  ADD  SI,AX ;form lookup address 002C 8B 04  MOV  AX,[SI] ;get ONE, TWO or THREE 002E FF E0 JMP  AX ;jump address 0030 ONE: 0030 B2 31 MOV  DL,’1’ ;load ‘1’ for display 0032 EB 06  JMP BOT ;go display ‘1’ 0034 TWO: 0034 B2 32  MOV  DL,’2’ ;load ‘2’ for display 0036 EB 02  JMP BOT ;go display ‘2’ 0038 THREE: 0038 B2 33 MOV DL,’3’ ;load ‘3’ for display 003A BOT: 003A B4 02  MOV AH,2 ;display number 003C CD 21  INT 21H .EXIT ;exit to DOS END ;end of file Example 6.4
Example 6.5   .MODEL SMALL  ;select small model 0000   .DATA ;start of data segment 0000 0030 R TABLE  DW  ONE ;define lookup table 0002 0034 R DW  TWO 0004 0038 R  DW  THREE 0000 .CODE ;start code segment .STARTUP ;start of program 0017 TOP: 0017 B4  01  MOV  AH,1 ;read key into AL 0019 CD 21  INT 21H   001B 2C 31  SUB  AL,31H ;convert to biner 001D 72 F8 JB  TOP ;if below ‘1’ typed 001F 3C 02 CMP AL,2 0021 77 F4 JA  TOP ;if above ‘3’ typed 0023 B4 00 MOV  AH,0 ;calculate table address 0025 03 C0 ADD  AX,AX 0027 03 F0 ADD SI,AX 0029 FF A4  0000 R JMP TABLE  [SI] ;jump to ONE, TWO or THREE 002D ONE: 002D B2 31 MOV  DL,’1’ ;load  DL with ‘1’ 002F EB 06  JMP BOT 0031 TWO: 0031 B2 32  MOV  DL,’2’ ;load  DL with ‘2’ 0033 EB 02  JMP BOT 0035 THREE: 0035 B2 33 MOV DL,’3’ ;load DL with‘3’  0037 BOT: 0037 B4 02  MOV AH,2 ;display ONE, Two or THREE 0039 CD 21  INT 21H .EXIT ;exit to DOS END ;end of file  
Example 6.6 ;A procedure that searches a table of 100 bytes for 0AH ;The address, TABLE, is transferred to the procedure  ;through the SI register ; 0017 SCAN  PROC NEAR 0017 B9 0064 MOV  CX,100 ;load count of 100 001A B0 0A MOV AL,0AH ;load AL with 0AH 001C FC  CLD ;select increment 001D F2/AE REPNE JMP  NEXT ;test 100 bytes fir 0AH 001F F9 STC ;set carry for not found 0020 F3 01 JCXZ  NOT_FOUND ;if not found 0022 F8 CLC ;clear carry if found   0023 NOT_FOUND:   0023 C3 RET ;return from procedure   0024  SCAN ENDP
Example 6.7 ;A program that sums the contens of  BLOCK1 and BLOCK2 ;and stores the result over top of data in BLOCK2 ;through the SI register ; .MODEL  SMALL  ;select small model  0000 .DATA ;start of data segment 0000 0064 [ BLOCK1 DW 100 DUP (?) ;100 bytes for BLOCK1   0000 ] 00C8 0064 [ BLOCK2 DW 100 DUP (?) ;100 bytes for  BLOCK2   0000 ] 0000 .CODE ;start of code segment .STARTUP ;start of program 0017 8C D8 MOV AX,DS ;overlap DS and ES 0019 8E C0 MOV ES,AX 001B FC    CLD  ;select increment 001C B9 0064 MOV CX,100 ;load count 100 001F BE 0000 R MOV SI,OFFSET BLOCK1 ;address BLOCK1 0022 BF 0000 R MOV DI,OFFSET BLOCK2 ;address BLOCK2 0025  L1: 0025 AD LODSW ;load AX with BLOCK1 0026 26:03 05 ADD AX,ES:[DI] ;add BLOCK2 data to AX 0029 AB STOSW ;store sum in BLOCK2 002A E2 F9 LOOP L1 ;repeat 100 times .EXIT ;exit to DOS END ;end file
; Inti Program Sequence MOV AH,30H INT 21 H .IF  AL<3  && AH<30 MOV AH,4CH INT 21H .ENDIF Example 6.8(a) Example 6.8(b) ; Diagram file bahasa Mesin pada contoh 6.8 (a) ; 0000 B4 30   MOV AH,30H 0002 CD 21   INT 21H  .IF AL<3 &&  AH<30 0004 3C 03 *   CMP AL,003H 0006 73 09 *  JAE  @c0001 0008 80 FC 1E*  CMP AH,01EH 000B 73 04 *  JAE @c0001 000D B4 4C   MOV AH,4CH 000F CD 21   INT 21H .ENDIF 0011  * @C0001:
Example 6.9   [c2]
Example 6.10 ; Program yang membaca sebuah key dan menyimpan dalam Hexadecimal ; Nilai pada memori lokasdi TEMP.     .Mode Small   : Pilih model SMALL 0000   .  Data   : Memulai data segmen 0000  00   TEMP  DB?   : Define TEMP 0000    .CODE   : Awal Code segment   STARTUP   : Start program 0017  B4  01   MOV AH,1   : Pembacaan key 0019  CD 21   INT 21H   . IF  AL>=’a’ && AL<=’f’   : Bila dibagian sisi bawah 0023  2C  57  SUB AL,57H   .ELSEIF  AL>=’A’ && AL<=’F’  : bila bagian sisi atas 002F  2C  37   .ELSE   : Hal lain 0033  2C  30   .  SUB AL,30H   .ENDIF A2  0000 R  MOV  TEMP, AL   .EXIT    : Keluar DOS   END   : Akhir file
 
Example 6-16 0000 SUMS PROC  NEAR 0000   03  C3 ADD AX,BX 0002  03  C1 ADD AX,CX 0004  03  C2 ADD AX,DX 0006  C3 RET 0007 SUMS ENDP 0007 SUMS1 PROC  FAR 0007  03  C3 ADD AX,BX 0009  03  C1 ADD AX,CX
 
 
 

More Related Content

What's hot

Understanding Tomasulo Algorithm
Understanding Tomasulo AlgorithmUnderstanding Tomasulo Algorithm
Understanding Tomasulo Algorithmonesuper
 
subroutines and interrupts
subroutines and interruptssubroutines and interrupts
subroutines and interruptsManoj Chowdary
 
Vulnerabilities analysis of fault and Trojan attacks in FSM
Vulnerabilities analysis of fault and Trojan attacks in FSMVulnerabilities analysis of fault and Trojan attacks in FSM
Vulnerabilities analysis of fault and Trojan attacks in FSMKurra Gopi
 
Flag register 8086 assignment
Flag register 8086 assignmentFlag register 8086 assignment
Flag register 8086 assignmentZia3130
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Béo Tú
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorRabin BK
 
Tomasulo Algorithm
Tomasulo AlgorithmTomasulo Algorithm
Tomasulo AlgorithmFarwa Ansari
 
NG3S903 - Electronic Systems Engineering - Fault Modelling Techniques
NG3S903 - Electronic Systems Engineering - Fault Modelling TechniquesNG3S903 - Electronic Systems Engineering - Fault Modelling Techniques
NG3S903 - Electronic Systems Engineering - Fault Modelling TechniquesChris Francis
 
8085:branching and logical instruction
8085:branching and logical instruction8085:branching and logical instruction
8085:branching and logical instructionNemish Bhojani
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solutionZunAib Ali
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutinemilandhara
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiMuhammad Abdullah
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!PRABHAHARAN429
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerjokersclown57
 
8051 basic programming
8051 basic programming8051 basic programming
8051 basic programmingANJUSHA R
 
Docfoc.com ericsson commands
Docfoc.com ericsson commandsDocfoc.com ericsson commands
Docfoc.com ericsson commandsadel kaoubi
 

What's hot (20)

Understanding Tomasulo Algorithm
Understanding Tomasulo AlgorithmUnderstanding Tomasulo Algorithm
Understanding Tomasulo Algorithm
 
branch ins 8051
branch ins 8051branch ins 8051
branch ins 8051
 
Csd01
Csd01Csd01
Csd01
 
subroutines and interrupts
subroutines and interruptssubroutines and interrupts
subroutines and interrupts
 
Vulnerabilities analysis of fault and Trojan attacks in FSM
Vulnerabilities analysis of fault and Trojan attacks in FSMVulnerabilities analysis of fault and Trojan attacks in FSM
Vulnerabilities analysis of fault and Trojan attacks in FSM
 
Flag register 8086 assignment
Flag register 8086 assignmentFlag register 8086 assignment
Flag register 8086 assignment
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessor
 
Tomasulo Algorithm
Tomasulo AlgorithmTomasulo Algorithm
Tomasulo Algorithm
 
NG3S903 - Electronic Systems Engineering - Fault Modelling Techniques
NG3S903 - Electronic Systems Engineering - Fault Modelling TechniquesNG3S903 - Electronic Systems Engineering - Fault Modelling Techniques
NG3S903 - Electronic Systems Engineering - Fault Modelling Techniques
 
8085:branching and logical instruction
8085:branching and logical instruction8085:branching and logical instruction
8085:branching and logical instruction
 
microprocessors
microprocessorsmicroprocessors
microprocessors
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solution
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidi
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!
 
Lec14
Lec14Lec14
Lec14
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
8051 basic programming
8051 basic programming8051 basic programming
8051 basic programming
 
Docfoc.com ericsson commands
Docfoc.com ericsson commandsDocfoc.com ericsson commands
Docfoc.com ericsson commands
 

Viewers also liked

Microprocessor Instructions
Microprocessor InstructionsMicroprocessor Instructions
Microprocessor InstructionsChinmoy Ghorai
 
MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085Sumadeep Juvvalapalem
 
Assembly level language
Assembly level languageAssembly level language
Assembly level languagePDFSHARE
 
8086 Microprocessor powerpoint
8086  Microprocessor  powerpoint8086  Microprocessor  powerpoint
8086 Microprocessor powerpointRandhir Kumar
 
Unit 4 assembly language programming
Unit 4   assembly language programmingUnit 4   assembly language programming
Unit 4 assembly language programmingKartik Sharma
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulationSanjeev Patel
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorAshita Agrawal
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)Ashim Saha
 

Viewers also liked (11)

Microprocessor Instructions
Microprocessor InstructionsMicroprocessor Instructions
Microprocessor Instructions
 
MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
8086 Microprocessor powerpoint
8086  Microprocessor  powerpoint8086  Microprocessor  powerpoint
8086 Microprocessor powerpoint
 
Unit 4 assembly language programming
Unit 4   assembly language programmingUnit 4   assembly language programming
Unit 4 assembly language programming
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 Microprocessor
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 

Similar to Chapter6-mikroprocessor

1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086techbed
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copymkazree
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set ArchitectureDilum Bandara
 
Microcontrollers ii
Microcontrollers iiMicrocontrollers ii
Microcontrollers iiKumar Kumar
 
8085_MicroelectronicAndMicroprocess.pdf
8085_MicroelectronicAndMicroprocess.pdf8085_MicroelectronicAndMicroprocess.pdf
8085_MicroelectronicAndMicroprocess.pdfFloraKara
 
MicrocontrollersII.ppt
MicrocontrollersII.pptMicrocontrollersII.ppt
MicrocontrollersII.pptSatheeshMECE
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent vijaydeepakg
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACnanocdac
 
Lab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence CounterLab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence CounterKatrina Little
 

Similar to Chapter6-mikroprocessor (20)

1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 
Microcontrollers ii
Microcontrollers iiMicrocontrollers ii
Microcontrollers ii
 
1.pdf
1.pdf1.pdf
1.pdf
 
8085_MicroelectronicAndMicroprocess.pdf
8085_MicroelectronicAndMicroprocess.pdf8085_MicroelectronicAndMicroprocess.pdf
8085_MicroelectronicAndMicroprocess.pdf
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
MicrocontrollersII.ppt
MicrocontrollersII.pptMicrocontrollersII.ppt
MicrocontrollersII.ppt
 
Real Time Embedded System
Real Time Embedded SystemReal Time Embedded System
Real Time Embedded System
 
Assembler
AssemblerAssembler
Assembler
 
Assembler
AssemblerAssembler
Assembler
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
Unit iii mca 1st year
Unit iii mca 1st yearUnit iii mca 1st year
Unit iii mca 1st year
 
Lab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence CounterLab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence Counter
 
Al2ed chapter7
Al2ed chapter7Al2ed chapter7
Al2ed chapter7
 
3 jump, loop and call instructions
3 jump, loop and call instructions3 jump, loop and call instructions
3 jump, loop and call instructions
 
Assembler
AssemblerAssembler
Assembler
 

More from teknik komputer ui (20)

Modul 1
Modul 1Modul 1
Modul 1
 
Modul 5
Modul 5Modul 5
Modul 5
 
Modul 4
Modul 4Modul 4
Modul 4
 
Modul 3
Modul 3Modul 3
Modul 3
 
Modul 1
Modul 1Modul 1
Modul 1
 
Modul 2
Modul 2Modul 2
Modul 2
 
The cisco networking academy net riders indonesia 2010 competition
The cisco networking academy net riders indonesia 2010 competitionThe cisco networking academy net riders indonesia 2010 competition
The cisco networking academy net riders indonesia 2010 competition
 
Rencana Proyek Divisi Komputer.doc
Rencana Proyek Divisi Komputer.docRencana Proyek Divisi Komputer.doc
Rencana Proyek Divisi Komputer.doc
 
Salinan Research Paper
Salinan Research PaperSalinan Research Paper
Salinan Research Paper
 
Chapter_1_Case_Study
Chapter_1_Case_StudyChapter_1_Case_Study
Chapter_1_Case_Study
 
Iins practice questions
Iins practice questionsIins practice questions
Iins practice questions
 
S1 intr ftui
S1 intr ftuiS1 intr ftui
S1 intr ftui
 
Exploration network chapter7
Exploration network chapter7Exploration network chapter7
Exploration network chapter7
 
Exploration network chapter6
Exploration network chapter6Exploration network chapter6
Exploration network chapter6
 
Exploration network chapter5
Exploration network chapter5Exploration network chapter5
Exploration network chapter5
 
Exploration network chapter4
Exploration network chapter4Exploration network chapter4
Exploration network chapter4
 
Exploration network chapter3
Exploration network chapter3Exploration network chapter3
Exploration network chapter3
 
Exploration network chapter2
Exploration network chapter2Exploration network chapter2
Exploration network chapter2
 
Exploration network chapter1
Exploration network chapter1Exploration network chapter1
Exploration network chapter1
 
Exploration network chapter11
Exploration network chapter11Exploration network chapter11
Exploration network chapter11
 

Chapter6-mikroprocessor

  • 1. Program Control Instructions A Course in Microprocessor Electrical Engineering Dept. University of Indonesia
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.  
  • 18.  
  • 19.  
  • 20. 0000 33 DB XOR BX,BX 0002 B8 0001 START: MOV AX,1 0005 03 C3 ADD AX,BX 0007 EB 17 JMP SHORT NEXT   0020 8B D8 NEXT : MOV BX,AX 0022 E8 DE JMP START Example 6.1 0000 33 DB XOR BX,BX 0002 B8 0001 START: MOV AX,1 0005 03 C3 ADD AX,BX 0007 E9 0200 R JMP NEXT   0020 8B D8 NEXT : MOV BX,AX 0022 E9 0002 R JMP START Example 6.2
  • 21. Example 6.3   EXTRN UP : FAR 0000 33 DB XOR BX,BX 0002 B8 0001 START: MOV AX,1 0005 03 C3 ADD AX,BX 0007 E9 0200 R JMP NEXT   0020 8B D8 NEXT : MOV BX,AX 0022 E9 0002 ---- R JMP FAR PTR START   0207 EA 0000 ---- E JMP UP  
  • 22.   ;A program that reads 1, 2 or 3 from the keyboard ;if 1, 2 or 3 is typed , a 1, 2 or 3 is displayed ; .MODEL SMALL ;select small model 0000 .DATA start of data segment 0000 0030 R TABLE DW ONE ;define lookup table 0002 0034 R DW TWO 0004 0038 R DW THREE 0000 .CODE start code segment STARTUP ;start of program 0017 TOP: 0017 B4 01 MOV AH,1 ;read key into AL 0019 CD 21 INT 21H   001B 2C 31 SUB AL,31H ;convert to biner 001D 72 F8 JB TOP ;if below ‘1’ typed 001F 3C 02 CMP AL,2 0021 77 F4 JA TOP ;if above ‘3’ typed   0023 B4 00 MOV AH,00H ;double to 0, 2 or 4 0025 03 C0 ADD AX,AX 0027 BE 0000 R MOV SI,OFFSET TABLE ;address lookup table 002A 03 F0 ADD SI,AX ;form lookup address 002C 8B 04 MOV AX,[SI] ;get ONE, TWO or THREE 002E FF E0 JMP AX ;jump address 0030 ONE: 0030 B2 31 MOV DL,’1’ ;load ‘1’ for display 0032 EB 06 JMP BOT ;go display ‘1’ 0034 TWO: 0034 B2 32 MOV DL,’2’ ;load ‘2’ for display 0036 EB 02 JMP BOT ;go display ‘2’ 0038 THREE: 0038 B2 33 MOV DL,’3’ ;load ‘3’ for display 003A BOT: 003A B4 02 MOV AH,2 ;display number 003C CD 21 INT 21H .EXIT ;exit to DOS END ;end of file Example 6.4
  • 23. Example 6.5   .MODEL SMALL ;select small model 0000 .DATA ;start of data segment 0000 0030 R TABLE DW ONE ;define lookup table 0002 0034 R DW TWO 0004 0038 R DW THREE 0000 .CODE ;start code segment .STARTUP ;start of program 0017 TOP: 0017 B4 01 MOV AH,1 ;read key into AL 0019 CD 21 INT 21H   001B 2C 31 SUB AL,31H ;convert to biner 001D 72 F8 JB TOP ;if below ‘1’ typed 001F 3C 02 CMP AL,2 0021 77 F4 JA TOP ;if above ‘3’ typed 0023 B4 00 MOV AH,0 ;calculate table address 0025 03 C0 ADD AX,AX 0027 03 F0 ADD SI,AX 0029 FF A4 0000 R JMP TABLE [SI] ;jump to ONE, TWO or THREE 002D ONE: 002D B2 31 MOV DL,’1’ ;load DL with ‘1’ 002F EB 06 JMP BOT 0031 TWO: 0031 B2 32 MOV DL,’2’ ;load DL with ‘2’ 0033 EB 02 JMP BOT 0035 THREE: 0035 B2 33 MOV DL,’3’ ;load DL with‘3’ 0037 BOT: 0037 B4 02 MOV AH,2 ;display ONE, Two or THREE 0039 CD 21 INT 21H .EXIT ;exit to DOS END ;end of file  
  • 24. Example 6.6 ;A procedure that searches a table of 100 bytes for 0AH ;The address, TABLE, is transferred to the procedure ;through the SI register ; 0017 SCAN PROC NEAR 0017 B9 0064 MOV CX,100 ;load count of 100 001A B0 0A MOV AL,0AH ;load AL with 0AH 001C FC CLD ;select increment 001D F2/AE REPNE JMP NEXT ;test 100 bytes fir 0AH 001F F9 STC ;set carry for not found 0020 F3 01 JCXZ NOT_FOUND ;if not found 0022 F8 CLC ;clear carry if found   0023 NOT_FOUND:   0023 C3 RET ;return from procedure   0024 SCAN ENDP
  • 25. Example 6.7 ;A program that sums the contens of BLOCK1 and BLOCK2 ;and stores the result over top of data in BLOCK2 ;through the SI register ; .MODEL SMALL ;select small model 0000 .DATA ;start of data segment 0000 0064 [ BLOCK1 DW 100 DUP (?) ;100 bytes for BLOCK1 0000 ] 00C8 0064 [ BLOCK2 DW 100 DUP (?) ;100 bytes for BLOCK2 0000 ] 0000 .CODE ;start of code segment .STARTUP ;start of program 0017 8C D8 MOV AX,DS ;overlap DS and ES 0019 8E C0 MOV ES,AX 001B FC CLD ;select increment 001C B9 0064 MOV CX,100 ;load count 100 001F BE 0000 R MOV SI,OFFSET BLOCK1 ;address BLOCK1 0022 BF 0000 R MOV DI,OFFSET BLOCK2 ;address BLOCK2 0025 L1: 0025 AD LODSW ;load AX with BLOCK1 0026 26:03 05 ADD AX,ES:[DI] ;add BLOCK2 data to AX 0029 AB STOSW ;store sum in BLOCK2 002A E2 F9 LOOP L1 ;repeat 100 times .EXIT ;exit to DOS END ;end file
  • 26. ; Inti Program Sequence MOV AH,30H INT 21 H .IF AL<3 && AH<30 MOV AH,4CH INT 21H .ENDIF Example 6.8(a) Example 6.8(b) ; Diagram file bahasa Mesin pada contoh 6.8 (a) ; 0000 B4 30 MOV AH,30H 0002 CD 21 INT 21H .IF AL<3 && AH<30 0004 3C 03 * CMP AL,003H 0006 73 09 * JAE @c0001 0008 80 FC 1E* CMP AH,01EH 000B 73 04 * JAE @c0001 000D B4 4C MOV AH,4CH 000F CD 21 INT 21H .ENDIF 0011 * @C0001:
  • 28. Example 6.10 ; Program yang membaca sebuah key dan menyimpan dalam Hexadecimal ; Nilai pada memori lokasdi TEMP.   .Mode Small : Pilih model SMALL 0000 . Data : Memulai data segmen 0000 00 TEMP DB? : Define TEMP 0000 .CODE : Awal Code segment STARTUP : Start program 0017 B4 01 MOV AH,1 : Pembacaan key 0019 CD 21 INT 21H . IF AL>=’a’ && AL<=’f’ : Bila dibagian sisi bawah 0023 2C 57 SUB AL,57H .ELSEIF AL>=’A’ && AL<=’F’ : bila bagian sisi atas 002F 2C 37 .ELSE : Hal lain 0033 2C 30 . SUB AL,30H .ENDIF A2 0000 R MOV TEMP, AL .EXIT : Keluar DOS END : Akhir file
  • 29.  
  • 30. Example 6-16 0000 SUMS PROC NEAR 0000 03 C3 ADD AX,BX 0002 03 C1 ADD AX,CX 0004 03 C2 ADD AX,DX 0006 C3 RET 0007 SUMS ENDP 0007 SUMS1 PROC FAR 0007 03 C3 ADD AX,BX 0009 03 C1 ADD AX,CX
  • 31.  
  • 32.  
  • 33.