chapter 2 instruction addressing and execution. lesson plan review some concepts in the first week...
TRANSCRIPT
![Page 1: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/1.jpg)
Chapter 2Chapter 2
Instruction Addressing and Execution
Instruction Addressing and Execution
![Page 2: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/2.jpg)
Lesson plan
• Review some concepts in the first week• First assembly program with EMU8086• Related concepts with the first program:
– Loading program – Boot process– Handling the stack
![Page 3: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/3.jpg)
Recalling main concepts
![Page 4: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/4.jpg)
Recalling main concepts
![Page 5: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/5.jpg)
Recalling main concepts
• Segment: special areas defined to contain CODE, DATA and STACK
• Paragraph boundary: location evenly divisible by 16 or 10H
![Page 6: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/6.jpg)
Recalling main concepts
Stack Segment
Data Segment
Code Segment
SSDSCS
Segment Registers
![Page 7: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/7.jpg)
Practice
• Start EMU8086• Type the first assembly language
given• Compile: Compile icon• Run:Run icon
![Page 8: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/8.jpg)
.model small,
.stack
.datamessage db "Hello everybody! I am learning assembly
language!","$"
.code
main proc mov ax, seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int 21hmain endpend main
![Page 9: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/9.jpg)
Result of the first program
![Page 10: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/10.jpg)
Types of programs
• *.COM and *.EXE files– *.COM: consists of one segment
containing code, data and stack– *.exe: separate code, data and stack
segments
![Page 11: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/11.jpg)
Loading *.exe program• Access *.exe from disk• 256-byte Program Segment Prefix (PSP)
on a paragraph boundary• Store the program immediately
following the PSP• Load address of PSP in the DS & ES• Load code segment in CS, set IP • Load address of the stack to SS, set SP• Transfer control to the program for
execution
![Page 12: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/12.jpg)
PSP
![Page 13: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/13.jpg)
.model small,
.stack
.datamessage db "Hello everybody! I am learning assembly
language!","$"
.code
main proc mov ax, seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int 21hmain endpend main
Assembly directive to
define memory
model to use in the
program
![Page 14: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/14.jpg)
Real and Protected mode
Real Mode 16-bit Protected
Mode
32-bit Protected Mode
Segment base address
20-bit24-bit,
from descriptor
32-bit,from descriptor
Segment size (limit)
16-bit, 64K bytes (fixed)
16-bit, 1-64K bytes
20-bit, 1-1M bytes or 4K-4G bytes
Segment protection
no yes yes
Segmentregister
segment base address / 16
selector selector
![Page 15: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/15.jpg)
Protected mode-Is a type of memory utilization, available on Intel 80286 and later
-Support:protection: each program is protected
from interference from other programs. extended memory : Enables a single
program to access more than 640K of memory. virtual memory : Expands the address
space to over 1GB. Multitasking:
![Page 16: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/16.jpg)
Booting processWhat is booting?
• The process of starting or restarting a computer
cold boot
Process of turning on a computer after it
has been powered off completely
warm boot
Process of restarting a
computer that is already powered on
Also called a warm start
![Page 17: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/17.jpg)
Booting process
processor
BIO
S
hard disk
CD-ROM drive
(RAM) memory modules
CMOS
floppy disk drive
Step 6
expansion cards
How does a personal computer boot up?
![Page 18: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/18.jpg)
BIOS Boot process
BIOS routineFFFF0H
Interrupt VectorTable
BIOS Data Areas
Access the bootstrap
loader
Check portsInitialize devices
![Page 19: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/19.jpg)
.model small,
.stack
.datamessage db "Hello everybody! I am learning assembly
language!","$"
.code
main proc mov ax, seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int 21hmain endpend main
Assembly directive to define stack to use in the
program
![Page 20: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/20.jpg)
STACK
• The word is from data structure• Last In, First Out (LIFO) mechanism• STACK in OS has three main
functions:– Contains return address – Data– Content of present registers
![Page 21: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/21.jpg)
STACK
• PUSH– Decrease SP by 2 and store a value
there
• POP– Return a value from stack and
increase SP by 2
![Page 22: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/22.jpg)
Lesson plan• Review loading an *.exe file• Concept of execution of instructions• Practice:
• Execution of instructions
![Page 23: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/23.jpg)
Access *.exe from disk256-byte Program Segment Prefix (PSP) on a paragraph boundaryStore the program immediately following the PSPLoad address of PSP in the DS & ESLoad code segment in CS, set IP Load address of the stack to SS, set SPTransfer control to the program for execution
Loading *.exe file
![Page 24: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/24.jpg)
Loading *.exe file
• The sequence of segments (code, data, and stack) is given
• SS: contains the address of the beginning of the stack
• CS: contains the address of the beginning of the code segment
• DS: contains the address of the beginning of the data segment
• SP: contains the size of stack
![Page 25: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/25.jpg)
Practice2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
![Page 26: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/26.jpg)
Practice2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
PSP 2B360HPSP size 100HOffset 0HSS 2B460H
(stored as 2B46)
2B46HSS
![Page 27: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/27.jpg)
Practice
2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
2B46HSS
PSP 2B360HPSP size 100HOffset 30H
70HCS 2B500H (stored as 2B50)
CS 2B50H
![Page 28: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/28.jpg)
Practice
2B360H
PSP
Stack Segment
Data Segment
Code Segment
Memory
2B46HSS
CS 2B50H
2B36H
2B36H
DS
ES
SP 0030H
![Page 29: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/29.jpg)
Instruction Execution and Addressing
• Executing an instruction include– Fetch the next instruction, put to a
queue (QUEUE: FIFO vs. STACK LIFO)– Decode the instruction– Execute the instruction
![Page 30: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/30.jpg)
Example
4AF0CS 0013IP
4AF13H
CS segment address: 4AF00HIP offset: 0013H________________________
+
Instruction address:
04B1DS
![Page 31: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/31.jpg)
Example4AF0CS 0013IP
4AF13H
A01200
Memory
04B1DS
Decode instruction:
AO: MOV [0012] to AL
![Page 32: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/32.jpg)
Example4AF0CS 0013IP
04B03H
A01200
Memory
04B1DS
DS segment address:04B10HIP offset: 0012H________________________
+
Data address: 04B22H
![Page 33: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/33.jpg)
Example4AF0CS 0013IP
04B03H
A01200
1B
Memory
04B1DS
04B22Data address:
04B22H
| 1B
AXAX
AH AL
![Page 34: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/34.jpg)
Practice
• Viewing memory location using DEBUGAt DOS prompt, type: DEBUG
• Checking Serial and parallel port:D 40:00
• Checking system equipmentD 40:10
![Page 35: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/35.jpg)
Practice
• Viewing memory location using DEBUGAt DOS prompt, type: DEBUG
• Checking Serial and parallel port:D 40:00
• Checking system equipmentD 40:10
![Page 36: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/36.jpg)
Practice
• Viewing memory location using DEBUGAt DOS prompt, type: DEBUG
• Checking Serial and parallel port:D 40:00
• Checking system equipmentD 40:10
22 C8 C822
reverse
Number of parallel printer ports=11(binary)=3 (15,14)
Number of serial ports=100(binary)=4 (11-9)
Number of diskette devices=00(binary)=1 (7,6)
Initial video mode =10 (5,4) (80x25 color)
Coprocessor present: 1 (1)Diskette drive is present: 0 (0)
![Page 37: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/37.jpg)
• Checking the keyboard status– D 40:17 (With Numlock and Caplock)
• Checking video status– D 40:49– D 40:84
Practice (cont.)
![Page 38: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/38.jpg)
• Checking copyright notice & serial number– D FE00:0
• Checking ROM BIOS dateD FFFF:5
Practice (cont.)
![Page 39: Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts](https://reader030.vdocuments.net/reader030/viewer/2022033103/56649ee55503460f94bf3fed/html5/thumbnails/39.jpg)
Running the first assembly program step by step using EMU 8086
Practice (cont.)