• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >汇编语言 > 汇编源码系列之clean

汇编源码系列之clean

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2017-06-28

匿名通过本文主要向大家介绍了clean系列香水,bio clean,clean clear官网,clean,clean是什么意思等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div>

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......

  name  clean
  page  55,132
  title  'CLEAN --- Filter text file'
;
; CLEAN --- a utility to filter text files.
; This program removes all control codes except
; for line feeds, carriage returns, and form
; feeds, strips off the high bit of all characters,
; and expands tabs. Can be used to make a Wordstar
; file acceptable for other screen or line editors,
; and vice versa.
;
; version 1.1  10 Dec 83 Blocking/deblocking
; version 1.0  25 Nov 83
;
; Copyright (c) 1983 by Ray Duncan
cr  equ  0dh    ;ASCII carriage return
lf  equ  0ah    ;ASCII line feed
ff  equ  0ch    ;ASCII form feed
eof  equ  01ah    ;End of file marker
tab  equ  09h    ;ASCII tab character
command  equ  80h    ;buffer for command tail
blksize  equ  1024    ;blocking/deblocking size
cseg  segment  para public 'CODE'
  assume  cs:cseg,ds:data,es:data,ss:stack
clean  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
  call  infile    ;get path and file spec.
        ;for input file
  mov  ax,es    ;set DS=ES for remainder
  mov  ds,ax    ;of program
  jnc  clean1    ;jump, got acceptable name
  mov  dx,offset msg4  ;missing or illegal filespec,
  jmp  clean9    ;print error message and exit.
clean1:  call  outfile    ;set up output file name
  call  open_input  ;now try to open input file
  jnc  clean2    ;jump,opened input ok
  mov  dx,offset msg1  ;open of input file failed,
  jmp  clean9    ;print error msg and exit.
clean2:
  call  open_output  ;try to open output file.
  jnc  clean25    ;jump,opened ok
  mov  dx,offset msg2  ;open of output file failed,
  jmp  clean9    ;print error message and exit.
clean25:      ;set up buffers
  call  init_buffs
  call  sign_on    ;print ident and file names
        ;files successfully opened,    
clean3:        ;now filter the file. 
  call  get_char  ;read 1 character from input.
  and  al,07fh    ;strip off the high bit
  cmp  al,20h    ;is it a control code?
  jae  clean4    ;no,write it to new file  
        ;yes it is control code,
  cmp  al,eof    ;is it end of file marker?
  je  clean6    ;yes,jump to close files.
  cmp  al,tab    ;is it a tab command?
  jz  clean5    ;yes,jump to special processing.
  cmp  al,cr    ;if control code other than
  je  clean35    ;tab or end-of-file mark, throw
  cmp  al,ff    ;it away unless it is a
  je  clean35    ;form feed, carriage return,
  cmp  al,lf    ;or line feed.
  jne  clean3    
clean35:      ;If it is one of those three,
  mov  column,0  ;incidentally initialize
  jmp  clean45    ;column count for tab processor.
clean4:        ;count alphanumeric chars. sent.
  inc  column
clean45:      ;write this character to
  call  put_char  ;output file,
  jnc  clean3    ;if CY not set, write was
        ;ok so go get next char.
clean47:
  call  close_input  ;if CY set, disk is full
  call  close_output  ;so close files and exit
  mov  dx,offset msg5 ;with error message.
  jmp  clean9
clean5:        ;process tab character
  mov  ax,column  ;let DX:AX=column count
  cwd
  mov  cx,8    ;divide it by eight...
  idiv  cx
  sub  cx,dx    ;remainder is in DX.
  add  column,cx  ;update column pointer.
clean55:      ;8 minus the remainder
  push  cx    ;gives us the number of
  mov  al,20h    ;spaces to send out to
  call  put_char  ;move to the next tab position
  pop  cx    ;restore space count
  jc  clean47    ;jump if disk is full
  loop  clean55
  jmp  short clean3  ;get next character
clean6:        ;end of file detected,
  call  put_char  ;write end-of-file marker,
  jc  clean47    ;jump if disk was full
  call  flush_buffs  ;write remaining data to disk
  jc  clean47    ;if CY set,disk was full
        ;otherwise file was written ok  
  call  close_input  ;close input and output
  call  close_output  ;files.
  mov  dx,offset msg3  ;addr of success message,
clean9:        ;print message and return
  mov  ah,9    ;control to PC-DOS
  int  21h
  ret
clean  endp
infile  proc  near    ;process name of input file
        ;DS:SI <- addr command line  
  mov  si,offset command
        ;ES:DI <- addr filespec buffer
  mov  di,offset input_name
  cld
  lodsb      ;any command line present?
  or  al,al    ;return error status if not.
  jz  infile4
infile1:         ;scan over leading blanks
  lodsb      ;to file name
  cmp  al,cr    ;if we hit carriage return
  jz  infile4   ;filename is missing.
  cmp  al,20h    ;is this a blank?
  jz  infile1    ;if so keep scanning.
infile2:       ;found first char of name,
  stosb      ;move last char. to output
        ;file name buffer.
  lodsb      ;check next character, found
  cmp  al,cr    ;carriage return yet?   
  je  infile3    ;yes,exit with success code
  cmp  al,20h    ;is this a blank?
  jne   infile2    ;if not keep moving chars.
infile3:       ;exit with carry =0
  clc      ;for success flag
  ret
infile4:       ;exit with carry =1
  stc      ;for error flag
  ret
infile endp
outfile  proc  near    ;set up path and file
  cld      ;name for output file.
  mov  cx,64    ;length to move
  mov  si,offset input_name ;source addr
  mov  di,offset output_name ;dest addr
  rep movsb    ;transfer the string
  mov  di,offset output_name
outfile1:      ;scan string looking for
  mov  al,[di]   ;"." marking start of extension
  or  al,al    ;or zero byte marking name end.
  jz  outfile2  ;if either is found,jump.
  cmp  al,'.'
  je  outfile2  ;bump string pointer, loop
  inc  di    ;if neither '.' or zero found.
  jmp  outfile1  
outfile2:      ;found zero or '.',force the
        ;extension of the output file  
        ;to '.CLN'
  mov  si,offset outfile_ext
  mov  cx,5
  rep movsb
  ret      ;back to caller
outfile endp
open_input proc near    ;open input file
        ;DS:DX=addr filename
  mov  dx,offset input_name
  mov  al,0    ;AL=0 for read only
  mov  ah,3dh    ;function 3dh=open
  int   21h    ;handle returned in AX,
  mov  input_handle,ax ;save it for

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 汇编源码系列之clean

相关文章

  • 2017-06-17堆栈操作指令
  • 2017-06-28汇编源码系列之clear
  • 2017-06-28利用驱动程序读取硬盘序列号的汇编程序
  • 2017-06-28汇编教程之窗口子类化
  • 2017-06-17程序开始和结束伪操作
  • 2017-06-28制作动态链接库
  • 2017-06-28汇编教程:位图初步
  • 2017-06-28通用控件详解
  • 2017-06-28如何创建汇编工作环境
  • 2017-06-17存储单元的地址和内容

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • hello,world!win32汇编小程序
    • GUI编程中以对话框为主要界面的应用程序
    • 汇编中参数的传递和堆栈修正
    • 什么是子程序?子程序的概念
    • 虚拟8086模式的内存管理
    • 标志位设置指令
    • 汇编语言编写DOS下的内存驻留程序(5)
    • 汇编处理程序多重启动
    • 树型视图控件详解
    • 汇编源代码之MAKE SOUNDS(发声)

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有