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

📄 gys_asm.asm

📁 本程序是汇编语言的一些基本功能的组合
💻 ASM
字号:
gys macro m,n
local xh,nextt
 mov ax,m
 mov cx,n
xh:
 mov dx,0
 div cx
 cmp dx,0
 je next
 mov ax,cx
 mov cx,dx
 jmp xh
next:
 mov bx,cx
 call binidec
endm
;----------------
data segment
  mess1 db 'Input M:$'
  mess2 db 'Input N:$'
data ends
program segment
 main proc far
  assume cs:program,ds:data
start:
  push ds
  sub ax,ax
  push ax
  mov ax,data
  mov ds,ax
  mov ah,9
  lea dx,mess1
  int 21h
  call decibin
  push bx
  call crlf
  mov ah,9
  lea dx,mess2
  int 21h
  call decibin
  call crlf
  pop si
  mov di,bx
  gys si,di
  ret
main endp
;------------------
decibin proc near
  mov bx,0
newchar:
  mov ah,1
  int 21h
  sub al,30h
  cmp al,0
  jb  exit1
  cmp al,9
  jnbe exit1
  cbw
  xchg ax,bx
  mov cx,10d
  mul cx
  xchg ax,bx
  add  bx,ax
  jmp  newchar
exit1:
  ret
decibin endp
;---------------
binidec proc near
     cmp   bx,0
     jne   nz
     mov   dl,'0'
     mov   ah,2
     int   21h
     ret
nz:
     push  bx
     push  cx
     push  si
     push  di
     mov   di,0
     mov   cx,10000d
     call  dec_div
     mov   cx,1000d
     call  dec_div
     mov   cx,100d
     call  dec_div
     mov   cx,10d 
     call  dec_div
     mov   cx,1
     call  dec_div
     pop   di
     pop   si
     pop   cx
     pop   bx
     ret
binidec endp
;------------------
dec_div proc near
     mov  ax,bx
     mov  dx,0
     div  cx
     mov  bx,dx
     mov  dl,al
     add  dl,30h
     cmp  dl,'0'
     je   done
     mov  di,1
done:cmp  di,1
     jne  exit2
     mov  ah,2
     int  21h
exit2:ret
dec_div  endp
;-----------------
crlf proc near
  mov dl,0dh
  mov ah,2
  int 21h
  mov dl,0ah
  int 21h
  ret
crlf endp
;---------------
program ends
  end start

⌨️ 快捷键说明

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