Lecture 9 Software Architecture
-
Upload
khaled-waly-ahlawy -
Category
Documents
-
view
214 -
download
0
Transcript of Lecture 9 Software Architecture
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 126
Micro processors Systems
Software Architecture of theSoftware Architecture of the 8088808880868086MicroprocessorsMicroprocessors
Lecturer DrLecturer Dr HeshamHesham ElEl ZoukaZouka
983107983107983092983090983089 983085 983107983151983149983152983157983156983141983154 983109983150983143983145983150983141983141983154983145983150983143 983108983141983152983156983086
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 226
225
Pipelined architecture of the 8886 microprocessors2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 326
Execution and bus interface units2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 426
Software Model of the 8886 Microprocessors2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 526
Memory Address Space and Data Organization
Memory address space
Storing a word in memory
What is the word in (b) in Hex
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 626
Aligned and misaligned data word
Is the word stored in (b) aligned
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 726
Aligned and misaligned double words of data2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 226
225
Pipelined architecture of the 8886 microprocessors2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 326
Execution and bus interface units2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 426
Software Model of the 8886 Microprocessors2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 526
Memory Address Space and Data Organization
Memory address space
Storing a word in memory
What is the word in (b) in Hex
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 626
Aligned and misaligned data word
Is the word stored in (b) aligned
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 726
Aligned and misaligned double words of data2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 326
Execution and bus interface units2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 426
Software Model of the 8886 Microprocessors2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 526
Memory Address Space and Data Organization
Memory address space
Storing a word in memory
What is the word in (b) in Hex
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 626
Aligned and misaligned data word
Is the word stored in (b) aligned
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 726
Aligned and misaligned double words of data2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 426
Software Model of the 8886 Microprocessors2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 526
Memory Address Space and Data Organization
Memory address space
Storing a word in memory
What is the word in (b) in Hex
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 626
Aligned and misaligned data word
Is the word stored in (b) aligned
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 726
Aligned and misaligned double words of data2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 526
Memory Address Space and Data Organization
Memory address space
Storing a word in memory
What is the word in (b) in Hex
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 626
Aligned and misaligned data word
Is the word stored in (b) aligned
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 726
Aligned and misaligned double words of data2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 626
Aligned and misaligned data word
Is the word stored in (b) aligned
2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 726
Aligned and misaligned double words of data2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 726
Aligned and misaligned double words of data2 0
0 9 D r H e sh am
E L
Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 826
Storing double word in memory2 0
0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 926
Example
How should the pointer with segment base address equal to
A000H and offset address 55FFH be stored at an even-address boundary at 0008H
Is the double word aligned
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1026
Data Types
Unsigned word integer0 ndash 65535
Unsigned byte integer0 - 255
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1126
Signed integers
-128 - +127
-32768 - +32767
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1226
Binary Coded Decimal (BCD)
Unpacked BCD
Packed BCD
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1326
ExampleExample
TheThe packed BCD data stored at byte addresspacked BCD data stored at byte address 0100001000HHequalsequals 100100011001000122 What is the twoWhat is the two--digit decimaldigit decimal
numbersnumbers
100100012 =1001BCD 0001BCD = 9110
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1426
American Standard Code for Information Interchange ASCII2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1526
Dedicated Reserved and General use Memory
128 Bytes
1MB=1048576
Some address locations have dedicated functions and should not be used asgeneral memory for storage of data or instructions of a program
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1626
Data Registers
bull Normally used for storing temporary resultsbull Each of the registers is 16 bits wide (AX BX CX DX)bull Can be accessed as either 16 or 8 bits AX AH AL
2 0 0 9 D r H e sh am
E L Z o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1726
Data Registers - Operations2 0 0 9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1826
Pointer and Index Registers
- All 16 bits wide LH bytes are not accessible- Used as memory pointers
bull Example MOV AH [SI]Move the byte stored in memory location whose address is contained in register SI to register AH
bull-IP is not under direct control of the programmer
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 1926
Status Register (Control Flags)
bull Six of the flags are status indicators reflecting properties of the lastarithmetic or logical instruction
bull For example if register AL = 7Fh and the instruction ADD AL1is executed then the following happen
AL = 80hCF = 0 there is no carry out of bit 7PF = 0 80h has an odd number of onesAF = 1 there is a carry out of bit 3 into bit 4ZF = 0 the result is not zero
SF = 1 bit seven is oneOF = 1 the sign bit has changed
bull Can be used to transfer program control to a new memory locationeg ADD AL1
JNZ 0100h
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2026
Flag register
983107983151983150983140983145983156983145983151983150983137983148 983142983148983137983143983155
983107983151983150983156983154983151983148 983142983148983137983143983155
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2126
Flag register - examples
0110100101101001 ++ 0001100100011001
AnsAns CFCF00 ZFZF00 SFSF11 OFOF11 PFPF11 AFAF11
0111111101111111 ++ 1000000110000001
AnsAns CFCF 11 ZFZF11 SFSF00 OFOF00 PFPF11 AFAF11
0101101101011011 ++ 1101001011010010
AnsAns CFCF11 ZFZF00 SFSF00 OFOF00 PFPF11 AFAF00
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2226
Generating A Memory Address
bull Addresses within a segment can range from address 0 to addressFFFFh This corresponds to the 64Kbyte length of the segment
bull An address within a segment is called an offset or logical address
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2326
Example2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2426
The Stack
- The stack is used for temporary storage of information such as data oraddresses for instance when a CALL is executed the 8088automatically PUSHes the current value of CS and IP onto the stack
bull Other registers can also be pushedbull Before return from the subroutine POP instructions can be used to pop
values back from the stack into the corresponding registers
2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2526
Example for PUSH2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a
7232019 Lecture 9 Software Architecture
httpslidepdfcomreaderfulllecture-9-software-architecture 2626
Example for POP2 0 0
9 D r H e sh am
E L Z
o uk a