• 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
  • 微信公众号
您的位置:首页 > 程序设计 >汇编语言 > (汇编源代码 )PRINT FILE PROGRAM (打印文件)

(汇编源代码 )PRINT FILE PROGRAM (打印文件)

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

匿名通过本文主要向大家介绍了printfile,print to file,printfile.pdf,print file是什么意思,onfileprintpreview等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div>

INTRODUCTION

The following example is a simple program to read a file and print the contents to a standard printer. It gets the filename of the file to print from the DOS command prompt input line. The prompt input information is passed to the program in a buffer area of the Program Segment Prefix (PSP). The address of the Program Segment Prefix is passed to the program in the ES and DS registers when the program execution starts. This program checks the keyboard between every character printed for an escape key code to terminate execution of the program.

; This program prints a file defined on the command line
.MODEL small
;************* Stack Section *********************
.STACK 500
;************* Data Section **********************
.DATA
psp_seg    dw  0
no_cl_mess  db "This routine requires that a "
  db  "filename be on the command line for printing."
  db 0dh,0ah,"Please try with a filename.",0dh,0ah,"$"
file_bad_open db "Bad file open",0dh,0ah,"$"
file_bad_read db "Bad file read",0dh,0ah,"$"
printer_bad_mess db  "!! Printer Error !!!!",0dh,0ah,"$"
printing_mess db "A file is being printed,",0dh,0ah
  db  "To stop printing, Press ESC key",0dh,0ah,"$"
filename    db  128 dup(0)
file_handle  dw  0
file_count   dw  0
file_pointer  dw  offset file_buffer
file_buffer  db  1024 dup(0)
; ************* ----------- *********************
;************* Code Section *******************
.CODE
start   proc near
 ;DS and ES are indexing PSP area
  mov al,[DS:80H]   ;load AL with size of data line
  mov dx,@data    ;get segment address of data area
  mov ds,dx      ;point DS to data area
  mov psp_seg,ES   ;save PSP address
  cmp al,1     ;?? data in DOS command line ??
  ja  get_PSP_filename ;branch if data found
 ;if here, there is no data on command line
  ;display error message to user and terminate
  lea dx,no_cl_mess
;-------------------------
terminate_display:
  ;display message indexed by DX then terminate
  mov ah,09
  int 21H   ;DOS Call
;-------------------------
terminate_program:
;terminating the program
  mov ah,4CH  ;set AH for terminating function
  mov al,00   ;set terminating code variable
  int 21H    ;call DOS to terminate
;------------------------------------------
; %%%%%%%%%%%%% ----------- %%%%%%%%%%%%%%%
get_PSP_filename:
 ;move PSP filename to filename buffer in our data area
  mov ax,ds
  mov es,ax  ;point ES to data segment
  mov ds,psp_seg
  mov si,82H  ;SI source is PSP data area
  lea di,filename
  cld      ;make strings go forward
  get_PSP_data_1:
   lodsb   ;load string data byte
     ;check for end of filename
   cmp al,21H
     ;branch if end of string
   jb got_PSP_filename
     stosb   ;store string data byte
     jmp get_PSP_data_1
got_PSP_filename:
  mov al,0
  stosb   ;make ASCIIZ string with zero end
  push es
  pop ds  ;reset data segment pointer
;try to open file
  mov ah,3dH
  lea dx,filename
  mov al,0   ;read access code
  int 21H   ;DOS Call
  jnc file_open_ok
  lea dx,file_bad_open
  jmp terminate_display
;+++++++++++++++++++++++++++++++++++++++++++
;############### +++++++++++ ###############
file_open_ok:
  ;save file handle
  mov file_handle,ax
  lea dx,printing_mess ;display start message
  mov ah,09
  int 21H    ;DOS Call
file_read:
  ;read in block of file data
  mov ah,3fH
  lea dx,file_buffer
  mov cx,1024
  mov bx,file_handle
  int 21H    ;DOS Call
  jnc file_read_ok  ;branch if good read
    ;else read file error occurred
     ;close file
    mov ah,3eh
    mov bx,file_handle
    int 21H
    ;index exit error message
    lea dx,file_bad_read
    jmp terminate_display
file_read_ok:
  ;check to see if no more file data
  cmp ax,0
  je  close_file  ;branch if no data left
  ;else reset data block size and pointer
  mov file_count,ax
  lea bx,file_buffer
  mov file_pointer,bx
;!!!!!!!!!!!!!!!!! ^^^^^^^^ !!!!!!!!!!!!!!!!!!!!
print_data_block:
  ;main loop to print block of file data
  ;scan keyboard to check for any keys
   mov ah,1
   int 16H
   jz print_data_block_1 ;branch if no key
   ;get key code out of buffer
   mov  ah,0
   int 16H     ;call BIOS keyboard
   cmp  al,01BH     ;check key code
   je  close_file  ;branch if ESC
print_data_block_1:
  mov si,file_pointer
  mov al,[si]
  mov ah,0
  mov dx,0   ;select LPT1
  int 17H    ;BIOS Call
  test ah,25H
  jnz printer_error
  inc si
  mov file_pointer,si
  dec file_count
  jnz print_data_block  ;loop if more data
  ;else go read in next block of file data
  jmp file_read
;!!!!!!!!!!!!!!!! ^^^^^^^^ !!!!!!!!!!!!!!!!!!!!
close_file:
  mov ah,3eh
  mov bx,file_handle
  int 21H  ;DOS Call
  jmp terminate_program
;-------------- ?????????? -------------------
printer_error:
   ;index exit error message
   lea dx,printer_bad_mess
   jmp terminate_display
;_______________________________________________
start endp   ;end of start procedure
  end start  ;define start as beginning of program

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

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

  • (汇编源代码 )PRINT FILE PROGRAM (打印文件)

相关文章

  • 2017-06-28鼠标控制CD-Audio播放程序
  • 2017-06-17循环指令
  • 2017-06-17分支程序设计
  • 2017-06-28汇编教程之处理键盘输入消息
  • 2017-06-28工具提示控件介绍
  • 2017-06-28Win32汇编的环境和基础
  • 2017-06-28(汇编源代码 )PRINT FILE PROGRAM (打印文件)
  • 2017-06-2880386的异常类型
  • 2017-06-28一个win32汇编语言程序示例
  • 2017-06-28汇编源码系列之calc

文章分类

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

最近更新的内容

    • 汇编语言的艺术-准备工作(三)
    • (汇编源代码 )简单的取系统时间小程序
    • debug命令详解
    • 80386/80286处理的数据类型
    • 5个DOS专用文件的6种io重定向(实现管道原理)
    • 汇编语言的艺术-准备工作(一)
    • 汇编源码系列之burnout
    • 8086/8088指令系统
    • 汇编修改文件操作
    • 汇编源码系列之calc

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

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