现在的位置: 首页 > 综合 > 正文

一个简单的masm开机引导

2013年02月15日 ⁄ 综合 ⁄ 共 999字 ⁄ 字号 评论关闭

CODES SEGMENT
ASSUME CS:CODES,DS:CODES,ES:CODES,SS:CODES
org 100h ;显示格式 2009-02-22 12:52:03
start:
jmp TT

disp:
push cx
mov ah,al
mov cx,4
shr al,cl
and al,0fh
or al,30h
stosb
mov al,0ch
stosb
mov al,ah
and al,0fh
or al,30h
stosb
mov al,0ch
stosb
pop cx
ret

Msg: db "Hello world!"
TT:push cs
pop ds
mov ax,3
int 10h
mov ax,0b800h
mov es,ax
cld
mov di,(80*8+26)*2
mov si,offset Msg
mov cx,13;显示Hello world!
shl cx,1
T0:movsb
mov al,0ch
stosb
loop T0
Again:
mov di,(80*10+30)*2
T1:mov ah,04 ;CX=2009 DX=0222
int 1ah;读取日期,CF=0 时钟在走,否则,时钟停止
;出口参数:CX=年,DX=月/日
mov al,ch;显示年
call disp
mov al,cl
call disp
mov al,'-'
stosb
mov al,0ch
stosb
mov al,dh;显示月
call disp
mov al,'-'
stosb
mov al,0ch
stosb
mov al,dl;显示日
call disp
mov al,20h
stosb
mov al,0ch
stosb

mov ah,02 ;CX=1252 DX=0300
int 1ah;读取当前时间,CF=0 时钟在走,否则,时钟停止
;出口参数:CX=时/分;DH=秒,DL=0 标准时间,否则,夏令时
mov al,ch;显示时
call disp
mov al,':'
stosb
mov al,0ch
stosb
mov al,cl;显示分
call disp
mov al,':'
stosb
mov al,0ch
stosb
mov al,dh;显示秒
call disp

mov ah,01
int 16h;读键盘
jz Again  ;无字符输入,继续显示时间
jmp $

Dat: db 339 dup(0) ; 填充剩下的空间
dw 0AA55H ; 结束标志
CODES ENDS
END START

以上代码编译为COM格式后,如BTIME.COM,再
用DEBUG.EXE导入内存,写到软盘即可。步骤:
debug btime.com
-w 0 0 1
-q

抱歉!评论已关闭.