Add a few toys

This commit is contained in:
2025-09-24 00:40:56 +02:00
parent 9daf8d7f97
commit ee97876115
8 changed files with 250 additions and 0 deletions

63
format.asm Normal file
View File

@@ -0,0 +1,63 @@
BITS 16
CPU 8086
buffer equ 0xe000
sectors equ 9
_start:
jmp main
formattrack:
push bp
push bx
push di
mov bp, sp
push ax ; track
push cx ; head
mov bx, buffer
xor cx, cx
l0:
cmp cl, sectors
jnl l1
mov di, cx
and di, 0x0f ; max 15 sectors
shl di, 1
shl di, 1 ; di = cl*4
lea di, [bx+di]
mov al, [bp-2] ; track number
mov [di+0], al
mov al, [bp-4] ; head number
mov [di+1], al
mov al, cl ; sector number
inc al
mov [di+2], al
mov [di+3], byte 0x02 ; 512 bytes per sector
inc cl
jmp l0
l1:
mov ah, 0x05 ; format track
mov al, sectors
mov dl, 0 ; first drive
mov dh, [bp-4] ; head number
mov ch, [bp-2] ; track number
mov cl, 1 ; sector number (first sector?)
int 0x13
add sp, 4
pop di
pop bx
pop bp
ret
main:
mov bp, sp
mov si, [bp+8]
mov ax, [si]
mov si, [bp+6]
mov cx, [si]
call formattrack
mov si, [bp+4]
mov [si], ax
retf 6