这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......
;************************************************************************
;* *
;* CleanDoc 1.2 (C) 1997 RonSoft. *
;* *
;* This is a simple litte assembler program that cleans out *
;* the documents folder in the start menu. *
;* This is version 1.2 *
;* There's no command line switches and stuff. *
;* It gives NO messages if everything goes allright. *
;* It check for a environment variable called CLEANDIR and CD:s *
;* down to that dir if the variable is found. If not it uses *
;* the default WINDOWSRECENT directory and deletes(UNLINKS) *
;* EVERYTHING it finds there, and CD:s back to where it started *
;* from. *
;* *
;* Comments, suggestions: *
;* Ronald Nordberg. *
;* Silverv刧en 3 *
;* 907 50 Ume? *
;* Sweden. *
;* http://home2.swipnet.se/~w-20064 *
;* christine.martinson@swipnet.se *
;* *
;* THIS PROGRAM ARE COPYRIGHTED FREEWARE. * *
;* *
;************************************************************************
;some euqates for readability
kbd equ 16h ;keyboard irq
msdos equ 21h ;MSDOS irq
reset equ 0dh ;disk reset
dfopen equ 0fh ;open disk file
dfclose equ 10h ;close disk file
searchf equ 11h ;search first
searchn equ 12h ;search next
seqread equ 14h ;sequential disk read
seqwrite equ 15h ; " " write
getdisk equ 19h ;get current disk(default)
setdta equ 1ah ;set disk transfer area address
setdir equ 3bh ;set current directory
createf equ 3ch ;create file with handle
openf equ 3dh ;open file with handle
closef equ 3eh ;close file with handle
readf equ 3fh ;read from file with handle
writef equ 40h ;write to file with handle
unlink equ 41h ;UNLINK(delete file)
getdir equ 47h ;get current directory
allocmem equ 48h ;allocate memory
freemem equ 49h ;free memory
changebs equ 4ah ;change block size
findfirst equ 4eh ;find first file
findnext equ 4fh ;find next file
exit equ 4c00h ;msdos exit
envir equ 2ch ;offset ENVIRONMENT block
[BITS 16] ;NASM STUFF !?
[ORG 100h]
mov ax,cs ;get code segment
mov ds,ax ;use it now
mov [comseg],ds
mov [extseg],es
;************************ setup and preparing ***************************
main:
mov ah,setdta ;set our DTA-area
mov dx,mydta ;buffer for it
int msdos ;call dos
mov ah,getdisk ;get default drive
int msdos ;call dos
add al,41h ;drive in al, make it ASCII
mov byte [curdir],al ;fill buffer with name (A:..etc)
mov byte [path],al ;and default path
mov word [curdir+1],":" ;copy separator to path
mov si,curdir ;pointer path buffer
add si,3 ;offset doscall part
mov ah,getdir ;get current dir
mov dl,0 ;0 = default
int msdos ;call dos
jnc diskok ;ok
mov bx,errt0 ;could not find current dir ?? If You
jmp errout ;get an error here You probably have
diskok: ;forgot to turn on Your computer.
call getenv ;check out if any ENV var
cmp dx,-1 ;was it there
je findfile ;yeahh
mov dx,path ;noo way, use default path
mov ah,setdir ;cd down
int msdos ;call dos
jnc findfile ;all ok
mov bx,errt1 ;error
jmp errout ;skip
;*************************** the delete file loop ***********************
findfile:
mov ah,findfirst ;see if the files out there
mov cx,0fh ;all files
mov dx,files ;our NULL terminated filname(*.*)
int msdos ;do the stuff
jnc delit ;all ok, must delete first file
jmp goback ;error, CD back and skip
found: ;found something
mov dx,files ;files (*.*)
mov ah,findnext ;the function
int msdos ;call dos
jc goback ;no more files, quit
delit:
mov ah,unlink ;UNLINK (delete) file
mov dx,mydta ;pointer Disk Transfer Area
add dx,30 ;offset Filename
int msdos ;delete it
jnc found ;deleted ok
mov bx,errt2 ;could not delete it ????
call write ;let us know
mov bx,mydta ;show wich file
add bx,30 ;offset filename in DTA
call write ;write out filename
mov bx,linefeed ;linefeed
jmp errout ;and skip
goback:
mov ah,setdir ;CD back to origin
mov dx,curdir ;path to dir
int msdos ;do it
jnc quit ;all ok, proceed
mov bx,errt1 ;error, get text
;***********