Meaning of Model Small: by Prof. Ahmed Fahmy
Meaning of Model Small: by Prof. Ahmed Fahmy
By
Prof. Ahmed Fahmy
.Model small/Compact/Medium/Large
Small 1 1
Compact 1 >1
Medium >1 1
Large >1 >1
INTERRUPTS
Prof. Ahmed Fahmy
Interrupt 21H, Writing Character Service
(INT 21H, Service 2)
To display character A write the following:
MOV DL, 41H ; where 41H is the
;ASCII code of letter A
MOV AH, 2 ;Service number 2
INT 21H
Interrupt 21H Writing Character Service
(INT 21H, Service 2)
OR write the following Code:
MOV DL, ‘A’ ;Character A will be
;displayed
MOV AH, 2 ;Service number 2
INT 21H
Ex1. Write down an Assembly program that
can display the ASCII table(1/5)
Ex1. Write down an Assembly program that
can display the ASCII table(2/5)
;ASCII.asm
;Write the ASCII table from ASCII 0 to ASCII 255
• model small
• stack 32
• DATA
char DB 0
Ex1. Write down an Assembly program that
can display the ASCII table(3/5)
• CODE
START PROC FAR
PUSH DS ;Start program initialization
MOV AX,0
PUSH AX
MOV AX, @DATA
MOV DS, AX ;End program initialization
Ex1. Write down an Assembly program that
can display the ASCII table(4/5)
MOV CX,255
MOV AH, 2
aa: MOV DL, char
INT 21H
inc char
LOOP aa
END START
Ex1. Write down an Assembly program that
can display the ASCII table(5/5)
Interrupt 21H, Reading Character Service
(INT 21H, Service 1, 6, 7, and 8)
1
7
8
Interrupt 21H, Reading Character Service
(INT 21H, Service 1, 6, 7, and 8)
To read a character using INT 21H service 1:
MOV AH, 1
INT 21H ;The ASCII code is stored in AL
Example 2
Write down an assembly program that keeps
reading characters from the keyboard until character ‘z’
is read. As soon as character ‘z’ is read, your program
should stop.
Every time the program reads a character, it
should display its succeeding 10 characters.
Example 2 (1/9)
Example 2 (2/9)
• MODEL SMALL
• STACK 32
• DATA
MESSAGE1 DB 0ah, 0dh,"Please write a character ",
0aH, 0dH, "$"
Example 2 (3/9)
• CODE
START PROC FAR
PUSH DS ; Start of program initialization
MOV AX,0
PUSH AX
MOV AX, @DATA
MOV DS, AX ; End of program initialization
Example 2 (4/9)
MOV AH, 1
INT 21H ; The read character is stored in AL.
MOV CX, 10
INC AL
MOV DL, AL
MOV AH, 2
DISPLAY_10: INT 21H
INC DL
LOOP DISPLAY_10
JMP XX
Example 2 (6/9)
MOV AH, 9
INT 21H ; write the message
POP AX
RET
PRINT ENDP
END START
Example 2 (8/9)
Example 2 (9/9)