The aim of the program was to Write a short assembly language program which creates a divide by zero trap and modify the isr so that you change the error message that the isr issues.


stepintr.asm << the sample
isr << built in system trap message he said.


stepintr.asm contains

TITLE Single-step program STEPINTR.ASM
COMMENT |
Objective: To demonstrate how ISRs can be defined and installed.
Input: None
| Output: Displays AX and BX values for the single-step code


.MODEL SMALL
.STACK 100H
.DATA
old_offset DW ? ; for old ISR offset
old_seg DW ? ; and segment values
start_msg DB 'Starts single stepping process.',0
AXequ DB 'AX = ',0
BXequ DB ' BX = ',0
.CODE
INCLUDE io.mac
main PROC
.STARTUP
PutStr start_msg
nwln
; get current interrupt vector for int 1H

mov AX, 3501H ; AH := 35H and AL := 01H
int 21H ; returns the offset in BX
mov old_offset, BX ; and the segment in ES
mov old_seg, ES

;set up interrupt vector to our ISR

push DS ; DS is used by function 25H
mov AX, CS ; copy current segment to DS
mov DS, AX
mov DX, OFFSET sstep_ISR ; ISR offset in DX
mov AX,2501H ; AH := 25H and AL := 1H
int 21H
pop DS ; restore DS
; set trap flag to start single stepping
pushf
pop AX ; copy flags into AX
or AX,100H ; set trap flag bit (TF = 1)
push AX ; copy modified flag bits
popf

; from now on a type 1 interrupt is generated after executing
; each instruction. Some test instructions follow.

mov AX, 100
mov BX, 20
add AX, BX

; now we are ready to stop the single stepping
; clear trap flag to end single stepping

pushf
pop AX ; copy flags into AX
and AX,0FEFFH ; clear trap flag bit (TF = 0)
push AX ; copy modified flag bits
popf ; back to flags register

; restore the original ISR

mov DX, old_offset
push DS
mov AX, old_seg
mov DS, AX
mov AX, 2501H
int 21H
pop DS
.EXIT
main ENDP
;----------------------------------------------------------­
;Single-step interrupt service routine replaces int 01H.
;----------------------------------------------------------­

sstep_ISR PROC
sti ; enable interrupt
PutStr AXequ ; display AX contents
PutInt AX
PutStr BXequ ; display BX contents
PutInt BX
nwln
iret
sstep_ISR ENDP
END main

the isr.asm contains

.MODEL SMALL
.STACK 100H
.DATA
n1 DB 0
.CODE
main PROC
.STARTUP
mov AL,10
div n1 ; look up div instruction
.EXIT
main ENDP
END main

Can anyone help me. Its a little urgent.

Which register is used for that trap ?

Which register is used for that trap ?

I am not sure. Can you help me. I need this soon. If possible can you send me this code?

You have two problems in your interrupt 1 handler:
registers are not pushed and restored,
your divisor is zero.
Also when divisor is 8-bits, AX / divisor
hence:

mov ax, 10h
div byte [nl]

Here's my code if it will help.
Hope I don't go to heck, any more delusional thoughts???

bits 16
org 100h

bum:
mov dx, isr1_grave
mov ax, 0x2501
int 21h
pushf
pop ax
or ax, 0x100
push ax
popf

mov ax, bx
xor bx, bx

pushf
pop ax
and ax, 0xfeff
push ax
popf

int 0x20

nl db 0
isr1_grave:
push ax
;mov al, 0x41 ; for confirmation with permission
;int 0x29
mov ax, 10h
div byte [nl]
pop ax
iret
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.