• 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
  • 微信公众号
您的位置:首页 > 程序设计 >汇编语言 > 汇编源码系列之cleanf

汇编源码系列之cleanf

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

匿名通过本文主要向大家介绍了汇编源码,易语言反汇编源码,win7用远程汇编源码,反汇编源码,易语言汇编源码等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div>

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

  name  cleanf
  page  55,132
  title  'CLEANF - Filter text file'
;
; CLEANF - a DOS 2.0 filter for word processing document files.
;
; CLEAN.ASM Originally written by Ray Duncan
; Converted to DOS 2.0 filter CLEANF.ASM by Bob Taylor.
;
; This program reads text from the standard input device and writes
; filtered and transformed text to the standard output device.
;
;  1. High bit of all characters is stripped off.
;   2. Tabs are expanded.
;    3. Removes all control codes except for line
;      feeds, carriage returns, and form feeds.
;    4. Appends an end-of-file mark to the text, if
;      none was present in the input stream.
;
; Can be used to make a WordStar file acceptable for
; other screen or line editors, and vice versa.
;
;
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 code
command  equ  80h    ; buffer for command tail
; DOS 2.0 Pre-Defined Handles
stdin  equ  0000    ; standard input file
stdout  equ  0001    ; standard output file
stderr  equ  0002    ; standard error file
stdaux  equ  0003    ; standard auxilliary file
stdprn  equ  0004    ; standard printer file
cseg  segment para public 'CODE'
  assume  cs:cseg,ds:cseg
  org  100H    ; start .COM at 100H
clean  proc  far    ; entry point from PC-DOS.
  push  ds    ; push a long return back
  xor  ax,ax    ; to DOS onto the stack.
  push  ax
clean3:  call  get_char  ; get a character from input.
  and  al,7fh    ; turn off the high bit.
  cmp  al,20h    ; is it a control char?
  jae  clean4    ; no. write it to output.
  cmp  al,eof    ; is it end of file?
  je  clean6    ; yes, go write EOF mark and exit.
  cmp  al,tab    ; is it a tab?
  je  clean5    ; yes, go expand it to spaces.
  cmp  al,cr    ; is it a carriage return?
  je  clean35    ; yes, go process it.
  cmp  al,lf    ; is it a line feed?
  je  clean35    ; yes, go process it.
  cmp  al,ff    ; is it a form feed?
  jne  clean3    ; no. discard it. 
clean35:
  mov  column,0  ; if it's a legit ctrl char,
  jmp  clean45    ; we should be back at column 0.
clean4:  inc  column    ; if it's a non-ctrl char,
clean45:      ; col = col + 1.
  call  put_char  ; write the char to output.
  jnc  clean3    ; if OK, go back for another char.
  mov  bx,stderr  ; not OK. Set up to show error.
  mov  dx,offset err_msg
  mov  cx,err_msg_len  ; error = Disk full.
  mov  ah,40h    ; write the error message
  int  21h    ; to the standard error device. (CON:)
  ret      ; back to DOS.
clean5:  mov  ax,column  ; tab code detected, must expand
  cwd      ; expand tabs to spaces.
  mov  cx,8    ; divide the current column counter
  idiv  cx    ; by eight...
  sub  cx,dx    ; eight minus the remainder is the
  add  column,cx  ; number of spaces to send out to
clean55:      ; move to the next tab position.
  push  cx
  mov  al,20h
  call  put_char  ; send an ASCII blank
  pop  cx
  loop  clean55
  jmp  clean3
clean6:  call  put_char  ; write out the EOF mark,
  ret      ; and return to DOS.
clean  endp
get_char proc near
  mov  bx,stdin    ; get chars from std. input
  mov  cx,1      ; # of chars to get = 1
  mov  dx,offset input_buffer  ; location = input_buffer
  mov  ah,3fh
  int  21h      ; do the function call
  or  ax,ax      ; test # of chars returned
  jz  get_char1    ; if none, return EOF
  mov  al,input_buffer    ; else, return the char in AL
  ret
get_char1:
  mov  al,eof      ; no chars read, return
  ret        ; an End-of-File (EOF) mark.
get_char endp
put_char proc near
  mov  output_buffer,al  ; put char to write in buffer.
  mov  bx,stdout    ; write to std. output
  mov  cx,1      ; # of chars = 1
  mov  dx,offset output_buffer  ; location = output_buffer
  mov  ah,40h
  int  21h      ; do the function call
  cmp  ax,1      ; check to see it was really done.
  jne  put_char1
  clc        ; really done. return carry = 0
  ret        ; as success signal.
put_char1:
  stc        ; not really done. return carry = 1
  ret        ; as error signal (device is full).
put_char endp
input_buffer  db  0    
output_buffer  db  0
column    dw  0
err_msg    db  cr,lf
    db  'clean: Disk is full.'
    db  cr,lf
err_msg_len  equ  (this byte)-(offset err_msg)
cseg  ends
  end  clean


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

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

  • 汇编源码系列之inthand
  • 汇编源码系列之cdcheck
  • 汇编源码系列之cldoc12
  • 汇编源码系列之basload
  • 汇编源码系列之basmain
  • 汇编源码系列之brk2
  • 汇编源码系列之cleanf
  • 汇编源码系列之charop
  • 汇编源码系列之sertype
  • 汇编源码系列之comint

相关文章

  • 2017-06-17DOS内部结构与BIOS的功能
  • 2017-06-28Win32汇编小试
  • 2017-06-28用汇编编写屏幕保护程序
  • 2017-06-17指令格式
  • 2017-06-28汇编源码系列之col
  • 2017-06-28汇编源码系列之gameport
  • 2017-06-28汇编源码系列之calc
  • 2017-06-28GUI编程中以对话框为主要界面的应用程序
  • 2017-06-28汇编语言套装软件制作(2)
  • 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
  • 微信公众号

最近更新的内容

    • 子程序的嵌套
    • 汇编程序设计
    • WIN98SE硬盘主引导记录代码反汇编分析
    • 汇编源码系列之getseg_c
    • 汇编源代码之硬盘保护锁
    • 汇编教程:连接数据源
    • 系统配置查询(BIOS,INT 10H)
    • 汇编处理程序多重启动
    • 汇编源码系列之chips
    • 汇编源码系列之drivesex

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

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