📄 001.asm
字号:
code segment;use 16
assume cs:code
main proc far
repeat: call menu
call tenmenu
call binarymenu
call shiliumenu
call adde
call sube
call mule
ret
main endp
;-------------------------------------------------------------------------
menu proc near
dseg segment;use 16
assume ds:dseg,es:dseg
mesg01 db 0dh,0ah,0dh,0ah,' |*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|'
db 0dh,0ah,' |* *|'
db 0dh,0ah,' |* Please select the number! *|'
db 0dh,0ah,' |* 1 DEC WORK *|'
db 0dh,0ah,' |* 2 BIN WORK *|'
db 0dh,0ah,' |* 3 HEX WORK *|'
db 0dh,0ah,' |* 4 END & EXIT *|'
db 0dh,0ah,' |* Please notice the range of opertation number! *|'
db 0dh,0ah,' |* *|'
db 0dh,0ah,' |*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|*|'
db 0dh,0ah,'Please select:$'
mesg02 db 0dh,0ah,0dh,0ah,'The result is:$'
dseg ends
mov ax,dseg
mov ds,ax
mov es,ax
mov ah,9
mov dx,offset mesg01
int 21h
mov ah,1
int 21h
case1: cmp al,'1'
jnz case2
call tenmenu
case2: cmp al,'2'
jnz case3
call binarymenu
case3: cmp al,'3'
jnz exit1
call shiliumenu
exit1: mov ah,4ch
int 21h
menu endp
;-----------------------------------------------------------------------------
tenmenu proc near
dseg segment;use 16
assume ds:dseg,es:dseg
mesg101 db 0dh,0ah,' |-|*|-|*|-|*|-|*|-|*|-|*|-|*|-|*|-|'
db 0dh,0ah,' |- DEC WORK: -|'
db 0dh,0ah,' |- 1 ADD + -|'
db 0dh,0ah,' |- 2 SUB - -|'
db 0dh,0ah,' |- 3 MUL * -|'
db 0dh,0ah,' |- 4 BACK -|'
db 0dh,0ah,' |-|*|-|*|-|*|-|*|-|*|-|*|-|*|-|*|-|'
db 0dh,0ah,'Please select:$'
mesg102 db 0dh,0ah,'Please input the added number:$'
mesg103 db 0dh,0ah,'Please input the add number:$'
mesg104 db 0dh,0ah,'Please input the subed number:$'
mesg105 db 0dh,0ah,'Please input the sub number:$'
mesg106 db 0dh,0ah,'Please input the muled number:$'
mesg107 db 0dh,0ah,'Please input the mul number:$'
dseg ends
mov ax,dseg
mov ds,ax
mov es,ax
mov ah,9
mov dx,offset mesg101
int 21h
mov ah,1
int 21h
case101: cmp al,'1'
jnz case102
call adde
case102: cmp al,'2'
jnz case103
call sube
case103: cmp al,'3'
jnz case104
call mule
case104: cmp al,'4'
jnz exit1
call menu
tenmenu endp
;-----------------------------------------------------------------------------
adde proc near
mov dx,offset mesg102
mov ah,9h
int 21h
call input
mov cx,bx
mov dx,offset mesg103
mov ah,09h
int 21h
call input
add bx,cx
call output
mov dx,0dh
mov ah,02h
int 21h
mov dx,0ah
mov ah,02h
int 21h
ret
adde endp
;-------------------------------------------------
sube proc near
mov dx,offset mesg104
mov ah,09h
int 21h
call input
mov cx,bx
mov dx,offset mesg105
mov ah,09h
int 21h
call input
xchg bx,cx
sub bx,cx
call output
mov dx,0dh
mov ah,02h
int 21h
mov dx,0ah
mov ah,02h
int 21h
ret
sube endp
;--------------------------------------------------
mule proc near
mov dx,offset mesg106
mov ah,09h
int 21h
call input
mov cx,bx
mov dx,offset mesg107
mov ah,09h
int 21h
call input
mov ax,cx
mul bx
mov bx,ax
call output
mov dx,0dh
mov ah,02h
int 21h
mov dx,0ah
mov ah,02h
int 21h
ret
mule endp
;----------------------------------------------
binarymenu proc near
dseg segment;use 16
mesg21 db 0dh,0ah,' |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|'
db 0dh,0ah,' |- BIN WORK: -|'
db 0dh,0ah,' |- 1 ADD + -|'
db 0dh,0ah,' |- 2 SUB - -|'
db 0dh,0ah,' |- 3 BACK -|'
db 0dh,0ah,' |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|'
db 0dh,0ah,'Please select:$'
dseg ends
mov ax,dseg
mov ds,ax
mov es,ax
mov ah,9
mov dx,offset mesg21
int 21h
mov ah,1
int 21h
case21: cmp al,'1'
jnz case22
call binarymenu
case22: cmp al,'2'
jnz case23
call binarymenu
case23: cmp al,'3'
jnz exit2
call menu
exit2: mov ah,4ch
int 21h
binarymenu endp
;---------------------------------------------------------
shiliumenu proc near
dseg segment;use 16
mesg161 db 0dh,0ah,' |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|'
db 0dh,0ah,' |- HEX WORK: -|'
db 0dh,0ah,' |- 1 ADD + -|'
db 0dh,0ah,' |- 2 SUB - -|'
db 0dh,0ah,' |- 3 BACK -|'
db 0dh,0ah,' |-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|'
db 0dh,0ah,'Please select:$'
dseg ends
mov ax,dseg
mov ds,ax
mov es,ax
mov ah,9
mov dx,offset mesg161
int 21h
mov ah,1
int 21h
case161: cmp al,'1'
jnz case162
call shiliumenu
case162: cmp al,'2'
jnz case163
call shiliumenu
case163: cmp al,'3'
jnz exit3
call menu
exit3: mov ah,4ch
int 21h
shiliumenu endp
;-----------------------------------------------------------------------------------------
input proc near
mov bx,0
newchar:
mov ah,1h
int 21h
sub al,30h
jl exit4
cmp al,9
jg exit4
cbw
xchg ax ,bx
mov si,10
mul si
add bx,ax
jmp newchar
exit4: ret
input endp
;-------------------------------------------
output proc near
mov dx,offset mesg02
mov ah,09h
int 21h
push ds
sub ax,ax
push ax
mov cx,10000d ;divide by 10000
call dec_div
mov cx,1000d ;divide by 1000
call dec_div
mov cx,100d ;divide by 100
call dec_div
mov cx,10d ;divide by 10
call dec_div
mov cx,1d ;divide by 1
call dec_div
ret ;return from binidec
;-------------------------------------------------------
dec_div proc near
;subroutine to divide number in bx by number in cx
;print quotient on screen
;(numberator in dx+ax,denom in cx)
mov ax,bx ;number low half
mov dx,0 ;zero out high half
div cx ;divide by cx
mov bx,dx ;remainder into bx
mov dl,al ;quotient into dl
;print the contents of dl on screen
add dl,30h ;convert to ASCII
mov ah,2h ;display function
int 21h ;call DOS
ret ;return from dec_div
dec_div endp
;--------------------------------------------------------
output endp
;--------------------------------------------------
code ends
end main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -