汇编网首页登录博客注册
chinatree的学习博客
博客首页博客互动【做检测题】论坛求助

我的博客

个人首页 |  我的文章 |  我的相册 |  我的好友 |  最新访客 |  文章收藏 |  论坛提问 |  友情链接 |  给我留言  
图片载入中
学习动态
友情链接

[2011-09-09 21:12] 课程设计2

图片载入中
在家里憋了三天,终于写出来了。
assume cs:code,ds:code,ss:code,es:code
code segment
mov ax ,offset lll;把代码写到软盘的偏移地址
push ax
cmp cx,215h;这个215H是代码总长度,如果是被操作系统执行的话CX就是215H,就会跳走到写软盘,如果是被BIOS加载的,它的值应该是随机的
jnz sl
ret
sl:mov ax,1000h;先将程序读到另一空间偏移地址为0处
mov es,ax
xor bx,bx
mov dx,bx
mov ax,201h
mov cx,1
int 13h;读软盘1号逻辑扇区到1000:0,这里的偏移地址是0,不用考虑7C00H的问题
push es
mov bx,offset m_m
push bx
retf;跳到另一个段的m_m
rrrr db 32 dup (0);定义32个栈
aaaa db "1) reset pc",0
     db "2) start system",0
     db "3) clock",0
     db "4) set clock",0
bbbb dw offset st1,offset st2,offset st3,offset st4
m_m:mov ax,cs
mov ss,ax
mov sp,offset rrrr
add sp,32
call qingping
mov ax,0b865h
mov es,ax
xor di,di
push cs
pop ds
mov si,offset aaaa
call dddd
add di,138
call dddd
add di,130
call dddd
add di,144
call dddd
s1:in al,60h
cmp al,2
jb s1
cmp al,5;输入功能号
ja s1
sub al,2
xor bx,bx
mov bl,al
add bx,bx
call word ptr bbbb[bx];跳到定址表中的地址
jmp m_m;当子程序返回时跳到m_m重新开始
st1:mov ax,0ffffh
push ax
xor ax,ax
push ax
retf;重启只要跳到FFFF:0就好
st2:xor ax,ax;从硬盘1号逻辑扇区把操作系统读出来
mov es,ax
mov bx,7c00h
mov dx,80h
mov ax,201h
mov cx,1
int 13h
push es
mov bx,7c00h
push bx
retf
st3:call qingping;时间的子程序,以前实验时写的
jmp s_s
abcd db 9,8,7,4,2,0
db "// :: "
mov bl,1
s_s:push cs
pop ds
mov ax,0b872h
mov es,ax
xor di,di
mov si,offset abcd
mov cx,6
s_p:
mov al,[si]
out 70h,al
in al,71h
mov ah,al
shr ah,1
shr ah,1
shr ah,1
shr ah,1
and al,0fh
add ax,3030h
mov es:[di],ah
mov es:[di+1],bl
mov es:[di+2],al
mov es:[di+3],bl
mov al,[si+6]
mov es:[di+4],al
mov es:[di+5],bl
inc si
add di,6
loop s_p
in al,60h
cmp al,3bh
jnz a_a
inc bl
a_a:cmp al,1
jnz s_s
ret
st4:jmp a_s
cccc db "nn/yy/rr ss:ff:mm:",0
 db 9,8,7,4,2,0
a_s:call qingping
mov ax,0b850h
mov es,ax
mov si,offset cccc
xor di,di
call dddd
mov cx,6;循环6次设置时间
mov ax,0b872h
mov es,ax
xor di,di
d_f:xor ax,ax
int 16h
cmp al,0;有时候这里得到的都是0,不知道为什么不循环等待
jz d_f
push ax
xor ax,ax
int 16h
pop bx
cmp al,39h
ja b_n
cmp al,30h
jb b_n
mov es:[di],bl
mov byte ptr es:[di+1],2
mov es:[di+2],al
mov byte ptr es:[di+3],2
add di,6
g_g:sub al,30h
sub bl,30h
shl bl,1
shl bl,1
shl bl,1
shl bl,1
xchg al,bl
add al,bl
xchg ah,al
mov al,[si]
out 70h,al
xchg ah,al
out 71h,al
b_n:inc si
loop d_f
mov si,offset cccc
call dddd
xor ax,ax
int 16h
ret
dddd:push cx;显示字符串的子程序,以0为结束标志
xor ch,ch
dd_dd:mov cl,[si]
jcxz reeet
mov es:[di],cl
mov byte ptr es:[di+1],2
add di,2
inc si
jmp dd_dd
reeet:inc si
pop cx
ret
qingping:mov cx,2000;清屏子程序
mov ax,0b800h
mov es,ax
xor di,di
c_c:mov byte ptr es:[di]," "
add di,2
loop c_c
ret
lll:mov ax,cs;把代码复制到软盘,这里的偏移地址是200,所以以下部分不会出现在软盘
mov es,ax
xor bx,bx
xor dx,dx
mov ax,301h
mov cx,1
int 13h
mov ax,offset sl
push ax
ret
code ends
end
评论次数(2)  |  浏览次数(360)  |  类型(汇编作业) |  收藏此文  | 

[  landyking   发表于  2011-09-09 22:32  ]

呵呵,你好快速啊.
我也要做这个了,捂住眼睛,不看你做的.等做好了再来看.
先留个脚印..

[  chinatree   发表于  2011-09-10 00:06  ]

没问题,欢迎之至。

 
 请输入验证码  (提示:点击验证码输入框,以获取验证码