Buffers
Files
Tools
Mule
;;; mmblocks.a86
;;;
;;; count number of flash data blocks that will
;;; become free by next memory management
;;;
;;; unsigned int mmblocks();
;;;
;;; Author: J. Steingraeber
;;; Date: 2004-10-16
;;;
;;; Released to the Public Domain
mmblocks_TEXT CSEG
.186
mmblocks_::
push bp
mov bp,sp
sub sp,0x80 ; read FAT in pieces of 0x80 bytes
push cx
push dx
push si
push di
cld
xor di,di ; result = 0
mov bx,0x0600 ; first data sector is #6
push ss
pop es
mmbl_secloop:
xor dx,dx
mmbl_offsloop:
push di
lea di,[bp-0x80]
mov cx,0x80
mov ah,0xF0
int 0x2E ; FLASHBIO
pop di
or ax,ax
jnz mmbl_ready ; error while reading data
lea si,[bp-0x80]
mov cx,0x40
mmbl_cntloop:
db 0x36 ; ss: (just in case)
lodsw
test ax,0x4000
jnz mmbl_cnt
inc di
mmbl_cnt:
loop mmbl_cntloop
;; next offset
add dx,0x80
cmp dx,0x07A0 ; FAT ends here, 0x7A0..0x7FF will be unmarked
jb mmbl_offsloop
;; next sector
inc bh
cmp bh,0x40
jb mmbl_secloop
mmbl_ready:
mov ax,di
pop di
pop si
pop dx
pop cx
mov sp,bp
pop bp
retf
end
--:%% mmblocks.a86 (Assembler)-L1--C1-----ALL----------------
|
|
M-x view-file index.html