%if 0 IRQ trace flag test 2026 by E. C. Masloch Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument. DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. %endif cpu 8086 org 256 start: mov si, 81h .skip: lodsb cmp al, 32 je .skip cmp al, 9 je .skip cmp al, '0' jb error cmp al, '9' ja error xor di, di jmp .digit .loop: lodsb .digit: sub al, '0' jb .end cmp al, 10 jae .end cbw add di, di ; times 2 mov bx, di add di, di ; times 4 add di, di ; times 8 add di, bx ; times 10 add di, ax jmp .loop .end: hook: mov ax, 3508h int 21h mov word [i08.next], bx mov word [i08.next + 2], es mov dx, i08 mov ax, 2508h int 21h mov ax, 3501h int 21h mov word [i01.next], bx mov word [i01.next + 2], es mov dx, i01 mov ax, 2501h int 21h test: mov dx, msg.header mov ah, 09h int 21h mov si, 4 .si: mov cx, di cli .outer: push cx mov cx, -1 .inner: mov ax, 16661 mul ax add ax, ax loop .inner pop cx loop .outer xchg ax, cx mov word [timer.1], ax mov word [timer.2], ax mov word [timer.3], ax mov ax, 100h | 200h ; set TF and IF push ax push cs call iret_inst addr1: equ $ mov ax, [timer.1] addr2: equ $ mov bx, [timer.2] addr3: equ $ mov cx, [timer.3] sti call disp_ax_hex mov dx, msg.sep mov ah, 09h int 21h xchg ax, bx call disp_ax_hex mov dx, msg.sep mov ah, 09h int 21h xchg ax, cx call disp_ax_hex mov bx, [match] mov dx, [bx - 2] mov ah, 09h int 21h dec si jnz .si lds dx, [cs:i08.next] mov ax, 2508h int 21h lds dx, [cs:i01.next] mov ax, 2501h int 21h mov ax, 4C00h int 21h error: mov dx, msg.error mov ah, 09h int 21h mov ax, 4C01h int 21h iret_inst: iret i08: addr4 equ $ jmp strict short .enter .next: dd 0 dw "KB" db 0 jmp strict short iret_inst times 7 db 0 .enter: addr5 equ $ nop inc word [cs:timer.1] inc word [cs:timer.2] inc word [cs:timer.3] jmp far [cs:.next] i01: jmp strict short .enter .next: dd 0 dw "KB" db 0 jmp strict short iret_inst times 7 db 0 .enter: push bp mov bp, sp push ds push si push ax mov ax, cs mov ds, ax cld mov si, table mov word [match], si cmp word [bp + 4], ax jne .none .loop: lodsw test ax, ax jz .none cmp word [bp + 2], ax lodsw jne .loop mov word [match], si jmp .done .none: stc .done: pop ax pop si pop ds jc .chain and byte [bp + 7], ~1 pop bp iret .chain: pop bp jmp far [cs:.next] disp_ax_hex: xchg al, ah call disp_al_hex xchg al, ah disp_al_hex: push cx mov cl, 4 rol al, cl call disp_al_nybble_hex rol al, cl pop cx disp_al_nybble_hex: push ax push dx and al, 15 add al, '0' cmp al, '9' jbe .got add al, 7 .got: xchg dx, ax mov ah, 02h int 21h pop dx pop ax retn align 2 timer: .1: dw 0 .2: dw 0 .3: dw 0 match: dw 0 pre: dw 0, msg.pre ; pre+4 = table table: dw addr1, msg.addr1 dw addr2, msg.addr2 dw addr3, msg.addr3 dw addr4, msg.addr4 dw addr5, msg.addr5 dw 0 msg: .error: db "Error!",13,10,36 .header: db "Traced Next Double",13,10,36 .sep: db "h, ",36 .addr1: db "h, Iret points to inst traced",13,10,36 .addr2: db "h, Iret points to next inst traced",13,10,36 .addr3: db "h, Iret points to double next inst traced",13,10,36 .addr4: db "h, Iret points to i08",13,10,36 .addr5: db "h, Iret points to i08.enter",13,10,36 .pre: db "h, Iret points to unknown",13,10,36