0% found this document useful (0 votes)
107 views

Meaning of Model Small: by Prof. Ahmed Fahmy

The document discusses different memory models in assembly language programming: 1) Small model uses 1 code segment and 1 data segment. 2) Compact model uses 1 code segment and more than 1 data segment. 3) Medium model uses more than 1 code segment and 1 data segment. 4) Large model uses more than 1 code segment and more than 1 data segment. It also provides examples of assembly language programs - one that displays the ASCII table, and another that reads characters from keyboard until 'z' is entered while displaying the next 10 characters. Both programs make use of interrupt 21H services for input/output.

Uploaded by

AhmedGamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views

Meaning of Model Small: by Prof. Ahmed Fahmy

The document discusses different memory models in assembly language programming: 1) Small model uses 1 code segment and 1 data segment. 2) Compact model uses 1 code segment and more than 1 data segment. 3) Medium model uses more than 1 code segment and 1 data segment. 4) Large model uses more than 1 code segment and more than 1 data segment. It also provides examples of assembly language programs - one that displays the ASCII table, and another that reads characters from keyboard until 'z' is entered while displaying the next 10 characters. Both programs make use of interrupt 21H services for input/output.

Uploaded by

AhmedGamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Meaning of Model Small

By
Prof. Ahmed Fahmy
.Model small/Compact/Medium/Large

Model Number of Code Number of Data


Segments Segments

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

MOV AH, 4CH ;stop the program


INT 21H
START ENDP

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)

Int 21H Will Wait ^Break seen Will echo


Service

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)

XX: MOV DX, offset MESSAGE1


CALL PRINT

MOV AH, 1
INT 21H ; The read character is stored in AL.

CMP AL, 'z'


JE FINISH
Example 2 (5/9)

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)

FINISH: MOV AH, 4CH


INT 21H
START ENDP
Example 2 (7/9)
PRINT PROC
PUSH AX

MOV AH, 9
INT 21H ; write the message

POP AX
RET
PRINT ENDP

END START
Example 2 (8/9)
Example 2 (9/9)

You might also like