#(C) TechnicallyObsolete 2024 # GPL v3 License #Based on 8088 BIOS Copyright (C) 2010 - 2023 Sergey Kiselev. ;========================================================================= ; int_13 - BIOS floppy disk services ; Input: ; AH = function ; 00h - Reset disk system ; 01h - Get status of last operation ; 02h - Read disk sectors ; 03h - Write disk sectors ; 04h - Verify disk sectors ; 05h - Format track ; 08h - Get drive parameters ; 15h - Get disk type ; 16h - Detect disk change ; 17h - Set disk type for format ; 18h - Set media type for format ; ; Note, all of these functions are handled by the STM32. ; Output: ; - depends on function ; - for most functions: ; CF clear if successful ; AH = 00h - successful completion ; CF set on error ; AH = error code ;------------------------------------------------------------------------- setloc 0EC59h ; INT 13 (Floppy) Entry Point FPGA_REG_AL equ 50h FPGA_REG_AH equ 51h FPGA_REG_BL equ 52h FPGA_REG_BH equ 53h FPGA_REG_CL equ 54h FPGA_REG_CH equ 55h FPGA_REG_DL equ 56h FPGA_REG_DH equ 57h FPGA_REG_ES_L equ 58h FPGA_REG_ES_H equ 59h FPGA_REG_DI_L equ 5Ah FPGA_REG_DI_H equ 5Bh FPGA_REG_COPY equ 5Ch ;Used to specify which bytes to copy back FPGA_REG_REQ equ 5Dh FPGA_REG_KBD equ 5Eh FPGA_REG_STS equ 5Fh int_13: ;Copy function params out FPGA_REG_AL, al mov al, ah out FPGA_REG_AH, al mov al, bl out FPGA_REG_BL, al mov al, bh out FPGA_REG_BH, al mov al, cl out FPGA_REG_CL, al mov al, ch out FPGA_REG_CH, al mov al, dl out FPGA_REG_DL, al mov al, dh out FPGA_REG_DH, al mov ax, es out FPGA_REG_ES_L, al mov al, ah out FPGA_REG_ES_H, al ;Now generate a request mov al, 13h out FPGA_REG_REQ, al ;Clock will now be stopped ;Once it resumes, register 5 will have a status code in it ; ;Update the carry flag accordingly clc in al, FPGA_REG_REQ cmp al, 00h jz copy_regs ;Didn't jump directly to COPY_REGS, so FPGA_REG_REQ != 0 ;Set Carry flag to indicate something went wrong stc copy_regs: ;Which registers should be copied back? ;REG_COPY = 0 -> AH, AL only ; = 1 -> AH, AL, BL, CH, CL, DH, DL, ES:DI in al, FPGA_REG_COPY cmp al, 01h jz copy_large copy_ah_al: in al, FPGA_REG_AH mov ah, al in al, FPGA_REG_AL jmp end copy_large: ;BX in al, FPGA_REG_BL mov bl, al in al, FPGA_REG_BH mov bh, al ;CX in al, FPGA_REG_CL mov cl, al in al, FPGA_REG_CH mov ch, al ;DX in al, FPGA_REG_DL mov dl, al in al, FPGA_REG_DH mov dh, al ;ES in al, FPGA_REG_ES_H mov ah, al in al, FPGA_REG_ES_L ;AX now contains the new ES value mov es, ax ;DI in al, FPGA_REG_DI_H mov ah, al in al, FPGA_REG_DI_L ;AX now contains the new DI value mov di, ax ;Finally, restore the AL, AH values in al, FPGA_REG_AH mov ah, al in al, FPGA_REG_AL end: iret