Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 29

IU2041050070_NISH MEHTA

LABORATORY 4

PROGRAMMING BASED ON BLOCK DATA TRANSFER

OBJECTIVE

To familiar with the use of data transfer instruction set of 8086

PRELAB

Read data transfer instructions and segment registers from textbook in detail.

DATA TRANSFER INSTRUCTIONS

Instructions Operands Description

MOV REG, memory Copy operand2 to operand1.

memory, REG REG, The MOV instruction cannot:

REG memory,
● Set the value of the CS and IP registers.
immediate ● Copy value of one segment register to
another segment register (should copy
to general register first).
REG, immediate
● Copy immediate value to segment
SREG, memory register (should copy to general register
first).
memory, SREG
Algorithm: operand1 = operand2
REG, SREG
Ex:
SREG, REG
Mov AX,BX ;Copy contents of BX to

AX Mov si,00h ;load Si with 00h


PUSH REG Store 16 bit value in the stack.

SREG memory Algorithm:

● SP = SP - 2
● SS:[SP] (top of the stack) = operand
IU2041050070_NISH MEHTA

POP Get 16 bit value from the stack.

REG Algorithm: Operand = SS : [SP](top of stack)

SREG memory SP = Sp + 2.

XCHG REG, memory memory, Exchange values of two operands.

REG Algorithm: operand1 < - > operand2

REG, REG

IN Input from port into AL or AX.


AL, im.byte Second operand is a port number. If required to
access port number over 255 - DX register should
be used.
AL, DX AX,

im.byte

AX, DX
OUT Output from AL or AX to port.
AL, ibyte First operand is a port number. If required to access
port number over 255 - DX register should be used.
AL, DX

AX, DX
LEA REG, memory
Load Effective Address.

Algorithm:

REG = address of memory (offset)


XLAT No Operands Translate byte from table.

Copy value of memory byte at DS:[BX + unsigned


AL] to AL register.

Algorithm: AL = DS:[BX + unsigned AL]

EXERCISES
IU2041050070_NISH MEHTA

4.1 An ALP to transfer a given block of data from source memory block to the destination
memory block without overlap.
DATA SEGMENT
S1 DW 2006H,1215H, 4115H,5116H,6241H,4125H,3218H,3215H,3215H,3651H
D1 DW 10 DUP(25H)
COUNT DB 10
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,S1
LEA DI,D1
MOV CL,COUNT
L1: MOV AX,[SI]
MOV [DI],AX
INC SI
INC SI
INC DI
INC DI
DEC CL
JNZ L1
INT 21H CODE
ENDS
END START

4.2 An ALP to exchange a block of data located from source to the destination memory
locations.

DATA SEGMENT
S1 DW 2006H,1215H, 4115H,5116H,6241H,4125H,3218H,3215H,3215H,3651H
D1 DW 1001H,1002H,1003H,1004H,1005H,1006H,1007H,1008H,1009H,1010H
COUNT DB 10
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,S1
LEA DI,D1
MOV CL,COUNT
IU2041050070_NISH MEHTA

L1: MOV AX,[SI]


MOV BX,[DI]
MOV DX,AX
MOV [DI],DX
MOV [SI],BX
INC SI
INC SI

INC DI

INC DI

DEC CL

JNZ L1

INT 21H CODE ENDS


END START
IU2041050070_NISH MEHTA

LABORATORY 5

PROGRAMMING BASED ON SORTING OF AN ARRAY OF NUMBERS

OBJECTIVE
To learn to sort the given data into ascending & descending order.

PRELAB
Read instructions related to Branch and Subroutine Call.

OVERVIEW OF BRANCH INSTRUCTIONS

Instructions Operands Description

JMP Label Unconditional Jump.Transfers control to another part of the


program. 4-byte address may be entered in this form: 1234h:
5678h, first value is a segment second value is an offset.

Algorithm: always jump

JA Label Jump If Above. Short Jump if first operand is Above second operand
(as set by CMP instruction). Unsigned.

Algorithm: if (CF = 0) and (ZF = 0) then jump

JAE Label Jump If Above Or Equal Short Jump if first operand is Above or Equal
to second operand (as set by CMP instruction). Unsigned.
Algorithm: if CF = 0 then jump

JB Label Jump If Below.Short Jump if first operand is Below second operand


(as set by CMP instruction). Unsigned.

Algorithm: if CF = 1 then jump

JBE Label Jump If Below Or Equal Short Jump if first operand is Below second
operand (as set by CMP instruction). Unsigned.

Algorithm: if CF = 1 then jump


IU2041050070_NISH MEHTA

JC Label Jump If Carry Short Jump if Carry flag is set to 1.

Algorithm: if CF = 1 then jump

JE Label Jump If Equal. Short Jump if first operand is Equal to second operand
(as set by CMP instruction). Signed/Unsigned.

Algorithm: if ZF = 1 then jump

JG Label Jump If Greater Short Jump if first operand is Greater then second
operand (as set by CMP instruction). Signed.

Algorithm: if (ZF = 0) and (SF = OF) then jump

JGE Label Jump If Greater Or Equal. Short Jump if first operand is Greater or
Equal to second operand (as set by CMP instruction). Signed.

Algorithm: if SF = OF then jump

JL Label Jump If Less than. Short Jump if first operand is Less then second
operand (as set by CMP instruction). Signed.

Algorithm: if SF <> OF then jump

JLE Label Jump If Less Or Equal. Short Jump if first operand is Less or Equal to
second operand (as set by CMP instruction). Signed.

Algorithm: if SF <> OF or ZF = 1 then jump

JNZ Label Jump If Non Zero. Short Jump if Not Zero (not equal). Set by CMP,
SUB, ADD, TEST, AND, OR, XOR instructions.

Algorithm: if ZF = 0 then jump

JZ Label Jump If Zero. Short Jump if Zero (equal). Set by CMP, SUB, ADD, TEST,
AND, OR, XOR instructions.
Algorithm: if ZF = 1 then jump

EXERCISES
5.1 Write an ALP to find the largest number from an array.
IU2041050070_NISH MEHTA

DATA SEGMENT
NUM DB 06H,05H,0FEH,32H,49H,36H
COUNT DB 5
LARGE DB 0 DATA
ENDS

CODE SEGMENT ASSUME CS:CODE


,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,NUM
MOV CL,COUNT
MOV AL,[SI]
BACK: CMP AL,[SI+1] JNC
XYZ
MOV AL,[SI+1]
XYZ: INC SI
DEC CL JNZ
BACK
MOV LARGE,AL
INT 03H
CODE ENDS END
START

5.2 Write an ALP to find the smallest number from an array.


DATA SEGMENT
NUM DB 06H,05H,0FEH,32H,49H,36H
COUNT DB 5
SMALL DB 0 DATA
ENDS

CODE SEGMENT ASSUME CS:CODE


,DS:DATA
START: MOV AX,DATA
MOV DS,AX
LEA SI,NUM
MOV CL,COUNT
MOV AL,[SI]
BACK: CMP AL,[SI+1]
JC XYZ
MOV AL,[SI+1]
XYZ: INC SI
DEC CL
IU2041050070_NISH MEHTA

JNZ BACK
MOV SMALL,AL
INT 03H
CODE ENDS
END START

5.3 Write an ALP to sort the given array of numbers in ascending order.
DATA SEGMENT
NUM DB 06H,05H,0FEH,32H,49H,36H,0FDH,0AFH,01H,00H
COUNT DB 9 DATA
ENDS

CODE SEGMENT
ASSUME CS:CODE ,DS:DATA
START: MOV AX,DATA MOV DS,AX
MOV CL,COUNT
MOV AH,CL
RPT: MOV BL,AH LEA SI,NUM
BACK: MOV AL,[SI] CMP
AL,[SI+1]
JC XYZ
XCHG AL,[SI+1]
MOV [SI],AL
XYZ: INC SI
DEC BL JNZ
BACK
DEC CL
JNZ RPT

INT 21H
CODE ENDS
END START

5.4 Write an ALP to sort the given array of numbers in descending order.
DATA SEGMENT
NUM DB 06H,05H,0FEH,32H,49H,36H,0FDH,0AFH,01H,00H
COUNT DB 9 DATA
ENDS

CODE SEGMENT
ASSUME CS:CODE ,DS:DATA
IU2041050070_NISH MEHTA

START: MOV AX,DATA MOV DS,AX


MOV CL,COUNT
MOV AH,CL
RPT: MOV BL,AH LEA SI,NUM
BACK: MOV AL,[SI] CMP
AL,[SI+1]
JNC XYZ
XCHG AL,[SI+1]
MOV [SI],AL
XYZ: INC SI
DEC BL JNZ
BACK DEC CL
JNZ RPT

INT 21H
CODE ENDS
END START
IU2041050070_NISH MEHTA

LABORATORY 6

PROGRAMMING BASED ON BIT MANIPULATION.

OBJECTIVE
To familiar with bit manipulation methods.

PRELAB
Read Instructions related to Logical and shift the operands.

BIT MANIPULATION INSTRUCTIONS

Instructions Operands Description


AND ▪ REG, memory Logical AND between all bits of two operands. Result is
▪ memory, REG REG, stored in operand1.
▪ REG
▪ memory,immediate These rules apply:
REG, immediate
▪ 1 AND 1 = 1; 1 AND 0 = 0
0 AND 1 = 0; 0 AND 0 = 0
OR ▪ REG, memory Logical OR between all bits of two operands. Result is
stored
▪ memory, REG in first operand.
▪ REG, REG
These rules apply:
▪ memory, immediate
REG,
▪ immediate 1 OR 1 = 1; 1 OR 0 = 1
0 OR 1 = 1; 0 OR 0 = 0
XOR ▪ REG, memory Logical XOR (Exclusive OR) between all bits of two
▪ memory, REG operands. Result is stored in first operand.
▪ REG, REG
These rules apply:
▪ memory, immediate

REG, immediate 1 XOR 1 = 0; 1 XOR 0 = 1
0 XOR 1 = 1; 0 XOR 0 = 0
IU2041050070_NISH MEHTA

SHL ▪ memory, immediate Shift Left.


Shift operand1 Left. The number of shifts is set by
▪ REG, immediate operand2.
▪ memory, CL
▪ Algorithm:
REG, CL

● Shift all bits left, the bit that goes off is set to

CF. Zero bit is inserted to the right-most position.

SHR ▪ memory, immediate Shift Right.


▪ REG, immediate
memory, CL REG, Shift operand1 Right. The number of shifts is set by
▪ operand2.
▪ CL

Algorithm:

● Shift all bits right, the bit that goes off is set to CF.
● Zero bit is inserted to the left-most position.
ROL ▪ memory, immediate Rotate Left.
▪ REG, immediate
▪ Rotate operand1 left. The number of rotates is set by
memory, CL
operand2.
▪ REG, CL
Algorithm:

Shift all bits left, the bit that goes off is set to
CF and the same bit is inserted to the right-
most position.
RCL ▪ memory, immediate Rotate operand1 left through Carry Flag. The number of
▪ rotates is set by operand2.
REG, immediate
▪ memory, CL Algorithm:
▪ REG, CL
Shift all bits left, the bit that goes off is set to
CF and previous value of CF is inserted to the
right- most position.

Example:
STC ; set carry (CF=1).
MOV AL, 1Ch ; AL = 00011100b

RCL AL, 1 ; AL = 00111001b, CF=0.


IU2041050070_NISH MEHTA

RET
OF=0 if first and keeps original sign.
ope
ROR ▪ memory, Rotate Right.
▪ immediate REG,
▪ immediate Rotate operand1 right. The number of rotates is set by
operand2.
▪ memory, CL
REG, CL
Algorithm:

Shift all bits right, the bit that goes off is set to
CF and the same bit is inserted to the left-most
position.
EXERCISES
6.1 Bit manipulation to check if the data is positive or negative.
DATA SEGMENT NUM DB 72H ;
1000 0010
MES1 DB 'DATA IS POSITIVE $'
MES2 DB 'DATA IS NEGATIVE $'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AL,NUM
ROL AL,1 JC
NEGA

LEA DX,MES1 ;Declare it positive.


JMP EXIT ;Exit program.
NEGA: LEA DX,MES2;Declare it negative.
EXIT: MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START

6.2 Bit manipulation to check if the data is odd or even


DATA SEGMENT
X DB 27
MSG1 DB 'NUMBER IS EVEN$'
MSG2 DB 'NUMBER IS ODD$'
IU2041050070_NISH MEHTA

DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AL,X
TEST AL,01H
JNZ EXIT
LEA DX,MSG1 MOV
AH,09H
INT 21H
JMP LAST

EXIT: LEA DX,MSG2 ;Declare it is Odd number.


MOV AH,09H
INT 21H

LAST: MOV AH,4CH INT


21H
CODE ENDS END
START

6.3 Bit manipulation to count the number of 1’s and 0’s in given data.
DATA SEGMENT X
DB 0AAH ONE DB
?
ZERO DB ? DATA
ENDS
CODE SEGMENT ASSUME CS:
CODE,DS:DATA
START: MOV
AX,DATA
MOV DS,AX
MOV AH,X
MOV BL,8 ;Initialize BL to
8. MOV CL,1 ;Initialize CL to 1.
UP: ROR AH,CL ;Perform the single bit rotate operation ;with
respect to right.
JNC DOWN ;If no carry go to DOWN label.
INC ONE ;Increment one.
JMP DOWN1 ;Jump to DOWN1.
DOWN: INC ZERO ;Increment ZERO.
IU2041050070_NISH MEHTA

DOWN1: DEC BL ;Decrement the BL. JNZ UP ;If


no zero go to UP label.
MOV AH,4CH
INT 21H
CODE ENDS
END START
IU2041050070_NISH MEHTA
IU2041050070_NISH MEHTA

LABORATORY 7

PROGRAMMING BASED ON STRING OPERATIONS

OBJECTIVE
To learn the different operations on the string.

PRELAB
Read Data Transfer and String related instructions.

EXERCISES
7.1 Write an ALP to transfer a string from one location to other.
STR1 DB 'INDUS UNIVERSITY'
LEN EQU $-STR1
FIND EQU 'Z'
MSG1 DB 'CHARACTER FOUND$'
MSG2 DB 'CHARACTER NOT FOUND$' DATA
ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
MOV AL,FIND
MOV CL,LEN
LEA SI,STR1
CLD
UP: SCASB JZ
DOWN
LOOP UP
LEA DX,MSG2 MOV
AH,09H
INT 21H
JMP EXIT
DOWN: LEA DX,MSG1
IU2041050070_NISH MEHTA

MOV AH,09H
INT 21H
EXIT: MOV AH,4CH INT
21H
CODE ENDS END
START

7.2 Write an ALP to reverse the string.


STR1 DB 'HELLO'
LEN EQU $-STR1
STR2 DB 20 DUP(0)
DATA ENDS
CODE SEGMENT ASSUME
CS:CODE,DS:DATA
START: MOV AX,DATA MOV
DS,AX
MOV ES,AX LEA
SI,STR1
LEA DI,STR2+LEN-1
MOV CX,LEN
UP: CLD LODSB
STD
STOSB
LOOP UP
MOV AH,4CH
INT 21H
CODE ENDS
END START

7.3 Write an ALP to find the Character in a string.


DATA SEGMENT
STR1 DB 'INDUS UNIVERSITY'
LEN EQU $-STR1
FIND EQU 'Z'
MSG1 DB 'CHARACTER FOUND$'
MSG2 DB 'CHARACTER NOT FOUND$' DATA
ENDS

CODE SEGMENT ASSUME


CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
IU2041050070_NISH MEHTA

MOV ES,AX
MOV AL,FIND
MOV CL,LEN
LEA SI,STR1
CLD
UP: SCASB JZ
DOWN
LOOP UP
LEA DX,MSG2 MOV
AH,09H
INT 21H
JMP EXIT

DOWN: LEA DX,MSG1


MOV AH,09H
INT 21H
EXIT: MOV AH,4CH INT
21H
CODE ENDS END
START

7.4 Write an ALP to check if the string is palindrome or not.


DATA SEGMENT
STR1 DB 'ABBCCBBA'
LEN EQU $-STR1
STR2 DB 20 DUP(0) MSG1
DB "STRING IS
PALINDROME","$" MSG2 DB "STRING
IS NOT PALINDROME","$"

DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA MOV
DS,AX
MOV ES,AX LEA
SI,STR1
LEA DI,STR2+LEN-1
MOV CX,LEN
UP: CLD
LODSB
IU2041050070_NISH MEHTA

STD
STOSB
LOOP UP LEA
SI,STR1 LEA
DI,STR2
MOV CL,LEN
BACK: MOV AL,
[SI] CMP
AL,[DI]
JNZ
NOT_PAL
INC SI
INC DI
DEC CL
JNZ BACK
PAL: LEA DX, MSG1 ; DISPLAY PALINDROME
MOV AH, 09H
INT 21H
JMP EXIT

NOT_PAL :LEA DX, MSG2; DISPLAY NOT PALINDROME


MOV AH, 09H INT
21H

EXIT: MOV AH,4CH


INT 21H CODE ENDS
END START
IU2041050070_NISH MEHTA
IU2041050070_NISH MEHTA

LABORATORY 8

PROGRAMMING BASED ON ARITHMETIC AND LOGICAL OPERATIONS

OBJECTIVE
To familiar with the use of arithmetic and logical instruction set of 8086
PRELAB
Read the instructions related to arithmetic and logical operations in detail.

OVERVIEW OF ARITHMETIC & LOGICAL INSTRUCTIONS

Instructions Operands Description


ADD ▪ REG, memory Add.
▪ memory, REG REG, Algorithm: operand1 = operand1 + operand2
▪ REG memory,
▪ immediate
▪ REG, immediate

INC ▪ REG memory Increment.


▪ Algorithm: operand = operand + 1
SUB ▪ REG, memory Subtract.
▪ memory, REG Algorithm: operand1 = operand1 - operand2
▪ REG, REG
▪ memory,
immediate
▪ REG, immediate

DEC ▪ REG Decrement.


▪ Memory Algorithm: operand = operand
CMP ▪ REG, memory Compare.
▪ memory, REG REG, Algorithm: operand1 - operand2
▪ REG memory,
▪ immediate Result is not stored anywhere, flags are set (OF, SF, ZF, AF,
REG, immediate PF, CF) according to result.

MUL ▪ REG Unsigned multiply.
IU2041050070_NISH MEHTA

▪ Memory Multiply the contents of REG/Memory with contents of


AL register. Algorithm:

When operand is a byte: AX


= AL * operand.

When operand is a word:


(DX: AX) = AX * operand.

DIV ▪ REG Unsigned


divide.

Memory
Algorithm:

when operand is a byte:


AL = AX / operand
AH = remainder (modulus)

when operand is a word: AX


= (DX AX) / operand
DX = remainder (modulus)
DAA No Operands Decimal adjust After Addition.
Corrects the result of addition of two packed BCD values.
Algorithm: if low nibble of AL > 9 or AF = 1 then:

● AL = AL + 6 ● AF = 1

if AL > 9Fh or CF = 1 then:

● AL = AL + 60h
● CF = 1

DAS No Operands Decimal adjust After Subtraction.


Corrects the result of subtraction of two packed BCD
values. Algorithm:
if low nibble of AL > 9 or AF = 1 then:

● AL = AL - 6
● AF = 1

if AL > 9Fh or CF = 1 then:

● AL = AL - 60h
● CF = 1
IU2041050070_NISH MEHTA

AAA No Operands ASCII Adjust after Addition.


Corrects result in AH and AL after addition when working
with BCD values.
Algorithm:
if low nibble of AL > 9 or AF = 1 then:

● AL = AL + 6
● AH = AH + 1

● AF = 1

● CF = 1

else

● AF = 0

● CF = 0

in both cases: clear the


high nibble of AL.
Example:
MOV AX, 15 ; AH = 00, AL = 0Fh
AAA ; AH = 01, AL = 05
AAS No Operands ASCII Adjust after Subtraction.
Corrects result in AH and AL after subtraction when
working with BCD values.

Algorithm: low ble of AL > 9 or AF = 1


then:

● AL = AL - 6
● AH = AH - 1

● AF = 1

● CF = 1

else

● AF = 0
● CF = 0

in both cases: clear the high


nibble of AL.
Example:
IU2041050070_NISH MEHTA

MOV AX, 02FFh ; AH = 02, AL =


0FFh AAS ; AH = 01, AL = 09

AAM No Operands ASCII Adjust after Multiplication.


Corrects the result of multiplication of two BCD values.
Algorithm:

● AH = AL / 10
● AL = remainder

Example: MOV AL, 15 ; AL = 0Fh


AAM ; AH = 01, AL = 05

EXERCISES
8.1 An ALP for 32 bit Addition and Subtraction
32 bit addition org
100h MOV
AX,1111H
MOV BX,1111H
MOV CX,9999H
MOV DX,9999H
ADC AX,CX ADC
BX,DX Ret

32 bit subtraction org 100h

MOV AX,1010H
MOV BX,1010H
MOV CX,0909H
IU2041050070_NISH MEHTA

MOV DX,0909H
SUB AX,CX SUB
BX,DX
Ret

8.2 An ALP for ASCII Adjust after Addition/Subtraction.

CODE SEGMENT
ASSUME CS:CODE
START: MOV AX,0901H
SUB AL,09H
AAS ; GIVE AX = 0802H
MOV AH,0
MOV AL,6
ADD AL,5
AAA; AH = 1 and AL = 1 , represents BCD 11
MOV AH,4CH
INT 21H
CODE ENDS END
START

8.3 An ALP for ASCII Adjust after Multiplication.


CODE SEGMENT
ASSUME CS:CODE
START: MOV AL,5
MOV BL,7
MUL BL
AAM
MOV AH,4CH
INT 21H CODE
ENDS
END START
IU2041050070_NISH MEHTA

LABORATORY 9

PROGRAMMING BASED ON DISPLAYING STRING ON CONSOLE USING DOS


INTERRUPTS

OBJECTIVE
To learn DOS Interrupt commands.

PRELAB
Read Interrupts.

OVERVIEW OF DOS INTERRUPTS


Interrupt INT 21h:

INT 21h calls DOS functions.

Function 01h - Read character from standard input, result is stored in AL. If there is no character in
the keyboard buffer, the function waits until any key is pressed.

Invoked by: AH = 01h

Returns: AL = character entered.

Example:

Mov AH, 01h

INT 21h

Function 02h - Write a character to standard output.

Invoked by: DL = character to write.

AH =02h After

execution AL = DL.

Example:

Mov AH, 02h

Mov DL, ’a’ ; Character to be displayed on screen must be stored in DL


reg. INT 21h
IU2041050070_NISH MEHTA

Function 06h – Direct console for input/output. If DL = 0FFH on entry, then this function reads the
console. If DL = ASCII character, then this function displays the ASCII character on the console
video screen.

Invoked by: Parameters for O/P: DL = 0…255 Parameters


for I/P: DL = 255.

Returns: for O/P: AL = DL.

For I/P: ZF set if no character available & AL = 0

ZF clear if character available & AL = character.

Example:

Mov AH,

06h Mov DL,

0ffh INT 21h

Function 09h - Write a string to standard output at DS: DX.

String must be terminated by '$'. The string can be of any length and may contain control characters
such as carriage return (0DH) and line feed (0AH).

Invoked by: DS = string to write.

AH = 09h

Example:

Mov AH, 09h

Mov DX,offset str ;Address of the string to be

displayed INT21h

Function 2Ch - Get system time.

Invoked by: AH =2Ch


Return: CH = hour. CL = minute. DH = second. DL = 1/100 seconds.

Example:

Mov AH, 2ch


INT 21h
IU2041050070_NISH MEHTA

Function 4Ch – Terminate a process.

Invoked by: AH = 4ch

Return: returns control to the operating system.

Example:

Mov AH, 4Ch

INT 21h Interrupt


INT 10h:

INT 10h calls the BIOS functions. This interrupt often called the video services interrupt as it directly
controls the video display in a system.

Function 02h - Set cursor position.

Invoked by: DH = row; DL = column; BH = page number (0...7); AH=02h.

Example:

MOV AH, 02h

MOV BH, 00

MOV DH, 06

MOV DL, 10

INT 10h Function 03h – Get

cursor position.

Invoked by: BH = page number. (In general 0)

AH = 03h

Return: DH = row number; DL = column number; CH = cursor start line;

CL = cursor bottom line.

Example:

Mov BH, 0
IU2041050070_NISH MEHTA

Mov AH, 03h

INT 10h

Function 06h – Scroll up window

Invoked by: AL = number of lines by which to scroll. (00h = clear the entire screen.)

BH = attribute used to write blank lines at bottom of window.


CH, CL = row, column of window's upper left corner.
DH, DL = row, column of window's lower right corner.

EXERCISES

9.1 Display string on console using DOS interrupts


CODE SEGMENT ASSUME
CS:CODE,DS:DATA
START: MOV AX,DATA MOV
DS,AX
MOV AH,09H
LEA DX,str1
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START

You might also like