资源预览内容
第1页 / 共12页
第2页 / 共12页
第3页 / 共12页
第4页 / 共12页
第5页 / 共12页
第6页 / 共12页
第7页 / 共12页
第8页 / 共12页
第9页 / 共12页
第10页 / 共12页
亲,该文档总共12页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
;-; Filename: calc.asm; Version: V 1.0; Writer: Liu Cong,Cui Yang; Organization: Tianjin University; Object: This is a demo for the header of assembly language source file.; Compilation Options: None; History: 09/20/2011 Init version;-imr0 equ 0f7himr1 equ 00hcnt0 equ 280hcnt1 equ 281hcntcmd equ 283hp85a equ 290hp85b equ 291hp85c equ 292h p85cmd equ 293hstacked segment stacksta dw 100 dup(?)top equ length stastacked endsdata segmentmes1 db please input the question.,0ah,0dh,$mes2 db can not hold the number!,0ah,0dh,$mes3 db incorrect input!,0ah,0dh,$mes4 db two-operand support only!,0ah,0dh,$mes5 db overflow!,0ah,0dh,$tab db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h db 7fh,67h,77h,7ch,39h,2eh,79h,71h,73htab1 db 88h,48h,28h,18h,84h,44h,24h,14h db 82h,42h,22h,12h,81h,41h,21h,11hint_seg dw ? int_off dw ?fmimr db 0fmimr1 db 0mdisp db 4 dup(?) operand1 dw 0000hoperand2 dw 0000hoperator db 00hresult dw 0000hnumsys dw 10htfor db 60dtemp dw ?tmp dw ?time0 dw ?time1 dw ?flag0 db 00hflag1 db 00hflag2 db 01hflag3 db 00hflag4 db 00htime dw 0000hdata endscode segment assume cs:code,ds:data,ss:stackedstart: mov ax, data mov ds, ax mov ax, stacked mov ss, ax mov sp, top mov dx, cntcmd ;initialize8253,set interrupt frequency to 1s once mov al, 37h out dx, al mov dx, cnt0 mov al, 00h out dx, al mov al, 10h out dx, al mov dx, cntcmd mov al, 77h out dx, al mov dx, cnt1 mov al, 00h out dx, al mov al, 10h out dx, al mov dx, p85cmd mov al, 88h out dx, al mov ax, 350bh int 21h mov ax, es mov int_seg, ax mov int_off, bx push ds mov ax, seg int_pr mov ds, ax mov dx, offset int_pr mov ax, 250bh int 21h pop ds in al, 21h mov fmimr, al and al, 0f7h out 21h, al in al, 0a1h mov fmimr1, al and al, 00h out 0a1h, al begin:or flag0, 08h xor ax, ax call disp xor dx, dx mov al, operator cmp al, 0ah je oadd cmp al, 0bh je osub cmp al, 0ch je omul cmp al, 0dh je odivoadd: mov ax, operand1 add ax, operand2 mov result, ax jmp over0osub: mov ax, operand1 sub ax, operand2 mov result, ax jmp over0omul: mov ax, operand1 mul operand2 mov result, ax jmp over0odiv: mov ax, operand1 div operand2 mov result, axover0: mov ah, 0 int 16h mov time, 0000h mov flag3, 01h sti lop: hlt mov ah, 0bh int 21h add al, 1 jnz lop mov flag3, 00h cli mov ax, time div tfor xchg ah, al and flag0, 0f7h mov si, 200h mov cx, 2 mov numsys, 10doutput:mov ax, result call disp mov dx, 9999hdelay2:dec dx cmp dx, 0 jnz delay2 mov flag4, 1 mov ax, time call disp mov flag4, 0 mov dx, 9999hdelay1:dec dx cmp dx, 0 jnz delay1 loop output mov operand1, 0 mov operand2, 0 mov operator, 0 mov flag0, 0 mov flag1, 0 mov flag2, 1 mov flag3, 0 mov flag4, 0 jmp begin hlt mov dx, int_seg mov ax, int_off mov ds, ax mov ax, 250bh int 21h mov al, fmimr out 21h, al mov al, fmimr1 out 0a1h, al disp proc push ax push bx push cx push dx push di push si pushf newn: mov bx, offset mdisp xor cx, cxsep: xor dx, dx div numsys mov di, cx mov bxdi, dl inc cx cmp ax,0 jnz sep lc: inc di xor dl, dl mov bxdi, dl cmp di, 3 jne lc mov al, flag4 cmp al, 0 jz xlt mov cx, 4 xlt: mov temp, cxrefh: mov cx, temp mov di, cx dec di mov ah, 01h shl ah, clop: shr ah, 1 mov al, ah mov dx, p85c out dx, al mov al, bxdi mov tmp, bx mov bx, offset tab xlat cmp di, 2 jne no cmp flag4, 0 jz no add al, 80h no: mov bx, tmp dec di mov dx, p85b out dx, al mov al, flag0 and al, 08h cmp al, 0 jnz iping mov cx, 9
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号