代碼解釋如下:
;匯編語(yǔ)言王爽 直接定址表 實(shí)驗(yàn)16 assume cs:code,ds:data,ss:stackdata segment db 128 dup(0)data endsstack segment db 128 dup(0)stack endscode segmentstart: mov ax,stack mov ss,ax mov sp,128 call cpy_newInt7ch ;復(fù)制定義的新的int7ch中斷處理程序 call set_newInt7ch ;設(shè)置中斷向量表 mov ah,2 ;初始化參數(shù),執(zhí)行哪個(gè)子程序 mov al,10111010B ;al存顏色參數(shù) int 7ch ;執(zhí)行7ch中斷程序 mov ax,4c00h int 21h;========================================================= 設(shè)置新的中斷程序new_int7ch: jmp newInt7chStartTABLE dw offset clear_screen - offset new_int7ch +7e00h ;記錄每個(gè)子程序的入口地址,參數(shù)0 dw offset set_PRe_screen - offset new_int7ch +7e00h ;參數(shù)1 dw offset set_back_screen - offset new_int7ch +7e00h ;參數(shù)2 dw offset set_up_scroll - offset new_int7ch +7e00h ;參數(shù)3newInt7chStart: push bx push es push ax mov bx,0 mov es,bx mov bl,ah add bx,bx ;存儲(chǔ)程序地址的是雙字,所以bx加倍 add bx,offset TABLE - offset new_int7ch + 7e00h call Word ptr es:[bx] pop ax pop es pop bx iret ;中斷程序用iret返回 ;========================================================= 清屏 clear_screen: push cx push bx push es push di mov cx,2000 mov bx,0b800h mov es,bx mov di,0clearScreen: mov es:[di],0700h add di,2 loop clearScreen pop di pop es pop bx pop cx ret;========================================================= 設(shè)置前景色set_pre_screen: push cx push bx push es push ax mov cx,2000 mov bx,0b800h mov es,bx mov bx,1changePreColor: and byte ptr es:[bx],11111000B or byte ptr es:[bx],al add bx,2 loop changePreColor pop ax pop es pop bx pop cx ret;========================================================= 設(shè)置背景色set_back_screen: push cx push bx push es push ax mov cx,2000 mov bx,0b800h mov es,bx mov bx,1changeBackColor: and byte ptr es:[bx],10001111B or byte ptr es:[bx],al add bx,2 loop changeBackColor pop ax pop es pop bx pop cx ret;========================================================= 向上滾動(dòng)一行set_up_scroll: push bx push es push ds push di push si push cx mov bx,0b800h mov es,bx mov ds,bx mov di,0 mov si,160 mov cx,24*160 rep movsb mov cx,80setNull: mov di,160*24 ;設(shè)置最后一行為空 mov es:[di],0700h add di,2 loop setNull pop cx pop si pop di pop ds pop es pop bx ret;========================================================= new_int7chEnd: nop ;========================================================== 復(fù)制中斷程序cpy_newInt7ch: push ax push ds push si push es push di push cx mov ax,cs mov ds,ax mov si,offset new_int7ch mov ax,0 mov es,ax mov di,7e00h mov cx,offset new_int7chEnd - offset new_int7ch cld ;每次執(zhí)行后si,di加 1, rep movsb pop cx pop di pop es pop si pop ds pop ax ret;========================================================== 設(shè)置中斷向量表set_newInt7ch: mov ax,0 mov es,ax cli mov word ptr es:[7ch*4],7e00h ;設(shè)置ip = 7e00 mov word ptr es:[7ch*4+2],0 ;設(shè)置cs = 0000 sti ret;========================================================== code endsend start
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注