欢迎光临散文网 会员登陆 & 注册

浅装一个小系统(雾

2023-08-09 23:02 作者:黄二哩个黄  | 我要投稿

MBR部分的源代码,编译过后512字节一字节不差

section .text

global main

main:

call getip

getip: ;间接获取IP寄存器的值

pop dx ;保存到dx中

sub dx,3 ;减去call指令的长度

mov ax,0002h ;设置屏显模式

int 10h ;设了


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: ;延时5秒

push cx

mov cx,33144d ;一次0.5秒,循环10次,刚好5秒

call delay ;不要问我为什么不直接用331120d

pop cx ;什么?rcx是什么东西?这个世界上存在rcx吗?

loop delay_5s




mov si,dao

add si,dx

call print_cn

mov si,fix_msg

call printstr


endian: ;结束

;jmp $会不会太耗CPU了?

cli ;屏蔽外部中断

hlt ;有外部中断时再执行下一条

;(虽然我已经把外部中断屏蔽掉了)

jmp endian ;如果跑到了这里就再来一次

;函数👇

;=======================================

delay: ;延迟,单位为15.08微秒,参数传递通过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结尾

add si,dx

push ax ;保存现场

mov ah,0eh ;ah=0eh,显示字符

pstr_loop:

mov al,ds:[si] ;al=si指向的字符

cmp al,0 ;是结尾吗

je pstr_ret ;是就返回主函数

int 10h ;不是则打印字符

inc si ;si指向下一个字符

jmp pstr_loop ;并再次打印

pstr_ret:

call br

pop ax

ret



print_cn: ;打印中文字符

push ax

push bx

push cx

mov bh,1

mov ah,0eh ;中断功能号,输出字符

xor di,di ;di用于检查是否完事

xor cl,cl ;cl用于指示输出到多少位了

pcn_loop:

mov al,[si] ;将si指向的点阵数据移入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 ;检测是否完事

je pcn_ret ;是就返回主函数

jmp pcn_loop

pcn_ret:

pop cx

pop bx

pop ax

ret

br:

mov al,0ah

int 10h

mov al,0dh

int 10h

ret

;数据段

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

浅装一个小系统(雾的评论 (共 条)

分享到微博请遵守国家法律