• 网络学院
  • IT资讯
  • 操作系统
  • 网络技术
  • 软件应用
  • 办公软件
  • 编程技术
  • 网站架设
  • 数据库类
  • 平面设计
  • 多媒体类
  • 游戏资讯
  • 教学论文
  • 认证考试
PC技术指导:汇编源码--free
  站点:
  • 首 页
  • 最新软件
  • 文章教程
  • 国内软件
  • 国外软件
  • 绿色软件
  • 源码下载
  • 字体下载
PC技术指导:汇编源码--free
软件发布 PC技术指导:汇编源码--free
网络软件 系统工具 应用软件 联络聊天 图形图像 多媒体类 行业软件 游戏娱乐 编程开发 安全相关 教育教学 数码软件 绿软下载
热门软件: QQ 瑞星 pplive e话通 木马克星 千千静听 office2000 五笔字根 Photoshop 视频分割
返回文章教程首页 >> 文章首页 >> 认证考试 >> 计算机等级考试 >> 计算机三级考试 >> PC技术指导:汇编源码--free

PC技术指导:汇编源码--free

添加时间: 2007-4-19 6:14:45  作者: 计算机等级考试认证参考  阅读次数:55   来源: http://www.d9soft.com

                name    free
        page    60,132
        title   'FREE --- Report free space on disk'
; FREE --- a utility to report free space on
;          the default or selected disk drive.
;
; Requires PC-DOS or MS-DOS 2.0.
;
; Used in the form:
; A> FREE  [unit:]
; (item in square brackets is optional)
;
; version 1.0   July 4, 1984
; Copyright (c) 1984 by Ray Duncan
; May be freely reproduced for non-commercial use.
cr      equ     0dh             ;ASCII carriage return
lf      equ     0ah             ;ASCII line feed
blank equ 20h  ;ASCII space code
eom equ '$'  ;end of string marker
; Here we define a dummy segment containing labels
; for the default file control block and the command tail buffer,
; so that the main program can access those locations.
;
psp segment para public 'PSP' 
org 05ch
fcb label byte  ;default file control block
org 080h
command label byte  ;default command buffer
psp ends
cseg segment para public 'CODE'
assume cs:cseg,ds:psp,es:data,ss:stack
get_drive proc near  ;get drive selection, if any,
    ;otherwise obtain the identity
    ;of the current disk drive.
    ;Return drive (1=A, 2=B, etc) in AL.
    ;
mov  al,fcb         ;Pick up the drive code, parsed
    ;by DOS into the default file
    ;control block.
or al,al  ;Is it the default?
jnz get_drive1 ;no, use it
mov ah,19h  ;Yes, get the actual current
int 21h  ;drive from PC-DOS.
inc  al  ;Increment to match FCB code.
get_drive1:   ;Return drive code in AL.
ret
get_drive endp
free  proc    far             ;entry point from PC-DOS
        push    ds              ;save DS:0000 for final
        xor     ax,ax           ;return to PC-DOS
        push    ax
        mov     ax,data         ;make our data segment
        mov     es,ax           ;addressable via ES register.
        mov     ah,30h  ;check version of PC-DOS.
        int     21h
        cmp     al,2
        jae     free1  ;proceed, DOS 2.0 or greater.
        mov     dx,offset msg2  ;DOS 1.x --- print error message
mov ax,es  ;and exit. First fix up DS register
mov ds,ax  ;so error message is addressable.
jmp free4
free1:  call    get_drive  ;get drive selection into DL.
push es  ;copy ES to DS for remainder
pop ds  ;of the program...
assume ds:data  ;and tell assembler about it.
mov dl,al 
add al,'A'-1 ;form drive letter from drive code,
mov outputb,al ;and put it into the output string.
mov ah,36h  ;now call DOS to get free disk space.
int 21h
cmp ax,-1  ;was drive invalid?
je free3  ;yes,go print error message
    ;drive was ok, so now registers are...
    ;AX=number of sectors per cluster
    ;BX=available clusters,
    ;CX=number of bytes per sector,
    ;DX=total clusters per drive.
    ;calculate free space:
mul cx  ;sectors per cluster * bytes per sector
    ;(we assume this won't overflow into DX)
mul bx  ;then * available clusters
    ;DX:AX now contains free space in bytes.
    ;SI = last byte address for converted string.
mov si,offset (outputa+9)
mov cx,10  ;CX = 10, radix for conversion
call bin_to_asc ;convert free space value to ASCII,
mov dx,offset output
jmp free4  ;and print it out.
free3:  mov     dx,offset msg1  ;illegal drive, print error
free4: mov ah,9  ;print the string whose address
int 21h  ;is in DX.
ret   ;then return to DOS.
free   endp
; Convert 32 bit binary value to ASCII string.
;
; Call with  DX:AX = signed 32 bit value
;      CX    = radix
;            SI    = last byte of area to store resulting string
;              (make sure enough room is available to store
;        the string in the radix you have selected.)
;
; Destroys AX, BX, CX, DX, and SI.
;
bin_to_asc proc near  ;convert DX:AX to ASCII.
    ;force storage of at least 1 digit.
mov byte ptr [si],'0'
or dx,dx  ;test sign of 32 bit value,
pushf   ;and save sign on stack.
jns bin1  ;jump if it was positive.
not dx  ;it was negative, take 2's complement
not ax  ;of the value.
add ax,1
adc dx,0
bin1:    ;divide the 32 bit value by the radix
    ;to extract the next digit for the
    ;forming string.
mov bx,ax  ;is the value zero yet?
or bx,dx
jz bin3  ;yes, we are done converting.
call divide  ;no, divide by radix.
add bl,'0'  ;convert the remainder to an ASCII digit.
cmp bl,'9'  ;we might be converting to hex ASCII,
jle bin2  ;jump if in range 0-9,
add bl,'A'-'9'-1 ;correct it if in range A-F.
bin2: mov [si],bl  ;store this character into string.
dec si  ;back up through string,
jmp bin1  ;and do it again.
bin3:    ;restore sign flag,
popf   ;was original value negative?
jns bin4  ;no, jump
    ;yes,store sign into output string.
mov byte ptr [si],'-'
bin4: ret   ;back to caller.
bin_to_asc endp
; General purpose 32 bit by 16 bit unsigned divide.
; This must be used instead of the plain machine unsigned divide
; for cases where the quotient may overflow 16 bits (for example,
; dividing 100,000 by 2).  If called with a zero divisor, this
; routine returns the dividend unchanged and gives no warning.
;
; Call with DX:AX = 32 bit dividend
;           CX    = divisor
;
; Returns   DX:AX = quotient
;           BX    = remainder
;     CX    = divisor (unchanged)
;
divide proc near  ; Divide DX:AX by CX
jcxz div1  ; exit if divide by zero
push ax  ; 0:dividend_upper/divisor
mov ax,dx
xor dx,dx
div cx
mov bx,ax  ; BX = quotient1
pop ax  ; remainder1:dividend_lower/divisor
div cx
xchg bx,dx  ; DX:AX = quotient1:quotient2
div1: ret   ; BX = remainder2
divide endp
cseg    ends
data    segment para public 'DATA'
output  db cr,lf
outputa  db 10 dup (blank)
  db ' bytes free on drive '
outputb  db 'x:',cr,lf,eom
msg1            db      cr,lf
                db      'That disk drive does not exist.'
                db      cr,lf,eom
msg2            db      cr,lf
                db      'Requires DOS version 2 or greater.'
                db      cr,lf,eom
data    ends   
stack   segment para stack 'STACK'
        db      64 dup (?)
stack   ends
        end     free

 

上下文章:

 

上一篇文章: 等考三级数据库设计经验谈1:设计数据库之前 下一篇文章: 数据库密码安全追踪与存储

相关文章:

  • 教你如何用零框架技术加密网页
  • 用端口碰撞技术实现服务器远程管理
  • 城域网光缆线路设计与技术应用
  • ORACLE指导:我的权限控制
  • Oracle指导:Oracle学习笔记

相关软件:

  • PhoneFree V7.2.20
  • Easy Free WebCam V3.5.4
  • HDClone Free Edition 3.6.2
  • FreeWheel 1.1.5
  • FreeTime V5.0
  • DiskSpaceFree V7.4

 

快速导航

  • 网络学院
  • 精品汇聚
  • 字体下载
  • 教程下载
  • ASP源码
  • PHP源码
  • Net源码
  • JSP 源码

计算机等级考试分类导航

  • 计算机等级考试动态
  • 计算机一级考试
  • 计算机二级考试
  • 计算机三级考试
  • 计算机四级考试

本类经典文章推荐

  • 三级PC技术寻址方式的复习 (4)
  • 三级PC技术寻址方式的复习 (3)
  • 三级PC技术寻址方式的复习
  • 三级PC技术寻址方式的复习 (2)
  • 三级网络技术全真标准预测试卷(二...
  • 全国计算机等级考试三级笔试试卷数...
  • 全国计算机等级考试三级笔试试卷数...
  • 2005年计算机等级考试三级上机题库...
  • 2003年4月全国计算机等级考试三级...
  • 2005年计算机等级考试三级上机题库...

计算机三级考试阅读排行

  • SQL数据库触发器实例讲解
  • 三级网络技术全真标准预测试卷(二...
  • 全国计算机等级考试三级笔试试卷数...
  • 南开计算机等级考试上机100题(三...
  • 全国计算机等级考试三级笔试试卷数...
  • 2005年计算机等级考试三级上机题库...
  • 三级C语言程序设计上机考试习题集...
  • 数据结构第10章例题与答案
  • 三级PC技术寻址方式的复习 (4)
  • 全国计算机等级考试三级A笔试试卷

计算机等级考试阅读总排行

  • 全国计算机等级考试一级模拟试题01
  • 全国计算机等级考试一级模拟试题10
  • 全国计算机等级考试一级模拟试题08
  • 全国计算机等级考试一级考试最新模...
  • 全国计算机等级考试一级模拟试题07
  • 全国计算机等级考试一级模拟试题02
  • 全国计算机等级考试一级模拟试题06
  • 全国计算机等级考试一级模拟试题03
  • 一级(WINDOWS)试题解析-Word篇
  • 全国计算机等级考试上机考试应试技...

广告位置

字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 回到顶部

关于我们 | 版权声明 | 免责条款 | 广告联系 | 软件发布 | 下载帮助 | 下载排行 | 网站地图 | 特别鸣谢 | 友情连接

copyright; 2005-2008 D9soft.com 第九软件网 版权所有