Professional Documents
Culture Documents
#################################################
###### Chapter - 1, Microcomputer Systems #######
#################################################
# Components
1. RAM (Random Access Memory)
2. ROM (Read Only Memory)
3. Buses
=> Data Bus
=> Address Bus
=> Control Bus
4. CPU (Central Processing Unit)
=> Execution Unit (EU)
=> ALU (Arithmetic and Logic Unit)
=> Registers
=> AX, BX, CX, DX, BP, SP, SI, DI, Flags
=> Bus Interface Unit (BIU)
=> Registers
=> DS, ES , SS, IP
5. I/O Ports
=> Serial Ports
=> Parallel Ports
# NOTES
1. Instructions, Instruction Set
2. Opcode
3. Fetch Execution Cycle
4. Assembler
5. Compiler
##################################################################
###### Chapter - 2, Representation of Numbers and Characters #####
##################################################################
1. Binary
2. Octal
3. Decimal
4. Hexadecimal
-1-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
5. Binary Arithmetic
6. Unsigned Integers
7. Signed Integers
8. One's Complement
9. Two's Complement
10. ASCII Codes
###########################################################
###### Chapter - 3, Organization of Intel Processors ######
###########################################################
# Registers (14)
1. Data Registers (4)
=>AX (AH, AL) - Accumulator Register
=>BX (BH, BL) - Base Register
=>CX (CH, CL) - Count Register
=>DX (DH, DL) - Data Register
2. Address Registers (9)
# Segment Registers (4) // Program Segments
=>CS - Code Segment
=>DS - Data Segment
=>SS - Stack Segment
=>ES - Extra Segment // for second data segment
# Pointer Registers (3)
=>SP - Stack Pointer
=>BP - Base Pointer
=>IP - Instruction Pointer
# Index Registers (2)
=>SI - Source Index
=>DI - Destination Index
3. Status/Flag Register (1)
- Status of Microprocessor
# Flags
=> Status Flags (ZF)
=> Control Flags (IF)
# NOTES
1 byte = 8 bits
-2-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
# Memory Segment
def: 2^16 (64K) consecutive memory bytes
# Purpose of OS
1. Reading and executing commands typed by the user
2. Performing I/0 operations
3. Generating error messages
4. Managing memory and other resources
##################################################################
##
###### Chapter - 4, Introduction to Intel PC Assembly Language
#####
##################################################################
##
# Statements
=> Instruction
=> Assembler Directive
# Statement Syntax
-3-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
# Data-Defining Pseudo-ops
1. DB - Define byte
2. DW - Define Word
3. DD - Define doubleword
4. DQ - Define quadword
5. DT - Define tenbytes
5.INC destination
eg. INC WORD1
6.DEC destination
eg. DEC BYTE1
7.NEG destination
eg. NEG BX
eg. B=A
MOV AX, A ;move A inot AX
MOV B, AX ;and then into B
eg. A=5-A
MOV AX, 5 ;put 5 in AX
SUB AX, A ;AX contains 5-A
MOV A, AX ;put it in A
eg. A=5-A
NEG A ;A=-A
ADD A, 5 ;A=5-A
eg. A=B-2xA
MOV AX, B ;AX has B
SUB AX, A ;AX has B-A
SUB AX, A ;AX has B-2xA
MOV A, AX ;move results to A
# # # Memory Model
# Syntax: .MODEL [memory_model]
memory_models: SMALL, MEDIUM, COMPACT, LARGE, HUGE
.MODEL SMALL
- Code in one Segment
- Data in one Segment
.MODEL MEDIUM
- Code in more than one Segment
- Data in one Segment
.MODEL COMPACT
- Code in one Segment
- Data in more than one Segment
.MODEL LARGE
- Code in more than one Segment
- Data in more than one Segment
- No array larger than 64k bytes
-5-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
.MODEL HUGE
- Code in more than one Segment
- Data in more than one Segment
- Arrays may be larger than 64k bytes
# # # Data Segment
- Contains all variables definition
- Constants definition
eg. .DATA
WORD1 DW 2
WORD2 DW 5
MSG DB 'This is a message'
MASK EQU 10010010B
# # # Stack Segment
- Reserve a block of memory in stack
# # # Code Segment
- Contains program's instructions
- Procedures declared in Code Segment
# EXAMPLE - 0
-6-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
.MODEL SMALL
.STACK 100H
.DATA
;data definitions go here
.CODE
MAIN PROC
;instructions go here
MAIN ENDP
;other procedures go here
END MAIN
# INT(Interrupt) Instruction
- Invokes a DOS or BIOS routine
# Syntax: INT interrupt_number
eg. INT 16h
- Invokes BIOS routine to perform keyboard input
eg. INT 21h
- Invokes DOS functions
# function specified by placing function number in AH
# function numbers
1 - single-key-input
2 - single-character-input
3 - character-string-output
# Function 1 - single-key-input
Input: AH = 1
Output: AL = ASCII code if any character key pressed
= 0 if non-character key pressed
# Control Functions
7 (07H) => BEL => Beep (Sounds a tone)
8 (08H) => BS => Backspace
9 (09H) => HT => Tab
A (0AH) => LF => Line feed (newline)
D (0DH) => CR => Carriage Return (start of current line)
# EXAMPLE - 01
TITLE PGM_1: ECHO PROGRAM
.MODEL SMALL
.STACK 100H
.CODE
MAIN PROC
;main prompt
MOV AH, 2 ;display character function
MOV DL, '?' ;character is '?'
INT 21H ;display it
;input a character
MOV AH, 1 ;read character function
INT 21H ;character in AL
MOV BL, AL ;save it in BL
-8-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
;display character
MOV DL, BL ;retrieve character
INT 21H ;and display it
;return to DOS
MOV AH, 4CH ;DOS exit funcation
INT 21H ;exit to DOS
;main end
MAIN ENDP
END MAIN
# Notes:
- When a program terminates, it should return control to DOS.
This can be accomplished by excuting INT 21h, funcation 4CH
# Workflow:
Editor => .ASM File => Assembler => .OBJ File => Linker =>
.EXE File
-9-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
-10-
C:\Users\zahid\Desktop\x86\notes.docx Friday, August 21, 2020 11:58 PM
-11-