淺裝一個(gè)小系統(tǒng)(霧

MBR部分的源代碼,編譯過后512字節(jié)一字節(jié)不差

:
section .text
global main
main:
call getip
getip: ;間接獲取IP寄存器的值
pop dx ;保存到dx中
sub dx,3 ;減去call指令的長(zhǎng)度
mov ax,0002h ;設(shè)置屏顯模式
int 10h ;設(shè)了
push cs
pop ds
mov si,ver_msg ;輸出"版本信息"
call printstr
mov cx,33112d
call delay ;延遲0.5s
mov cx,33112d
call delay ;延遲0.5s
mov cx,3h
ERROR_MSG:
mov si,err
push cx
mov cx,22000d
call delay
pop cx
call printstr
loop ERROR_MSG
mov si,error_msg
call printstr
mov si,pirated_msg
call printstr
mov cx,0ah
delay_5s: ;延時(shí)5秒
push cx
mov cx,33144d ;一次0.5秒,循環(huán)10次,剛好5秒
call delay ;不要問我為什么不直接用331120d
pop cx ;什么?rcx是什么東西?這個(gè)世界上存在rcx嗎?
loop delay_5s
mov si,dao
add si,dx
call print_cn
mov si,fix_msg
call printstr
endian: ;結(jié)束
;jmp $會(huì)不會(huì)太耗CPU了?
cli ;屏蔽外部中斷
hlt ;有外部中斷時(shí)再執(zhí)行下一條
;(雖然我已經(jīng)把外部中斷屏蔽掉了)
jmp endian ;如果跑到了這里就再來(lái)一次
;函數(shù)??
;=======================================
delay: ;延遲,單位為15.08微秒,參數(shù)傳遞通過cx(33144約為0.5秒,注意不要溢出)
push ax
delay_test:
in al,61h
and al,00010000b
cmp al,ah
je delay_test
mov ah,al
loop delay_test
pop ax
ret
;===============================
printstr: ;打印字符串,si指向,以0結(jié)尾
add si,dx
push ax ;保存現(xiàn)場(chǎng)
mov ah,0eh ;ah=0eh,顯示字符
pstr_loop:
mov al,ds:[si] ;al=si指向的字符
cmp al,0 ;是結(jié)尾嗎
je pstr_ret ;是就返回主函數(shù)
int 10h ;不是則打印字符
inc si ;si指向下一個(gè)字符
jmp pstr_loop ;并再次打印
pstr_ret:
call br
pop ax
ret
print_cn: ;打印中文字符
push ax
push bx
push cx
mov bh,1
mov ah,0eh ;中斷功能號(hào),輸出字符
xor di,di ;di用于檢查是否完事
xor cl,cl ;cl用于指示輸出到多少位了
pcn_loop:
mov al,[si] ;將si指向的點(diǎn)陣數(shù)據(jù)移入al
push cx
clean_cl:
cmp cl,8h
jb pcn_line
sub cl,8h
jmp clean_cl
pcn_line:
sar al,cl
pop cx
and al,1h
cmp al,1
mov al,20h
jne display
mov al,'#'
display:
int 10h
int 10h
inc bl
inc cl
cmp cl,32d
jne pcn_dcl
xor cl,cl
call br
pcn_dcl:
cmp bl,8h
jne pcn_dbl
xor bl,bl
inc si
pcn_dbl:
inc di
cmp di,200h ;檢測(cè)是否完事
je pcn_ret ;是就返回主函數(shù)
jmp pcn_loop
pcn_ret:
pop cx
pop bx
pop ax
ret
br:
mov al,0ah
int 10h
mov al,0dh
int 10h
ret
;數(shù)據(jù)段
ver_msg db "Miorcsoft(R) Winbows 11 Ultimate 40H4 (Build 1919810.114514)" ,0
err db "ERROR",07h,0
error_msg db "BOOT ERROR:Cannot verify your system licence." ,0
pirated_msg db "You may be a victim of pirated software.", 0
fix_msg db 'To fix your computer up,please visit "http://virus.huang2.cn"' ,0
;"盜版"
dao:
db 00000010b,00000001b,00010000b,00010000b
db 00000100b,00000001b,00010010b,00111000b
db 10010000b,00111111b,10010010b,00000111b
db 01001000b,00100000b,10010010b,00000000b
db 00100100b,00010010b,10010010b,00000000b
db 00000111b,00000010b,10111110b,00111111b
db 00000100b,00000101b,10000010b,00100010b
db 11000100b,00011000b,10000010b,00100010b
db 00110100b,01100000b,10011110b,00100010b
db 00000000b,00000000b,10010010b,00010100b
db 11111100b,00011111b,10010010b,00010100b
db 00100100b,00010010b,10010010b,00001000b
db 00100100b,00010010b,10010010b,00001000b
db 00100100b,00010010b,01010010b,00010100b
db 11111111b,01111111b,01010010b,00100010b
db 00000000b,00000000b,00110001b,01000001b
db "你看啥呢?"
dw 0aa55h