DOSBox下读写软盘

发布时间 2024-01-09 18:16:53作者: 儿立之年

最近在学习汇编语言,教材是王爽的汇编语言程序设计第三版,最后一个程序是写数据到软盘,教材上的代码很简单

assume cs:code
code segment

start:	
    mov ax,0b800h
	mov es,ax
	mov bx,0
	
	mov al,8	; 一屏4000字节,需要8个扇区
	mov ch,0
	mov cl,1
	mov dl,0
	mov dh,0
	mov ah,3
	int 13h

    mov ax, 4c00H
    int 21h

code ends
end start     

但是奈何没有软盘,在DOSBox的官方文档下面有教如何挂载:

-fs

The following are valid file system formats:

iso: Specifies the ISO 9660 CD-ROM format.
fat: Specifies that the image uses the FAT file system. DOSBox will attempt to mount this image as a drive in DOSBox and make the files available from inside DOSBox.
none: DOSBox will make no attempt to read the file system on the disk. This is useful if you need to format it or if you want to boot the disk using the BOOT command. When using the "none" filesystem, you must specify the drive number (2 or 3, where 2 = master, 3 = slave) rather than a drive letter.
For example, to mount a 70MB image as the slave drive device, you would type (without the quotes):

"imgmount 3 d:\test.img -size 512,63,16,142 -fs none"
Compare this with a mount to be able to access the drive
within DOSBox, which would read as:
"imgmount e: d:\test.img -size 512,63,16,142"

然后我就弄个了文件,diska.img,然后挂载上去

imgmount 0 D:\workspace\masm\drivers\diska.img -fs none

可惜没那么简单,执行后的的AH一直是AF。然后回过头来看教材上说的:

也是,我这个mac下的文件,写不进去也很正常,况且也没有格式化。最终,我在winimg9下面创建了diska.ima文件,挂载上去,运行代码,OK!

imgmount 0 D:\workspace\masm\drivers\diskb.ima -fs none

弄个下载地址,方便我mac使用