




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lecture handout was provided at Quaid-i-Azam University for Microprocessor and Assembly Language Programming course by Prof. Saleem Raza. Its main points are: Interrupts, Asynchronous, Synchronous, Flags, Register, Handler, Program, Memory, Functions
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!





; hooking divide by zero interrupt [org 0x0100] jmp start
message: db 'You divided something by zero.', 0
;;;;; COPY LINES 028-050 FROM EXAMPLE 7.4 (strlen) ;;;;; ;;;;; COPY LINES 005-024 FROM EXAMPLE 7.1 (clrscr) ;;;;; ;;;;; COPY LINES 050-090 FROM EXAMPLE 7.4 (printstr) ;;;;;
; divide by zero interrupt handler myisrfor0: push ax ; push all regs push bx push cx push dx push si push di push bp push ds push es
push cs pop ds ; point ds to our data segment
call clrscr ; clear the screen mov ax, 30 push ax ; push x position mov ax, 20 push ax ; push y position mov ax, 0x71 ; white on blue attribute push ax ; push attribute mov ax, message push ax ; push offset of message call printstr ; print message
pop es pop ds pop bp
pop di pop si pop dx pop cx pop bx pop ax iret ; return from interrupt
; subroutine to generate a divide by zero interrupt genint0: mov ax, 0x8432 ; load a big number in ax mov bl, 2 ; use a very small divisor div bl ; interrupt 0 will be generated ret
start: xor ax, ax mov es, ax ; load zero in es mov word [es:04], myisrfor0 ; store offset at n mov [es:04+2], cs ; store segment at n4+ call genint0 ; generate interrupt 0
mov ax, 0x4c00 ; terminate program int 0x
; print string using bios service [org 0x0100] jmp start message: db 'Hello World'
start: mov ah, 0x13 ; service 13 - print string mov al, 1 ; subservice 01 – update cursor mov bh, 0 ; output on page 0 mov bl, 7 ; normal attrib mov dx, 0x0A03 ; row 10 column 3 mov cx, 11 ; length of string push cs pop es ; segment of string mov bp, message ; offset of string int 0x10 ; call BIOS video service
mov ax, 0x4c00 ; terminate program int 0x
; print string and keyboard wait using BIOS services [org 0x100] jmp start
msg1: db 'hello world', 0 msg2: db 'hello world again', 0 msg3: db 'hello world again and again', 0
;;;;; COPY LINES 005-024 FROM EXAMPLE 7.1 (clrscr) ;;;;; ;;;;; COPY LINES 050-090 FROM EXAMPLE 7.4 (printstr) ;;;;; ;;;;; COPY LINES 028-050 FROM EXAMPLE 7.4 (strlen) ;;;;;
start: mov ah, 0x10 ; service 10 – vga attributes mov al, 03 ; subservice 3 – toggle blinking mov bl, 01 ; enable blinking bit int 0x10 ; call BIOS video service
mov ah, 0 ; service 0 – get keystroke int 0x16 ; call BIOS keyboard service
call clrscr ; clear the screen
mov ah, 0 ; service 0 – get keystroke int 0x16 ; call BIOS keyboard service
mov ax, 0 push ax ; push x position mov ax, 0 push ax ; push y position mov ax, 1 ; blue on black push ax ; push attribute mov ax, msg push ax ; push offset of string call printstr ; print the string
mov ah, 0 ; service 0 – get keystroke int 0x16 ; call BIOS keyboard service
mov ax, 0 push ax ; push x position mov ax, 0 push ax ; push y position mov ax, 0x71 ; blue on white push ax ; push attribute mov ax, msg push ax ; push offset of string call printstr ; print the string
mov ah, 0 ; service 0 – get keystroke int 0x16 ; call BIOS keyboard service
mov ax, 0 push ax ; push x position mov ax, 0 push ax ; push y position mov ax, 0xF4 ; red on white blinking push ax ; push attribute mov ax, msg push ax ; push offset of string call printstr ; print the string
mov ah, 0 ; service 0 – get keystroke int 0x16 ; call BIOS keyboard service
mov ax, 0x4c00 ; terminate program int 0x