一个简单的masm开机引导

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值