⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 b.asm

📁 汇编语言写的程序
💻 ASM
字号:
data segment
	msg1 db 'Enter:','$'
	err  db 'Enter Error!','$'
	buf  db 20
	     db ?
	     db 20 dup(?)
	fnu1 db 0     
	num1 dw 0
	fnu2 db 0
	num2 dw 0
	oper db 0
	flag1 db 0
	flag2 db 0
	num db 0
	crlf db 10,13,'$'
	wen db 'wen','$'
	
data ends
code segment
	main proc far
	assume cs:code,ds:data
start:
     push ds
     sub ax,ax
     push ax
     
     mov ax,data
     mov ds,ax
     
     lea dx,msg1
     mov ah,9
     int 21h
     
     lea dx,buf
     mov ah,10
     int 21h
     
     lea dx,crlf
     mov ah,9
     int 21h
     mov cl,buf+1
     mov num,cl
     lea si,buf+2
     
      
    
   
     
     
     
     
     
     mov bx,0
     
     
again:
     mov al,[si]
     
   
     
     test flag1,01h
     jnz follow
     
    
      
     cmp al,2dh
     jnz next
     
     
     mov fnu1,1
     inc si
     dec num
     
 
     
     jnz again
     jmp error
     
     
next:    
     sub al,30h   
     jl error   
     cmp al,9d   
     jg error 
     
    
	
     mov flag1,1
     cbw   
     xchg ax,bx   
     mov cx,10d   
     mul cx   
     xchg ax,bx   
     add bx,ax
     inc si
     dec num
    
     
     jnz again
 follow:
     
   test flag2,01h
   jnz follow2
   test fnu1,01h
    jz follow2 
      
   
   
  sub al,30h   
  jl error
  
 
 
     
  cmp al,9d   
  jg error 
   

  
  mov flag2,1
  cbw   
   xchg ax,bx   
   mov cx,10d   
   mul cx   
    xchg ax,bx   
    add bx,ax
   inc si
   dec num
   
    
     jnz again
follow2:
      
     
     test oper,01h
     jnz follow3
     
    
     
     cmp al,2bh
     jnz next1
     mov oper,1
     mov num1,bx
     mov bx,0
     inc si
     dec num
     jnz again
 next1:
     cmp al,2dh
     jnz next2
     mov oper,2
     mov num1,bx
     mov bx,0
     inc si
     dec num
     jnz again
 next2:
     cmp al,2ah
     jnz next3
     mov oper,3
     mov num1,bx
     mov bx,0
     inc si
     dec num
      
     
     
     jnz again
 next3:
     cmp al,2fh
     jnz follow3
     mov oper,4
     mov num1,bx
     mov bx,0
     inc si
     dec num
     jnz again
follow3:
     
     sub al,30h   
    jl error   
    cmp al,9d   
    jg error 
    cbw   
    xchg ax,bx   
    mov cx,10d   
    mul cx   
    xchg ax,bx   
    add bx,ax
    inc si
    dec num
    
  
    
    
    jnz again
    jmp exit
error:
     mov ah,9
     lea dx,err
     int 21h
    ; jmp end1    
exit:
    mov num2,bx
   ; mov bx,num1
   ; call bin2dec
    
   ; lea dx,crlf
   ; mov ah,09
   ; int 21h
    
    ;mov bx,num2
    ;call bin2dec
    
cmp oper,1
jnz subtract
mov ax,num1
add ax,num2
mov bx,ax
call bin2dec
jmp end1

subtract: 
cmp oper,2
jnz multiply
mov ax,num1
sub ax,num2
mov bx,ax
call bin2dec
jmp end1

multiply:  
 cmp oper,3
 jnz chu
 mov ax,num1
 
 mov bx,num2
 mul bx
; mov bx,dx
;call bin2dec
 mov bx,ax
 call bin2dec
 jmp end1
chu: 
mov ax,num1
cwd
mov bx,num2
div bx
mov bx,ax
call bin2dec

   
    
    
    
    
    
    
    
    
    
    
    
     end1:
   ret
   main endp
   
   
   
    bin2dec proc near   
  mov cx,10000d   
  call decdiv   
  mov cx,1000d   
  call decdiv   
  mov cx,100d   
  call decdiv   
  mov cx,10d   
  call decdiv   
  mov cx,1d   
  call decdiv   
  ret   
  bin2dec endp   
    
  decdiv proc near   
  mov ax,bx   
  mov dx,0   
  div cx   
  mov bx,dx   
  mov dl,al   
  add dl,30h   
  mov ah,2   
  int 21h   
  ret   
  decdiv endp 
   
   
   
   
   
  code ends
 end start  
        
    
     
     
               
          
     
     		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -