在裸机上在bios中断向量表中,汇编设置增加中断服务程序(向量地址设置三种方式)

来源:互联网 发布:poe交换机端口不供电 编辑:程序博客网 时间:2024/06/05 16:26
bits 16cpu 8086%macro PutChar 2 ;必须定义写在使用前面;否则后面编译报错mov al,%1mov ah,09hmov bx,000chmov cx,%2mov dh,02hmov dl,0hint 10h%endmacroorg 07c00hmov ax,csmov ds,axmov es,ax;cld;1.Successfully the following code;IntPtr equ 1F0h;mov word [IntPtr],offset;mov word [IntPtr+2h],07c0h ;this org 07c00h,so segment is 07c0h;2.This way is also successful!;int 7ch;IntPtr equ 1F0h;mov word [IntPtr],$$+offset ;07c00h + IntPtr; Note: overflow! ;mov word [IntPtr+2h],0000;this org 07c00h,so segment is 07c0h;3.This way is successful,too!;int 21hIntPtr equ 84hmov word [IntPtr],InterruptServiceProc;07c00h + offset InterruptServiceProc; Note: overflow! mov word [IntPtr+2h],0000h;this org 07c00h,so segment is 07c0hcall DispStr;没返应,应该是不成功;mov ah,25h;mov al,78H;mov ax,07c00h;mov ds,ax;mov dx,offset;int 21h;int 78h;PutChar `\n`,2; `\n` not useful;PutChar 'A',5 ;mov byte [char],'N';PutChar byte [char],3int 21h;PutChar byte [char],5;char was 'Y' after int 7chjmp $;This interrupt proc code is correct!InterruptServiceProc:offset equ $-$$;clicall DispInterruptMsg;mov byte [char],'Y';stimov ax,IntMsgmov bp,axmov cx,intlenmov ax,01301hmov bx,000chmov dh,5hmov dl,0int 10hiretDispInterruptMsg:mov ax,IntMsgmov bp,axmov cx,intlenmov ax,01301hmov bx,000chmov dh,3hmov dl,0int 10hret ;must have instruction "ret" ,or some unknown error occurs!DispStr:mov ax,BootMessagemov bp,axmov cx,lenmov ax,01301hmov bx,000chmov dl,0int 10hretBootMessage: db "Hello,World!"len equ $-BootMessageIntMsg:db "Call Interrupt process,Successfully!"intlen equ $-IntMsg;char db '?'times 510-($-$$) db 0dw 0xaa55




以下几种错误:

中断向量表:地址设置错误


中断服务程序中没有:ret,第二行显示不正确



阅读全文
0 0