- UID
 - 2198
 
 注册时间2005-6-29
阅读权限255
最后登录1970-1-1
副坛主 
    
 
 
 
该用户从未签到  
 | 
 
; 写的比较仓促 仅供参考 
- assume cs:code
 
  
- data segment
 
 - dd 123456789
 
 - nstr db 10h dup (0)
 
 - data ends
 
  
- stack segment
 
 - dw 100h dup (0)
 
 - stack ends
 
  
- code segment
 
  
- _end:  mov ax,4c00h
 
 -        int 21h
 
  
- ; 除法溢出函数
 
 - ; 调用该函数前请自行保存 si
 
 - ; 除数 ax,dx / 被除数 cx  
 
 - ; 余数保存到:si  
 
 - div_over:
 
 -         xor si,si
 
 -         test dx,dx
 
 -         jz _div
 
 -         push ax
 
 -         mov ax,dx
 
 -         xor dx,dx
 
 -         div cx
 
 -         mov si,ax
 
 -         pop ax
 
 - _div:
 
 -         div cx
 
 -         push dx
 
 -         mov dx,si
 
 -         pop si
 
 -         retn
 
  
- ; 整形转字符串
 
 - ; 参数:字符保存位置,低16位,高16位
 
 - ntostr:
 
 -         push bp
 
 -         mov bp,sp
 
 -         push cx
 
 -         push dx
 
 -         push bx
 
 -         push si
 
  
-         xor cx,cx
 
 -         mov ax,[bp+8]
 
 -         mov dx,[bp+6]
 
  
- n_next:
 
 -         push cx
 
 -         mov cx,0ah
 
 -         call div_over
 
  
-         pop cx
 
 -         inc cx
 
 -         add si,30h
 
 -         push si
 
  
-         test dx,dx
 
 -         jnz n_next
 
 -         test ax,ax
 
 -         jnz n_next
 
  
-         mov bx,[bp+4]
 
 -         xor si,si
 
 - n_addstr:
 
 -         pop ax
 
 -         mov [bx+si],al
 
 -         inc si
 
 -         loop n_addstr
 
 -         mov byte ptr [bx+si],0  ; thanks ngm20
 
  
-         pop si
 
 -         pop bx
 
 -         pop dx
 
 -         pop cx
 
 -         mov sp,bp
 
 -         pop bp
 
 -         retn
 
  
- ; 显示字符串
 
 - ; 参数:字符串地址,字符位置
 
 - show_str:
 
 -         push bp
 
 -         mov bp,sp
 
 -         push si
 
 -         push di
 
 -         push bx
 
  
-         mov al,[bp+7]
 
 -         mov cl,80*2
 
 -         mul cl
 
 -         mov si,ax
 
 -         xor ax,ax
 
 -         mov al,[bp+6]
 
 -         add ax,ax
 
 -         add si,ax
 
  
-         mov ax,0b800h
 
 -         mov es,ax
 
 -         mov bx,[bp+4]
 
 -         xor di,di
 
 -         mov ah,2
 
 - s_add:
 
 -         mov al,[bx+di]
 
 -         test al,al
 
 -         jz s_over
 
 -         mov es:[si],ax
 
 -         inc di
 
 -         add si,2
 
 -         jmp s_add
 
 - s_over:
 
 -         pop bx
 
 -         pop di
 
 -         pop si
 
 -         mov sp,bp
 
 -         pop bp
 
 -         retn
 
  
 
- start:  jmp _start
 
 -         db 'Code By: Nisy/PYG ',0
 
 - _start:
 
 -         mov ax,data
 
 -         mov ds,ax
 
 -         mov ax,stack
 
 -         mov ss,ax
 
 -         mov sp,200h
 
 -         
 
 - ; 将整形转化为字符串 保存到nstr中
 
 -         xor bx,bx
 
 -         mov ax,[bx]
 
 -         push ax
 
 -         lea bx,[bx+2]
 
 -         mov ax,[bx]
 
 -         push ax
 
 -         lea ax,nstr
 
 -         push ax
 
  
-         call ntostr
 
 -         add sp,6
 
  
- ; 显示nstr的数值
 
 -         mov ax,0a0ah
 
 -         push ax
 
 -         lea ax,nstr
 
 -         push ax
 
 -         call show_str 
 
 -         add sp,4
 
 - ; 程序结束
 
 -         jmp _end
 
  
- code ends
 
  
- end start
 
  
  复制代码 
 
 |   
 
评分
- 
查看全部评分
 
 
 
 
 
 |