![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-10-31 19:16 |
共 47,815 主题排行 / 349,930 发帖 / 今日 0 篇 / 48,290 会员排行 |
| DOS开发编程 & 发展交流 (开发室) » 关于 INT25 读磁盘的问题〔已结〕 |
| 可打印版本 1,398 / 10 |
| 第1楼 19951001 | 发表于 2007-01-09 03:29 |
| 高级用户 发帖 272 积分 570 来自 北京 | |
|
关于 INT25 读磁盘的问题〔已结〕 经确认 INT25/26 不能读写 FAT32 ,要读写 FAT32要使用 INT21,我在3楼给出的程序,读出的FAT32扇区是乱码
[ Last edited by 19951001 on 2007-1-16 at 09:47 PM ] |
|
| 第2楼 GOTOmsdos | 发表于 2007-01-09 04:16 |
| 铂金会员 发帖 1,827 积分 5,154 | |
|
没有什么问题,INT25,26只能处理软盘.
|
|
| 第3楼 19951001 | 发表于 2007-01-09 04:55 |
| 高级用户 发帖 272 积分 570 来自 北京 | |
Originally posted by GOTOmsdos at 2007-1-9 04:16: 怎么会是这样, INT25, INT26属于DOS调用, 理论上说 FAT32 分区 DOS 7 是能够访问的. 以下是一个老外的程序, 在我的 fat32 分区上成功执行了 ; -*- fundamental -*- (asm-mode sucks) ; $Id: copybs.asm,v 1.4 2004/12/14 23:03:28 hpa Exp $ ; ----------------------------------------------------------------------- ; ; Copyright 1998-2004 H. Peter Anvin - All Rights Reserved ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, Inc., 53 Temple Place Ste 330, ; Boston MA 02111-1307, USA; either version 2 of the License, or ; (at your option) any later version; incorporated herein by reference. ; ; ----------------------------------------------------------------------- ; ; copybs.asm ; ; Small DOS program to copy the boot sector from a drive ; to a file ; ; Usage: copybs <drive>: <file> ; absolute 0 pspInt20: resw 1 pspNextParagraph: resw 1 resb 1 ; reserved pspDispatcher: resb 5 pspTerminateVector: resd 1 pspControlCVector: resd 1 pspCritErrorVector: resd 1 resw 11 ; reserved pspEnvironment: resw 1 resw 23 ; reserved pspFCB_1: resb 16 pspFCB_2: resb 16 resd 1 ; reserved pspCommandLen: resb 1 pspCommandArg: resb 127 section .text org 100h ; .COM format _start: mov ax,3000h ; Get DOS version int 21h xchg al,ah mov ,ax cmp ax,0200h ; DOS 2.00 minimum jae dosver_ok mov dx,msg_ancient_err jmp die section .bss alignb 2 DOSVersion: resw 1 section .text ; ; Scan command line for a drive letter followed by a colon ; dosver_ok: xor cx,cx mov si,pspCommandArg mov cl, cmdscan1: jcxz bad_usage ; End of command line? lodsb ; Load character dec cx cmp al,' ' ; White space jbe cmdscan1 or al,020h ; -> lower case cmp al,'a' ; Check for letter jb bad_usage cmp al,'z' ja bad_usage sub al,'a' ; Convert to zero-based index mov ,al ; Save away drive index section .bss DriveNo: resb 1 section .text ; ; Got the leading letter, now the next character must be a colon ; got_letter: jcxz bad_usage lodsb dec cx cmp al,':' jne bad_usage ; ; Got the colon; now we should have at least one whitespace ; followed by a filename ; got_colon: jcxz bad_usage lodsb dec cx cmp al,' ' ja bad_usage skipspace: jcxz bad_usage lodsb dec cx cmp al,' ' jbe skipspace mov di,FileName copyfile: stosb jcxz got_cmdline lodsb dec cx cmp al,' ' ja copyfile jmp short got_cmdline ; ; We end up here if the command line doesn't parse ; bad_usage: mov dx,msg_unfair jmp die section .data msg_unfair: db 'Usage: copybs <drive>: <filename>', 0Dh, 0Ah, '$' section .bss alignb 4 FileName resb 256 ; ; Parsed the command line OK. Get device parameter block to get the ; sector size. ; struc DPB dpbDrive: resb 1 dpbUnit: resb 1 dpbSectorSize: resw 1 dpbClusterMask: resb 1 dpbClusterShift: resb 1 dpbFirstFAT: resw 1 dpbFATCount: resb 1 dpbRootEntries: resw 1 dpbFirstSector: resw 1 dpbMaxCluster: resw 1 dpbFATSize: resw 1 dpbDirSector: resw 1 dpbDriverAddr: resd 1 dpbMedia: resb 1 dpbFirstAccess: resb 1 dpbNextDPB: resd 1 dpbNextFree: resw 1 dpbFreeCnt: resw 1 endstruc section .bss alignb 2 SectorSize resw 1 section .text got_cmdline: xor al,al ; Zero-terminate filename stosb mov dl, inc dl ; 1-based mov ah,32h int 21h ; Get Drive Parameter Block and al,al jnz filesystem_error mov dx, ; Save sector size ; ; Read the boot sector. ; section .data align 4, db 0 DISKIO equ $ diStartSector: dd 0 ; Absolute sector 0 diSectors: dw 1 ; One sector diBuffer: dw SectorBuffer ; Buffer offset dw 0 ; Buffer segment section .text read_bootsect: mov ax,cs ; Set DS <- CS mov ds,ax mov ,dx ; Saved sector size from above cmp word ,0400h ; DOS 4.00 has a new interface jae .new .old: mov bx,SectorBuffer mov cx,1 ; One sector jmp short .common .new: mov ,ax ; == DS mov bx,DISKIO mov cx,-1 .common: xor dx,dx ; Absolute sector 0 mov al, int 25h ; DOS absolute disk read pop ax ; Remove flags from stack jc disk_read_error ; ; Open the file and write the boot sector to the file. ; mov dx,FileName mov cx,0020h ; Attribute = ARCHIVE mov ah,3Ch ; Create file int 21h jc file_write_error mov bx,ax push ax ; Handle mov cx, mov dx,SectorBuffer mov ah,40h ; Write file int 21h jc file_write_error cmp ax, jne file_write_error pop bx ; Handle mov ah,3Eh ; Close file int 21h jc file_write_error ; ; We're done! ; mov ax,4C00h ; exit(0) int 21h ; ; Error routine jump ; filesystem_error: mov dx,msg_filesystem_err jmp short die disk_read_error: mov dx,msg_read_err jmp short die file_write_error: mov dx,msg_write_err die: push cs pop ds push dx mov dx,msg_error mov ah,09h int 21h pop dx mov ah,09h ; Write string int 21h mov ax,4C01h ; Exit error status int 21h section .data msg_error: db 'ERROR: $' msg_ancient_err: db 'DOS version 2.00 or later required', 0Dh, 0Ah, '$' msg_filesystem_err: db 'Filesystem not found on disk', 0Dh, 0Ah, '$' msg_read_err: db 'Boot sector read failed', 0Dh, 0Ah, '$' msg_write_err: db 'File write failed', 0Dh, 0Ah, '$' section .bss alignb 4 SectorBuffer: resb 4096 |
|
| 第4楼 GOTOmsdos | 发表于 2007-01-09 05:24 |
| 铂金会员 发帖 1,827 积分 5,154 | |
|
这个ASM是调用的25H,查了TC3的ABSREAD()的说明,是INT 25的我试过用ABSREAD()未能成功读硬盘,INT13就行,我也不知原因 .
这个ASM是不是还另外作了特别处理? |
|
| 第5楼 19951001 | 发表于 2007-01-09 06:11 |
| 高级用户 发帖 272 积分 570 来自 北京 | |
Originally posted by GOTOmsdos at 2007-1-9 05:24: 全部代码都在 |
|
| 第6楼 GOTOmsdos | 发表于 2007-01-10 11:31 |
| 铂金会员 发帖 1,827 积分 5,154 | |
|
我也感到很奇怪,我这里有本专讲硬盘编程的书,从头到尾未提int25-26一字!
|
|
| 第7楼 cnch | 发表于 2007-03-24 03:49 |
| 中级用户 发帖 70 积分 326 | |
|
INT25,INT26确实能对硬盘进行读写,但仅适用于FAT12,FAT16,要读写FAT32须调用INT21(7305H) ,它可以读写软盘、硬盘,支持FAT12、FAT16、FAT32,但要求WIN95OSR2及以后版本的操作系统
[ Last edited by cnch on 2007-3-24 at 03:52 AM ] |
|
| 第8楼 GOTOmsdos | 发表于 2007-03-24 06:21 |
| 铂金会员 发帖 1,827 积分 5,154 | |
Originally posted by cnch at 2007-3-24 03:49 AM: 调用中断读写硬盘是物理(扇区)方式嘛,应该跟文件系统没有关系吧 所需要的仅仅是BIO硬盘S信息和硬盘软盘控制器信息吧? |
|
| 第9楼 cnch | 发表于 2007-03-27 04:12 |
| 中级用户 发帖 70 积分 326 | |
Originally posted by GOTOmsdos at 2007-3-24 06:21 AM: 哦,只要BIOS硬盘信息和硬盘软盘控制器信息INT13即可.现成的应用程序太多啦,何必如此辛苦? |
|
| 第10楼 wzsunlight | 发表于 2007-03-28 18:45 |
| 初级用户 发帖 52 积分 107 | |
Originally posted by cnch at 2007-3-26 03:12 PM: 同意 |
|
| 第11楼 download | 发表于 2007-03-29 00:34 |
| 初级用户 发帖 101 积分 199 | |
|
造轮子的工作……一直在重复着。没多大意思
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |