您的位置:首页 > 其它

汇编语言王爽课程设计二

2015-07-19 10:01 656 查看
//该代码为安装程序,运行后即将主程序部分复制到软盘a
//测试环境为VMWARE 11 + MS-DOS
assume cs:codecode segment;------------------------------BEGIN COPY-----------------------------------begin: mov bx,2000hmov es,bxmov bx,0mov ax,0203hmov cx,0001hmov dx,0000hint 13hmov ax,2000hpush axmov ax,offset MYBOOTpush axretf;--------------My Booting Program--------------------MYBOOT:jmp short myboot_beginmyboot_table  dw    reset_pc, start_system,clock,    set_clockmyboot_msg dw msg1,msg2,msg3,msg4msg1  db     '1.reset pc',0msg2  db     '2.start system',0msg3  db     '3.clock',0msg4  db     '4.set clock',0myboot_begin:call show_menumov ah,0int 16hcmp al,'1'jb myboot_begincmp al,'4'ja myboot_beginsub al,31hshl al,1mov bl,almov bh,0mov bx,cs:myboot_table[bx]call clscall bxjmp short myboot_beginretshow_menu:push axpush bxpush cxpush dxpush bppush dipush escall clsmov bp,csmov es,bpmov bh,0mov bl,2mov dh,8mov dl,33mov di,0show_menu1:mov bp,cs:myboot_msg[di]call show_stradd di,2add dh,3cmp di,8jb show_menu1mov ah,1mov cx,2000hint 10hpop espop dipop bppop dxpop cxpop bxpop axretcls:    push cxpush dipush esmov di,0b800hmov es,dimov di,0mov cx,2000cls0:mov byte ptr es:[di],' 'mov byte ptr es:1[di],7add di,2loop cls0pop espop dipop cxret;--------------data & stack--------------data db 32 dup(0)stack dw 32 dup(0);----------------reboot pc---------------reset_pc:mov ax,0ffffhpush axmov ax,0push axretf;----------------boot OS-----------------start_system:mov bx,0mov es,bxmov bx,7c00hmov ah,2mov al,1mov ch,0mov cl,1mov dh,0mov dl,80hint 13h;----CURSOR--------mov ah,1mov cx,1011hint 10h;----CURSOR--------mov ax,0push axmov ax,7c00hpush axretf;----------------------show time------------------------clock:  jmp short clock_beginclock_table0 db 9,8,7,4,2,0clock_table1 db '/','/',' ',':',':',' 'clock_begin:push axpush cxpush dipush esclock0:call show_timein al,60hcall delaycmp al,1je clock_esccmp al,3bhje clock_f1jmp short clock0clock_f1:mov di,0b800hmov es,dimov di,1mov cx,2000clock_f1_0:inc byte ptr es:[di]add di,2loop clock_f1_0jmp short clock0clock_esc:pop espop dipop cxpop axretshow_time:push axpush bxpush cxpush sipush dipush esmov di,0b800hmov es,dimov ch,es:[1]and ch,11111000bor  ch,00000010bmov di,12*160+31*2mov si,0mov bx,0show_time0:mov al,clock_table0[bx]out 70h,alin al,71hmov ah,almov cl,4shr ah,cladd ah,30hand al,00001111badd al,30hmov es:[di],ahmov cs:data[si+5],ahmov es:1[di],chmov es:2[di],almov cs:data[si+6],almov es:3[di],chpush axmov al,cs:clock_table1[bx]mov es:4[di],almov cs:data[si+7],alpop axmov byte ptr es:5[di],chadd si,3add di,6inc bxcmp bx,6jb show_time0pop espop dipop sipop cxpop bxpop axretdelay:  push cxpush dxmov dx,0mov cx,180hdelay0:sub dx,1sbb cx,0cmp cx,0jne delay0pop dxpop cxret;---------------------------set clock-------------------------------set_clock:jmp short set_clock_begindata_enter: db 'Save changes and exit now? [Y/N]',0data_esc: db 'Discard changes and exit now? [Y/N]',0set_clock_begin:push axpush bxpush dxset_clock_restart:;----CURSOR--------mov ah,1mov cx,1011hint 10h;----CURSOR--------mov ah,2mov bh,0mov dh,12 ;/....................................mov dl,31int 10hcall clscall show_timemov dh,0set_clock0:call set_clock_FAcmp dh,0je  set_clock0cmp dh,3je  set_clock_restartjmp short set_clock_endset_clock_end:cmp dh,2je set_clock_retcall save_timeset_clock_ret:pop dxpop bxpop axretset_clock_FA:push axpush bxpush cxmov bl,cs:data[4]       ;bl=locmov bh,0mov ah,bhint 16hcmp al,20hjnb scf_charcmp ah,4bhje scf_larocmp ah,4dhje scf_rarocmp ah,1chje scf_entercmp ah,01hje scf_escjmp near ptr set_clock_FA_retscf_char:cmp al,'0'jb set_clock_FA_retcmp al,'9'ja set_clock_FA_retpush axpush bxpush cxpush dxpush espush axmov bx,0b800hmov es,bxmov bl,es:[1]mov ah,9mov bh,0mov cx,1int 10hpop axmov bh,0mov bl,cs:data[4]mov cs:data[bx+5],alpop espop dxpop cxpop bxpop axjmp short scf_raroscf_laro:push bxmov bl,cs:data[4]cmp bl,0pop bxje set_clock_FA_retpush axpush bxmov bl,cs:data[4]mov al,blmov ah,0mov bh,3div bhcmp ah,0pop bxpop axjne scf_laro0dec blscf_laro0:dec blmov cs:data[4],blpush axpush bxpush dxmov ah,2mov bh,0mov dh,12mov dl,31add dl,blint 10hpop dxpop bxpop axjmp short set_clock_FA_retscf_raro:push bxmov bl,cs:data[4]cmp bl,16pop bxje set_clock_FA_retpush axpush bxmov bl,cs:data[4]mov al,blmov ah,0mov bh,3div bhcmp ah,1pop bxpop axjne scf_raro0inc blscf_raro0:inc blmov cs:data[4],blpush axpush bxpush dxmov ah,2mov bh,0mov dh,12mov dl,31add dl,blint 10hpop dxpop bxpop axjmp short set_clock_FA_retscf_enter:push bxpush dxpush bppush esmov bp,csmov es,bpmov bp,data_entermov bh,0mov bl,7mov dh,15mov dl,15call show_strpop espop bppop dxpop bxmov dh,0call show_choicejmp short set_clock_FA_retscf_esc:push bxpush dxpush bppush esmov bp,csmov es,bpmov bp,data_escmov bh,0mov bl,7mov dh,15mov dl,15call show_strpop espop bppop dxpop bxmov dh,1call show_choiceset_clock_FA_ret:pop cxpop bxpop axretshow_str:push axpush cxpush dxpush bpmov cx,1show_str0:mov ah,2int 10hmov ah,9mov al,es:[bp]cmp al,0je show_str_retint 10hinc bpinc dljmp short show_str0show_str_ret:pop bppop dxpop cxpop axretshow_choice:push axpush bxpush cxmov al,1show_choice0:mov cl,almov ah,0int 16hmov ch,ahmov ah,almov al,clcmp ah,'Y'je scs01xxhcmp ah,'y'je scs01xxhcmp ah,'N'je scs01xxhcmp ah,'n'je scs01xxhcmp ch,1chje scs02xxhjmp short show_choice0scs01xxh:cmp al,1je scs0101hjmp short scs0102hscs02xxh:cmp al,1je show_choice0jmp short show_choiceretscs0101h:mov al,2call show_charmov bh,ahjmp short show_choice0scs0102h:call show_charmov bh,ahjmp short show_choice0show_choiceret:cmp bh,'Y'je show_choiceokcmp bh,'y'je show_choiceokmov dh,3jmp short show_choiceendshow_choiceok:inc dhshow_choiceend:pop cxpop bxpop axretshow_char:push axpush bxpush cxmov al,ahmov ah,9mov bx,7mov cx,1int 10hpop cxpop bxpop axretsave_time:push axpush bxpush cxpush dxpush simov si,0mov bx,5mov cx,6save_time0:push cxmov dh,cs:data[bx]mov dl,cs:data[bx+1]sub dh,30hsub dl,30hmov cl,4shl dh,cladd dl,dhmov al,cs:clock_table0[si]out 70h,almov al,dlout 71h,aladd bx,3inc sipop cxloop save_time0pop sipop dxpop cxpop bxpop axretendcopy:nopdb 512 dup(0);-----------------------------END COPY--------------------------------------;--------------installation program------------------start:  ;call MYBOOT;call set_clock;mov ax,4c00h;int 21hnopinstallation:mov bx,csmov es,bxmov bx,offset beginmov ax,0303hmov cx,0001hmov dx,0000hint 13hmov ax,4c00hint 21hcode endsend start
特别感谢:lingdushanke参考地址:http://blog.csdn.net/lingdushanke/article/details/5455587
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: