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

汇编源码系列之driver

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

匿名通过本文主要向大家介绍了driver系列,led driver镇流器,oppodriver.exe,s530driver,mac driver等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div>

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

    name  driver
    page  55,132
    title  'DRIVER --- installable driver template'
;
; This is a "template" for a MS-DOS installable device driver.
; The actual driver subroutines are stubs only and have
; no effect but to return a non-error "done" status.
;
; Ray Duncan
; Laboratory Microsystems Inc.
; April 1985
code  segment public 'CODE'
driver proc  far
    assume cs:code,ds:code,es:code
    org   0
Max_Cmd equ   15       ; MS-DOS command code maximum
                ; this is 15 for MS-DOS 3.x
                ; and 12 for MS-DOS 2.x
cr   equ   0dh       ; ASCII carriage return
lf   equ   0ah       ; ASCII line feed
eom   equ   '$'       ; end of message signal
    page
;
; Device Driver Header
;
Header dd   -1       ;link to next device,-1= end of list
    dw   8000h      ;attribute word
                ;bit 15=1 for character devices
    dw   Strat      ;device "Strategy" entry point
    dw   Intr      ;device "Interrupt" entry point
    db   'DRIVER '   ;char device name, 8 char, or
                ;if block device, no. of units
                ;in first byte followed by
                ;7 don't care bytes  
; Interpretation of Attribute word:
;
; Bit      Significance
;
; 15      =1 for character drivers
; 14      =1 if driver can handle IOCTL
; 13      =1 if block device & non-IBM format
; 12      0
; 11      open/close/RM supported (DOS 3.x)
; 10      0
; 9      0
; 8      0
; 7      0
; 6      0
; 5      0
; 4      0
; 3      =1 if CLOCK device
; 2      =1 if NUL device
; 1      =1 if Standard Output
; 0      =1 if Standard Input
    page
;
; local variables for use by driver
;
RH_Ptr dd   ?        ; pointer to request header
                ; passed to Strat by BDOS
Ident  db   cr,lf,lf
    db   'LMI Example Device Driver 1.0'
    db   cr,lf
    db   'Copyright (c) 1985 '
    db   'Laboratory Microsystems Inc.'
    db   cr,lf,lf,eom
;
; MS-DOS Command Codes dispatch table.
; The "Interrupt" routine uses this table and the
; Command Code supplied in the Request Header to
; transfer to the appropriate driver subroutine.
Dispatch:
    dw   Init      ; 0 = init driver into system
    dw   Media_Chk    ; 1 = media check on blk dev
    dw   Build_Bpb    ; 2 = build BIOS param block
    dw   Ioctl_Inp    ; 3 = I/O ctrl read from dev
    dw   Input      ; 4 = normal destructive read
    dw   Nd_Input    ; 5 = non-destructive read,no wait
    dw   Inp_Stat    ; 6 = return current input status
    dw   Inp_Flush    ; 7 = flush device input buffers
    dw   Output     ; 8 = normal output to device
    dw   Outp_Vfy    ; 9 = output with verify
    dw   Outp_Stat    ; 10 = return current output status
    dw   Outp_Flush   ; 11 = flush output buffers
    dw   Ioctl_Outp   ; 12 = I/O control output
    dw   Dev_Open    ; 13 = device open   (MS-DOS 3.x)
    dw   Dev_Close    ; 14 = device close   (MS-DOS 3.x)
    dw   Rem_Media    ; 15 = removeable media (MS-DOS 3.x)
    page
;
; MS-DOS Request Header structure definition
;
; The first 13 bytes of all Request Headers are the same
; and are referred to as the "Static" part of the Header.
; The number and meaning of the following bytes varies.
; In this "Struc" definition we show the Request Header
; contents for Read and Write calls.
;
Request struc          ; request header template structure
    
                ; beginning of "Static" portion
Rlength db   ?        ; length of request header
Unit  db   ?        ; unit number for this request
Command db   ?        ; request header's command code
Status dw   ?        ; driver's return status word
Reserve db   8 dup (?)    ; reserved area
                ; end of "Static" portion   
Media  db   ?        ; media descriptor byte
Address dd   ?        ; memory address for transfer
Count  dw   ?        ; byte/sector count value
Sector dw   ?        ; starting sector value
Request ends          ; end of request header template
;
; Status word is interpreted as follows:
;
; Bit(s)  Significance
;  15    Error
;  10-14  Reserved
;  9    Busy
;  8    Done
;  0-7   Error code if bit 15=1
; Predefined BDOS error codes are:
;
;  0    Write protect violation
;  1    Unknown unit
;  2    Drive not ready
;  3    Unknown command
;  4    CRC error
;  5    Bad drive request structure length
;  6    Seek error
;  7    Unknown media
;  8    Sector not found
;  9    Printer out of paper
;  10   Write fault
;  11   Read fault
;  12   General failure  
;  13-14  Reserved
;  15   Invalid disk change (MS-DOS 3.x)
    page
; Device Driver "Strategy Routine"
; Each time a request is made for this device, the BDOS
; first calls "Strategy routine", then immediately calls
; the "Interrupt routine". 
; The Strategy routine is passed the address of the
; Request Header in ES:BX, which it saves in a local
; variable and then returns to the BDOS.
Strat  proc  far  
                ; save address of Request Header
    mov   word ptr cs:[RH_Ptr],bx
    mov   word ptr cs:[RH_Ptr+2],es
    ret           ; back to BDOS
Strat  endp
    page
; Device Driver "Interrupt Routine"
; This entry point is called by the BDOS immediately after
; the call to the "Strategy Routine", which saved the long
; address of the Request Header in the local variable "RH_Ptr".
; The "Interrupt Routine" uses the Command Code passed in
; the Request Header to transfer to the appropriate device
; handling routine. Each command code routine is responsible
; for any necessary return information into the Request Header,
; then transfers to Error or Exit to set the Return Status code.
Intr  proc far
    push  ax       ; save general registers
    push  bx
    push  cx
    push  dx
    push  ds
    push  es
    push  di
    push  si
    push  bp
    push  cs       ; make local data addressable
    pop   ds
    les   di,[RH_Ptr]   ; ES:DI = Request Header
                ; get BX = Command Code
    mov   bl,es:[di.Command]
    x

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

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

  • 汇编源码系列之driver

相关文章

  • 2017-06-28汇编数据转换操作小技巧
  • 2017-06-28汇编语言的艺术-基本认识(二)
  • 2017-06-28虚拟8086模式的内存管理
  • 2017-06-28汇编教程:连接数据源
  • 2017-06-28汇编源码系列之circle
  • 2017-06-28汇编源码系列之hdr
  • 2017-06-17几种基本的逻辑运算
  • 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
  • 微信公众号

最近更新的内容

    • 子程序的嵌套
    • 汇编与C语言的配合使用
    • 汇编语言学习指南(三)
    • 汇编源码系列之cdcheck
    • 汇编源码系列之drivesex
    • 汇编源码系列之ctrladel
    • 汇编教程之窗口子类化
    • 标志寄存器传送指令
    • 汇编教程:Win32调试API
    • 打印I/O

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

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