⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 format.asm

📁 DOS下基于28f512的小型文件系统 format.asm/list.asm/erasetes.asm/readfl.asm/start.asm/writefl.asm
💻 ASM
字号:
port_a  equ 0c800h
port_b  equ 0c801h
port_d  equ 0c803h
port_ce equ 0c810h
data    segment
string1 db 'GW33 SYSTEM!'
string2 db 0dh,0ah,'formating...','$'
string3 db 0dh,0ah,'setting up GW33 SYSTEM ...','$'
string4 db 0dh,0ah,'format error!','$'
string5 db 0dh,0ah,'set system error!','$'
string6 db 0dh,0ah,'set system ok ,enjoy yourself!','$'
position dw 400h
number   db 0
data    ends
code    segment
        assume cs:code,ds:data
start:  mov ax,data
        mov ds,ax
        mov dx,port_d           ;set comtrol word
        mov al,80h
        out dx,al
        lea dx,string2          ;format
        mov ah,09h
        int 21h
        call format
        cmp di,1000             ;format ok?
        jnz next1
        lea dx,string4
        mov ah,09h
        int 21h
next1:  lea dx,string3           ;set system
        mov ah,09h
        int 21h
        lea si,string1
        mov cx,12
        mov bx,0
next2:  call writebyt           ;write string1
        cmp di,25
        jz exit_f
        inc bx
        inc si
        loop next2
        lea si,position         ;write file address
        mov bx,10h
        call writebyt
        cmp di,25
        jz exit_f
        inc bx
        inc si
        call writebyt
        cmp di,25
        jz exit_f
        mov bx,80h               ;write file number
        lea si,number
        call writebyt
        cmp di,25
        jz exit_f
        lea dx,string6
        mov ah,09h
        int 21h
exit_f: mov ah,4ch             ;return dos
        int 21h
;
format  proc
        xor di,di
        xor bx,bx
        mov cx,0ffffh
        mov dx,port_b   ;addressh
        mov al,bh
        out dx,al
        mov dx,port_a    ;addressl
        mov al,bl
        out dx,al
next_e1:mov dx,port_ce    ;erase cmd1
        mov al,20h
        out dx,al
        mov dx,port_ce    ;erase cmd2
        mov al,20h
        out dx,al
        call delay_e
next_e2:mov dx,port_b   ;addressh
        mov al,bh
        out dx,al
        mov dx,port_a    ;addressl
        mov al,bl
        out dx,al
        mov dx,port_ce    ;erase check
        mov al,0a0h
        out dx,al
        call delay
        mov dx,port_ce     ;read
        in al,dx
        cmp al,0ffh
        jz next_e3
        inc di
        cmp di,1000
        jnz next_e1
        jmp exit_e
next_e3:inc bx
        loop next_e2
exit_e: ret
format  endp
delay_e proc
        push cx
        mov cx,100h
bb:     mov di,8000h
aa:     dec di
        jnz aa
        loop bb
        pop cx
        ret
delay_e endp
delay   proc
        push cx
        mov cx,8000h
        loop $
        pop cx
        ret
delay   endp
writebyt proc         ;address: bx, byte to write: [si]
        mov di,0
next_w: mov dx,port_ce    ;set write cmd
        mov al,40h
        out dx,al
        mov dx,port_b    ;addressh
        mov al,bh
        out dx,al
        mov dx,port_a     ;addressl
        mov al,bl
        out dx,al
        mov dx,port_ce     ;write
        mov al,[si]
        out dx,al
        call delay
        mov dx,port_ce     ;write check
        mov al,0c0h
        out dx,al
        call delay
        mov dx,port_ce     ;read
        in al,dx
        cmp al,[si]
        jz exit_w
        inc di
        cmp di,25
        jnz next_w
        lea dx,string5     ;error write
        mov ah,09h
        int 21h
exit_w: ret
writebyt endp

code    ends
        end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -