CSB23044 Lab09
CSB23044 Lab09
.MODEL SMALL
.STACK 100H
.DATA
No_Records EQU 5
No_Fields EQU 7
Subjects db 3
DW 05, 21, 49, 59, 69, 00, 00 ;field 1: roll, field 2: age, field 3-5: marks,
Subject_Av DW ?,?,?,?,?,?,?
ten db 10
hun db 100
.CODE
main PROC
.STARTUP
sub bx, bx
Repeat1:
sub ax, ax
mov Marks_Records[bx+10], ax
div Subjects
sub ah, ah
mov Marks_Records[bx+12], ax
loop Repeat1
sub bx, bx
sub dx, dx
Repeat2:
int 21h
pusha ; save all register values in stack so that they can be restored after printing
; integer is done
div ten
mov dl, al
int 21h
int 21h
int 21h
pusha
div hun
mov bx, ax
mov dl, al
add dl, 30h
int 21h
mov ah, 0
mov al, bh
div ten
mov bx, ax
mov dl, al
int 21h
mov dl, bh
int 21h
int 21h
pusha
div ten
mov bx, ax
mov dl, al
add dl, 30h
int 21h
mov dl, bh
int 21h
int 21h
loop Repeat2
; .EXIT
mov ah ,4ch
mov al ,0
int 21h
main ENDP
END main
Add a procedure to the program to read in the Marks_Records from the keyboard and repeat
the exercises.
.MODEL SMALL
.STACK 100H
.DATA
No_Records EQU 5
No_Fields EQU 7
Subjects DB 3
Input_Msg1 DB 'Enter student data (Roll Age Mark1 Mark2 Mark3): $'
ten DB 10
hun DB 100
.CODE
main PROC
.STARTUP
CALL InputRecords
mov cx, No_Records
sub bx, bx
Repeat1:
sub ax, ax
mov Marks_Records[bx+10], ax
div Subjects
sub ah,ah
mov Marks_Records[bx+12], ax
loop Repeat1
sub bx, bx
sub dx, dx
Repeat2:
int 21h
int 21h
push ax
push bx
push cx
push dx
push sp
push si
div ten
mov bx, ax
mov dl, al
int 21h
mov dl, bh
int 21h
pop si
pop sp
pop dx
pop cx
pop bx
pop ax
int 21h
push ax
push bx
push cx
push dx
push sp
push si
div hun
mov bx, ax
mov dl, al
int 21h
mov ah, 0
mov al, bh
div ten
mov bx, ax
mov dl, al
int 21h
mov dl, bh
add dl, 30h
int 21h
pop si
pop sp
pop dx
pop cx
pop bx
pop ax
int 21h
push ax
push bx
push cx
push dx
push sp
push si
div ten
mov bx, ax
mov dl, al
int 21h
mov dl, bh
int 21h
pop si
pop sp
pop dx
pop cx
pop bx
pop ax
int 21h
dec cx
cmp cx,0
je Exit_loop
jmp Repeat2
Exit_loop:
int 21h
main ENDP
InputRecords PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
MOV BX, 0
InputLoop:
INT 21H
INT 21H
CALL InputNumber
MOV Marks_Records[BX], AX
LEA DX, Input_Space
INT 21H
CALL InputNumber
MOV Marks_Records[BX+2], AX
INT 21H
CALL InputNumber
MOV Marks_Records[BX+4], AX
INT 21H
CALL InputNumber
MOV Marks_Records[BX+6], AX
INT 21H
CALL InputNumber
MOV Marks_Records[BX+8], AX
MOV WORD PTR Marks_Records[BX+10], 0
LOOP InputLoop
POP SI
POP DX
POP CX
POP BX
POP AX
RET
InputRecords ENDP
InputNumber PROC
PUSH BX
PUSH DX
INT 21H
MOV BL, 10
MUL BL
MOV BH, AL
ADD BH, AL
MOV AX, 0
MOV AL, BH
POP DX
POP BX
RET
InputNumber ENDP
END main
Observations:
Variables:
Learning Outcome:
Key characteristics:
Examples:
assembly
Applications: Efficient for accessing array elements, data structures, and stack parameters where
complex address calculations are needed.
2. Use of various registers in the division instruction operation in µP 8086: The 8086 division
operations (DIV/IDIV) utilize specific registers depending on operand size:
● Dividend: DX
register pair (32-bit value)
● Divisor: 16-bit register or memory location
● Quotient: AX register
● Remainder: DX register
Examples:
assembly
; 8-bit division
MOV AX, 250 ; Dividend
; 16-bit division