2004-10-29 18:32:48 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
db "biosprint",0
|
|
|
|
|
dw biosprint
|
|
|
|
|
db "mbinit",0
|
|
|
|
|
dw mbinit
|
|
|
|
|
db "mbcreate",0
|
|
|
|
|
dw mbcreate
|
|
|
|
|
db "mbfree",0
|
|
|
|
|
dw mbfree
|
|
|
|
|
db "mbclean",0
|
|
|
|
|
dw mbclean
|
|
|
|
|
db "mbresident",0
|
|
|
|
|
dw mbresident
|
|
|
|
|
db "mbnonresident",0
|
|
|
|
|
dw mbnonresident
|
|
|
|
|
db "mbchown",0
|
|
|
|
|
dw mbchown
|
|
|
|
|
db "mballoc",0
|
|
|
|
|
dw mballoc
|
|
|
|
|
db "mbfind",0
|
|
|
|
|
dw mbfind
|
|
|
|
|
db "mbfindsb",0
|
|
|
|
|
dw mbfindsb
|
|
|
|
|
db "mbget",0
|
|
|
|
|
dw mbget
|
|
|
|
|
db "mbloadfuncs",0
|
|
|
|
|
dw mbloadfuncs
|
|
|
|
|
db "mbsearchfunc",0
|
|
|
|
|
dw mbsearchfunc
|
|
|
|
|
db "bioswaitkey",0
|
|
|
|
|
dw bioswaitkey
|
|
|
|
|
db "mbloadsection",0
|
|
|
|
|
dw mbloadsection
|
|
|
|
|
db "enableirq",0
|
|
|
|
|
dw enableirq
|
|
|
|
|
db "disableirq",0
|
|
|
|
|
dw enableirq
|
|
|
|
|
db "readmaskirq",0
|
|
|
|
|
dw readmaskirq
|
|
|
|
|
db "readirr",0
|
|
|
|
|
dw readirr
|
|
|
|
|
db "readisr",0
|
|
|
|
|
dw readisr
|
|
|
|
|
db "seteoi",0
|
|
|
|
|
dw seteoi
|
|
|
|
|
dd 0
|
2004-10-29 18:32:48 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
include "8259a.asm"
|
2004-10-29 18:32:48 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Affiche le nombre hexa dans %0[dword]
|
|
|
|
|
PROC biosprinth FAR
|
|
|
|
|
ARG @num:dword
|
|
|
|
|
USES ax,bx,cx,edx,si,di
|
|
|
|
|
mov edx,[@num]
|
|
|
|
|
mov ah,09h
|
|
|
|
|
mov di,8
|
|
|
|
|
@@hexaize:
|
|
|
|
|
rol edx,4
|
|
|
|
|
mov si,dx
|
|
|
|
|
and si,1111b
|
|
|
|
|
mov al,[cs:si+offset @@tab]
|
|
|
|
|
mov cx,1
|
|
|
|
|
cmp al,32
|
|
|
|
|
jb @@control
|
|
|
|
|
mov bx,7
|
|
|
|
|
mov ah,09h
|
|
|
|
|
int 10h
|
|
|
|
|
@@control:
|
|
|
|
|
mov ah,0Eh
|
|
|
|
|
int 10h
|
|
|
|
|
dec di
|
|
|
|
|
jnz @@hexaize
|
|
|
|
|
ret
|
|
|
|
|
@@tab db '0123456789ABCDEF'
|
|
|
|
|
endp biosprinth
|
2004-10-29 18:32:48 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Affiche le texte ASCIIZ point<6E> par %0
|
|
|
|
|
PROC biosprint FAR
|
|
|
|
|
ARG @pointer:word
|
|
|
|
|
USES ax,bx,cx,si
|
|
|
|
|
mov si,[@pointer]
|
|
|
|
|
mov cx,1
|
|
|
|
|
mov bx,7
|
|
|
|
|
@@again:
|
|
|
|
|
lodsb
|
|
|
|
|
or al,al
|
|
|
|
|
jz @@fin
|
|
|
|
|
cmp al,32
|
|
|
|
|
jb @@control
|
|
|
|
|
mov ah,09h
|
|
|
|
|
int 10h
|
|
|
|
|
@@control:
|
|
|
|
|
mov ah,0Eh
|
|
|
|
|
int 10h
|
|
|
|
|
jmp @@again
|
|
|
|
|
@@fin:
|
|
|
|
|
ret
|
|
|
|
|
endp biosprint
|
2004-10-29 18:32:48 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;PROC flatmode FAR
|
|
|
|
|
; USES eax,bx,edx
|
|
|
|
|
; ; first, calculate the linear address of GDT
|
|
|
|
|
; xor edx,edx
|
|
|
|
|
; xor eax,eax
|
|
|
|
|
; mov dx,cs
|
|
|
|
|
; shl edx,4
|
|
|
|
|
; add [dword ptr cs:offset @@gdt+2],edx ; store as GDT linear base addr
|
|
|
|
|
; ; now load the GDT into the GDTR
|
|
|
|
|
; lgdt [fword ptr cs:offset @@gdt] ; load GDT base (286-style 24-bit load)
|
|
|
|
|
; mov bx,1 * size descriptor ; point to first descriptor
|
|
|
|
|
; mov eax,cr0 ; prepare to enter protected mode
|
|
|
|
|
; or al,1 ; flip the PE bit
|
|
|
|
|
; cli ; turn off interrupts
|
|
|
|
|
; mov cr0,eax ; we're now in protected mode
|
|
|
|
|
; mov fs,bx ; load the FS segment register
|
|
|
|
|
; and al,0FEh ; clear the PE bit again
|
|
|
|
|
; mov cr0,eax ; back to real mode
|
|
|
|
|
; sti ; resume handling interrupts
|
|
|
|
|
; ret ;
|
|
|
|
|
|
|
|
|
|
;@@gdt descriptor <@@gdtend - @@gdt - 1, @@gdt, 0, 0, 0, 0> ; the GDT itself
|
|
|
|
|
; descriptor <0ffffh, 0, 0, 091h, 0cfh, 0> ; 4G data segment
|
|
|
|
|
;@@gdtend:
|
|
|
|
|
;endp flatmode
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Attend l'appuie sur une touche
|
|
|
|
|
PROC bioswaitkey FAR
|
|
|
|
|
xor ax,ax
|
|
|
|
|
int 16h
|
|
|
|
|
ret
|
|
|
|
|
endp bioswaitkey
|
|
|
|
|
|
|
|
|
|
firstmb dw 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;Charge les sections du block %0
|
|
|
|
|
PROC mbloadsection FAR
|
|
|
|
|
ARG @blocks:word
|
|
|
|
|
USES ax,bx,cx,si,di,ds,es
|
|
|
|
|
LOCAL @@toresov:word:60
|
|
|
|
|
mov ax,[@blocks]
|
|
|
|
|
inc ax
|
|
|
|
|
inc ax
|
|
|
|
|
mov es,ax
|
|
|
|
|
mov ds,ax
|
|
|
|
|
cmp [word ptr 0],"EC"
|
|
|
|
|
jne @@notace
|
|
|
|
|
lea si,[@@toresov]
|
|
|
|
|
mov [word ptr ss:si],0FFFFh
|
|
|
|
|
mov bx,[ds:exe.sections]
|
|
|
|
|
@@loading:
|
|
|
|
|
cmp [dword ptr bx],0
|
|
|
|
|
je @@finishloading
|
|
|
|
|
mov ax,bx
|
|
|
|
|
add ax,4
|
|
|
|
|
call mbcreate,ax,[word ptr bx+2]
|
|
|
|
|
jc @@error
|
2004-11-19 18:19:05 +01:00
|
|
|
|
inc si
|
|
|
|
|
inc si
|
2007-03-13 21:56:55 +01:00
|
|
|
|
mov [ss:si],ax
|
|
|
|
|
push si
|
|
|
|
|
mov si,[bx]
|
|
|
|
|
xor di,di
|
|
|
|
|
mov es,ax
|
|
|
|
|
mov cx,[bx+2]
|
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
pop si
|
|
|
|
|
add bx,4
|
|
|
|
|
@@gonext:
|
|
|
|
|
inc bx
|
|
|
|
|
cmp [byte ptr bx],0
|
|
|
|
|
jne @@gonext
|
|
|
|
|
inc bx
|
|
|
|
|
jmp @@loading
|
|
|
|
|
@@finishloading:
|
|
|
|
|
pushad
|
|
|
|
|
xor eax,eax
|
|
|
|
|
mov ax,[word ptr ss:si]
|
|
|
|
|
call biosprinth,eax
|
|
|
|
|
popad
|
|
|
|
|
cmp [word ptr ss:si],0FFFFh
|
|
|
|
|
je @@finishdepands
|
|
|
|
|
call mbloadfuncs,[word ptr ss:si]
|
|
|
|
|
jc @@depandserror
|
|
|
|
|
dec si
|
|
|
|
|
dec si
|
|
|
|
|
jmp @@finishloading
|
|
|
|
|
@@finishdepands:
|
|
|
|
|
ret
|
|
|
|
|
@@notace:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
@@error:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
@@depandserror:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbloadsection
|
|
|
|
|
|
2004-11-19 18:19:05 +01:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Initialise les blocs de m<>moire en prenant memorystart pour segment de base
|
|
|
|
|
PROC mbinit FAR
|
|
|
|
|
USES ax,cx,si,di,ds,es
|
|
|
|
|
cmp [cs:firstmb],0
|
|
|
|
|
jne @@alreadyok
|
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
mov [cs:firstmb],memorystart
|
|
|
|
|
mov ax,memorystart-2
|
|
|
|
|
mov es,ax
|
|
|
|
|
mov si,offset afree
|
|
|
|
|
xor di,di
|
|
|
|
|
mov cx,size mb
|
|
|
|
|
rep movsb
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
@@alreadyok:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbinit
|
2004-11-19 18:19:05 +01:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
afree mb <"HN",0,0,0,0A000h-memorystart,"Libre">
|
|
|
|
|
db 0
|
|
|
|
|
|
|
|
|
|
;Cre<72>r un bloc de nom %0 de taille %1 (octets) -> n<>segment dans AX
|
|
|
|
|
PROC mbcreate FAR
|
|
|
|
|
ARG @blocks:word,@size:word
|
|
|
|
|
USES bx,cx,dx,si,di,ds,es
|
|
|
|
|
push gs
|
|
|
|
|
mov gs,[ss:bp+4]
|
|
|
|
|
mov cx,[@size]
|
|
|
|
|
shr cx,4
|
|
|
|
|
inc cx
|
|
|
|
|
mov bx,[cs:firstmb]
|
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
|
|
|
|
mov dl,true
|
|
|
|
|
@@searchfree:
|
|
|
|
|
cmp dl,false
|
|
|
|
|
je @@notenougtmem
|
|
|
|
|
mov es,bx
|
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
|
|
|
|
cmp [es:mb.isnotlast],true
|
|
|
|
|
sete dl
|
|
|
|
|
cmp [es:mb.reference],free
|
|
|
|
|
jne @@notsogood
|
|
|
|
|
mov ax,[es:mb.sizes]
|
|
|
|
|
cmp cx,ax
|
|
|
|
|
ja @@notsogood
|
|
|
|
|
;mov [word ptr es:mb.check],"NH"
|
|
|
|
|
mov [es:mb.isnotlast],true
|
|
|
|
|
mov [es:mb.reference],gs
|
|
|
|
|
mov [es:mb.isresident],false
|
|
|
|
|
lea di,[es:mb.names]
|
|
|
|
|
push cx
|
|
|
|
|
mov cx,24/4
|
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
mov si,[@blocks]
|
|
|
|
|
cld
|
|
|
|
|
rep movsd
|
|
|
|
|
pop cx
|
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
|
|
|
|
sub ax,cx
|
|
|
|
|
cmp ax,0
|
|
|
|
|
je @@nofree
|
|
|
|
|
dec ax
|
|
|
|
|
dec ax
|
|
|
|
|
mov [es:mb.sizes],cx
|
|
|
|
|
add cx,bx
|
|
|
|
|
mov es,cx
|
|
|
|
|
mov si,offset afree
|
|
|
|
|
xor di,di
|
|
|
|
|
mov cx,size mb
|
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov [es:mb.isnotlast],dl
|
|
|
|
|
mov [es:mb.sizes],ax
|
|
|
|
|
@@nofree:
|
|
|
|
|
mov ax,bx
|
|
|
|
|
clc
|
|
|
|
|
pop gs
|
|
|
|
|
ret
|
|
|
|
|
@@notsogood:
|
2004-11-19 18:19:05 +01:00
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
add bx,[es:mb.sizes]
|
|
|
|
|
jmp @@searchfree
|
|
|
|
|
@@memoryerror:
|
|
|
|
|
stc
|
|
|
|
|
pop gs
|
|
|
|
|
ret
|
|
|
|
|
@@notenougtmem:
|
|
|
|
|
pop gs
|
2004-11-19 18:19:05 +01:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
endp mbcreate
|
2004-11-19 18:19:05 +01:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Lib<69>re le bloc de m<>moire %0 et ses sous blocs
|
|
|
|
|
PROC mbfree FAR
|
|
|
|
|
ARG @blocks:word
|
|
|
|
|
USES ax,bx,cx,si,di,ds,es
|
|
|
|
|
mov bx,[@blocks]
|
|
|
|
|
mov ax,bx
|
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
|
|
|
|
mov es,bx
|
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
|
|
|
|
cmp [es:mb.reference],free
|
|
|
|
|
je @@wasfree
|
|
|
|
|
cmp [es:mb.isresident],true
|
|
|
|
|
je @@wasresident
|
|
|
|
|
mov [es:mb.reference],free
|
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
mov si,offset @@isfree
|
|
|
|
|
lea di,[es:mb.names]
|
|
|
|
|
mov cx,6
|
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov bx,[cs:firstmb]
|
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
|
|
|
|
@@searchtofree:
|
|
|
|
|
mov es,bx
|
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
|
|
|
|
add bx,[es:mb.sizes]
|
|
|
|
|
cmp [es:mb.sizes],0
|
|
|
|
|
je @@nottofree
|
|
|
|
|
cmp ax,[es:mb.reference]
|
|
|
|
|
jne @@nottofree
|
|
|
|
|
mov [es:mb.isresident],false
|
|
|
|
|
mov [es:mb.reference],free
|
|
|
|
|
mov cx,6
|
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
@@nottofree:
|
|
|
|
|
cmp [es:mb.isnotlast],true
|
|
|
|
|
je @@searchtofree
|
|
|
|
|
call mbclean
|
|
|
|
|
ret
|
|
|
|
|
@@memoryerror:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
@@wasfree:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
@@wasresident:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
@@isfree db "libre",0
|
|
|
|
|
endp mbfree
|
2004-11-19 18:19:05 +01:00
|
|
|
|
|
2004-11-03 01:32:19 +01:00
|
|
|
|
;Mise a nivo de la m<>moire (jonction de blocs libre)
|
2007-03-13 21:56:55 +01:00
|
|
|
|
PROC mbclean FAR
|
|
|
|
|
USES ax,bx,dx,es,gs
|
|
|
|
|
mov bx,[cs:firstmb]
|
2004-11-03 01:32:19 +01:00
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
|
|
|
|
xor ax,ax
|
|
|
|
|
xor dx,dx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@searchfree:
|
2004-11-03 01:32:19 +01:00
|
|
|
|
mov gs,bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
cmp [word ptr gs:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
2004-11-03 01:32:19 +01:00
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
add bx,[gs:mb.sizes]
|
|
|
|
|
cmp [word ptr gs:mb.sizes],0
|
|
|
|
|
je @@notenougtmem
|
|
|
|
|
cmp [gs:mb.reference],free
|
|
|
|
|
jne @@notfree
|
2004-11-03 01:32:19 +01:00
|
|
|
|
cmp ax,0
|
2007-03-13 21:56:55 +01:00
|
|
|
|
je @@notmeetfree
|
|
|
|
|
add dx,[gs:mb.sizes]
|
|
|
|
|
mov [word ptr gs:mb.check],0
|
|
|
|
|
mov [dword ptr gs:mb.names],0
|
2004-11-03 01:32:19 +01:00
|
|
|
|
inc dx
|
|
|
|
|
inc dx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
jmp @@nottrigered
|
|
|
|
|
@@notmeetfree:
|
2004-11-03 01:32:19 +01:00
|
|
|
|
xor dx,dx
|
|
|
|
|
mov ax,gs
|
2007-03-13 21:56:55 +01:00
|
|
|
|
jmp @@nottrigered
|
|
|
|
|
@@notfree:
|
2004-11-03 01:32:19 +01:00
|
|
|
|
cmp ax,0
|
2007-03-13 21:56:55 +01:00
|
|
|
|
je @@nottrigered
|
2004-11-03 01:32:19 +01:00
|
|
|
|
mov es,ax
|
2007-03-13 21:56:55 +01:00
|
|
|
|
add [es:mb.sizes],dx
|
2004-11-03 01:32:19 +01:00
|
|
|
|
xor ax,ax
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@nottrigered:
|
|
|
|
|
cmp [gs:mb.isnotlast],true
|
|
|
|
|
je @@searchfree
|
2004-11-03 01:32:19 +01:00
|
|
|
|
cmp ax,0
|
2007-03-13 21:56:55 +01:00
|
|
|
|
je @@reallyfinish
|
2004-11-03 01:32:19 +01:00
|
|
|
|
mov es,ax
|
2007-03-13 21:56:55 +01:00
|
|
|
|
add [es:mb.sizes],dx
|
|
|
|
|
mov [es:mb.isnotlast],false
|
|
|
|
|
@@reallyfinish:
|
2004-11-03 01:32:19 +01:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@notenougtmem:
|
2004-11-03 01:32:19 +01:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@memoryerror:
|
2004-06-12 23:34:04 +02:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
endp mbclean
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Rend le segment %0 r<>sident
|
|
|
|
|
PROC mbresident FAR
|
|
|
|
|
ARG @blocks:word
|
|
|
|
|
USES bx,es
|
|
|
|
|
mov bx,[@blocks]
|
|
|
|
|
dec bx
|
2004-10-29 18:32:48 +02:00
|
|
|
|
dec bx
|
2004-06-12 23:34:04 +02:00
|
|
|
|
mov es,bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
|
|
|
|
mov [es:mb.isresident],true
|
2004-10-29 20:22:55 +02:00
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@memoryerror:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbresident
|
2004-10-31 12:45:46 +01:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Rend le segment %0 non r<>sident
|
|
|
|
|
PROC mbnonresident FAR
|
|
|
|
|
ARG @blocks:word
|
|
|
|
|
USES bx,es
|
|
|
|
|
mov bx,[@blocks]
|
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
|
|
|
|
mov es,bx
|
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
|
|
|
|
mov [es:mb.isresident],false
|
|
|
|
|
ret
|
|
|
|
|
@@memoryerror:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbnonresident
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;Change le proprietaire de %0 a %1
|
|
|
|
|
PROC mbchown FAR
|
|
|
|
|
ARG @blocks:word,@owner:word
|
|
|
|
|
USES bx,dx,es
|
|
|
|
|
mov bx,[@blocks]
|
2004-10-31 12:45:46 +01:00
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
|
|
|
|
mov es,bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
|
|
|
|
cmp [es:mb.reference],free
|
|
|
|
|
je @@wasfree
|
|
|
|
|
mov dx,[@owner]
|
|
|
|
|
mov [es:mb.reference],dx
|
|
|
|
|
ret
|
|
|
|
|
@@memoryerror:
|
|
|
|
|
stc
|
2004-10-31 12:45:46 +01:00
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@wasfree:
|
2004-10-31 12:45:46 +01:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
endp mbchown
|
2004-10-31 12:45:46 +01:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Alloue un bloc /data de CX caractere pour le process appelant -> ax
|
|
|
|
|
PROC mballoc FAR
|
|
|
|
|
ARG @size:word
|
|
|
|
|
USES ax,si,ds
|
2004-11-02 22:54:19 +01:00
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
2007-03-13 21:56:55 +01:00
|
|
|
|
call mbcreate,offset @@data,[@size]
|
|
|
|
|
call mbchown,ax,[word ptr ss:bp+4]
|
2004-11-02 22:54:19 +01:00
|
|
|
|
ret
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@data db '/data',0
|
|
|
|
|
endp mballoc
|
|
|
|
|
|
|
|
|
|
;Renvoie en AX le MB n<> %0 carry quand termin<69>
|
|
|
|
|
PROC mbget FAR
|
|
|
|
|
ARG @num:word
|
|
|
|
|
USES bx,dx,es
|
|
|
|
|
mov bx,[cs:firstmb]
|
2004-10-29 20:22:55 +02:00
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
|
|
|
|
xor dx,dx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@searchfree:
|
|
|
|
|
mov es,bx
|
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
2004-10-29 20:22:55 +02:00
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
add bx,[es:mb.sizes]
|
|
|
|
|
cmp [es:mb.sizes],0
|
|
|
|
|
je @@memoryerror
|
|
|
|
|
cmp dx,[@num]
|
|
|
|
|
je @@foundmcb
|
|
|
|
|
ja @@notfound
|
2004-10-29 20:22:55 +02:00
|
|
|
|
inc dx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
cmp [es:mb.isnotlast],true
|
|
|
|
|
je @@searchfree
|
|
|
|
|
@@memoryerror:
|
2004-10-29 20:22:55 +02:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@foundmcb:
|
|
|
|
|
mov ax,es
|
|
|
|
|
inc ax
|
|
|
|
|
inc ax
|
2004-10-29 20:22:55 +02:00
|
|
|
|
clc
|
2007-03-13 21:56:55 +01:00
|
|
|
|
ret
|
|
|
|
|
@@notfound:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbget
|
2004-10-31 10:31:20 +01:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Renvoie en AX le MCB qui correspond a ds:%0
|
|
|
|
|
PROC mbfind FAR
|
|
|
|
|
ARG @blocks:word
|
|
|
|
|
USES bx,si,di,es
|
|
|
|
|
mov bx,[cs:firstmb]
|
2004-10-31 10:31:20 +01:00
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
mov si,[@blocks]
|
|
|
|
|
lea di,[es:mb.names]
|
|
|
|
|
@@search:
|
|
|
|
|
mov es,bx
|
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
2004-10-31 10:31:20 +01:00
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
add bx,[es:mb.sizes]
|
|
|
|
|
cmp [es:mb.sizes],0
|
|
|
|
|
je @@memoryerror
|
2004-10-31 10:31:20 +01:00
|
|
|
|
push si di
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@cmpnames:
|
|
|
|
|
mov al,[es:di]
|
|
|
|
|
cmp al,[ds:si]
|
|
|
|
|
jne @@ok
|
2004-10-31 10:31:20 +01:00
|
|
|
|
cmp al,0
|
2007-03-13 21:56:55 +01:00
|
|
|
|
je @@ok
|
2004-10-31 10:31:20 +01:00
|
|
|
|
inc si
|
|
|
|
|
inc di
|
2007-03-13 21:56:55 +01:00
|
|
|
|
jmp @@cmpnames
|
|
|
|
|
@@ok:
|
2004-10-31 10:31:20 +01:00
|
|
|
|
pop di si
|
2007-03-13 21:56:55 +01:00
|
|
|
|
je @@foundmcb
|
|
|
|
|
cmp [es:mb.isnotlast],true
|
|
|
|
|
je @@search
|
|
|
|
|
@@notfound:
|
2004-10-31 10:31:20 +01:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@memoryerror:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
@@foundmcb:
|
|
|
|
|
mov ax,es
|
|
|
|
|
inc ax
|
|
|
|
|
inc ax
|
2004-10-31 10:31:20 +01:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
endp mbfind
|
|
|
|
|
|
2004-10-31 10:31:20 +01:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
;Renvoie en AX le sous mcb qui correspond a %0 et qui appartien a %1
|
|
|
|
|
PROC mbfindsb FAR
|
|
|
|
|
ARG @blocks:word,@owner:word
|
|
|
|
|
USES bx,dx,si,di,es
|
|
|
|
|
mov bx,[cs:firstmb]
|
2004-11-03 23:30:09 +01:00
|
|
|
|
dec bx
|
|
|
|
|
dec bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
mov si,[@blocks]
|
|
|
|
|
lea di,[es:mb.names]
|
|
|
|
|
mov dx,[@owner]
|
|
|
|
|
@@search:
|
|
|
|
|
mov es,bx
|
|
|
|
|
cmp [word ptr es:mb.check],"NH"
|
|
|
|
|
jne @@memoryerror
|
2004-11-03 23:30:09 +01:00
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
add bx,[es:mb.sizes]
|
|
|
|
|
cmp [es:mb.sizes],0
|
|
|
|
|
je @@memoryerror
|
2004-11-03 23:30:09 +01:00
|
|
|
|
push si di
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@cmpnames:
|
|
|
|
|
mov al,[es:di]
|
|
|
|
|
cmp al,[ds:si]
|
|
|
|
|
jne @@ok
|
2004-11-03 23:30:09 +01:00
|
|
|
|
cmp al,0
|
2007-03-13 21:56:55 +01:00
|
|
|
|
je @@ok
|
2004-11-03 23:30:09 +01:00
|
|
|
|
inc si
|
|
|
|
|
inc di
|
2007-03-13 21:56:55 +01:00
|
|
|
|
jmp @@cmpnames
|
|
|
|
|
@@ok:
|
2004-11-03 23:30:09 +01:00
|
|
|
|
pop di si
|
2007-03-13 21:56:55 +01:00
|
|
|
|
jne @@notfoundmcb
|
|
|
|
|
cmp [es:mb.reference],dx
|
|
|
|
|
je @@foundmcb
|
|
|
|
|
@@notfoundmcb:
|
|
|
|
|
cmp [es:mb.isnotlast],true
|
|
|
|
|
je @@search
|
|
|
|
|
@@notfound:
|
2004-11-03 23:30:09 +01:00
|
|
|
|
stc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@foundmcb:
|
|
|
|
|
mov ax,es
|
|
|
|
|
inc ax
|
|
|
|
|
inc ax
|
2004-06-12 23:34:04 +02:00
|
|
|
|
clc
|
|
|
|
|
ret
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@memoryerror:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbfindsb
|
|
|
|
|
|
|
|
|
|
;Resouds les d<>pendances du bloc de m<>moire %0
|
|
|
|
|
PROC mbloadfuncs FAR
|
|
|
|
|
ARG @blocks:word
|
|
|
|
|
USES ax,bx,cx,dx,si,ds
|
|
|
|
|
mov ds,[@blocks]
|
|
|
|
|
cmp [word ptr 0],"EC"
|
|
|
|
|
jne @@notace
|
|
|
|
|
mov si,[ds:exe.imports]
|
|
|
|
|
cmp si,0
|
|
|
|
|
je @@endofloading
|
|
|
|
|
@@loadfuncs:
|
|
|
|
|
cmp [word ptr si],0
|
|
|
|
|
je @@endofloading
|
|
|
|
|
call mbsearchfunc,si
|
|
|
|
|
jnc @@toendoftext
|
|
|
|
|
mov bx,si
|
|
|
|
|
@@findend:
|
2004-10-29 18:32:48 +02:00
|
|
|
|
inc bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
cmp [byte ptr bx], ':'
|
|
|
|
|
jne @@findend
|
|
|
|
|
mov [byte ptr bx],0
|
|
|
|
|
;call projectfile,bx
|
|
|
|
|
jc @@erroronload
|
|
|
|
|
mov [byte ptr bx],':'
|
|
|
|
|
call mbsearchfunc,si
|
|
|
|
|
jc @@libnotexist
|
|
|
|
|
@@toendoftext:
|
|
|
|
|
mov cl,[si]
|
|
|
|
|
cmp cl,0
|
|
|
|
|
je @@oktonext
|
|
|
|
|
inc si
|
|
|
|
|
jmp @@toendoftext
|
|
|
|
|
@@oktonext:
|
|
|
|
|
inc si
|
|
|
|
|
mov [si],ax
|
|
|
|
|
mov [si+2],dx
|
|
|
|
|
add si,4
|
|
|
|
|
jmp @@loadfuncs
|
|
|
|
|
@@endofloading:
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
@@notace:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
@@libnotexist:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
@@erroronload:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbloadfuncs
|
2004-06-12 23:34:04 +02:00
|
|
|
|
|
2007-03-13 21:56:55 +01:00
|
|
|
|
|
|
|
|
|
;Recherche une fonction point<6E> par DS:SI en m<>moire et renvoie son adresse en DX:AX
|
|
|
|
|
PROC mbsearchfunc FAR
|
|
|
|
|
ARG @func:word
|
|
|
|
|
USES bx,si,di,es
|
|
|
|
|
mov bx,[@func]
|
|
|
|
|
push bx
|
|
|
|
|
@@findend:
|
|
|
|
|
inc bx
|
|
|
|
|
cmp [byte ptr bx], ':'
|
|
|
|
|
jne @@findend
|
|
|
|
|
mov [byte ptr bx],0
|
|
|
|
|
call mbfind
|
|
|
|
|
mov [byte ptr bx],':'
|
|
|
|
|
jc @@notfoundattallthesb
|
|
|
|
|
mov es,ax
|
|
|
|
|
cmp [word ptr es:exe.checks],"EC"
|
|
|
|
|
jne @@notfoundattallthesb
|
|
|
|
|
mov di,[es:exe.exports]
|
|
|
|
|
inc bx
|
|
|
|
|
inc bx
|
|
|
|
|
@@functions:
|
|
|
|
|
cmp [word ptr es:di],0
|
|
|
|
|
je @@notfoundattallthesb
|
|
|
|
|
mov si,bx
|
|
|
|
|
@@cmpnamesfunc:
|
|
|
|
|
mov al,[es:di]
|
|
|
|
|
cmp al,[ds:si]
|
|
|
|
|
jne @@notfoundthesb
|
|
|
|
|
cmp al,0
|
|
|
|
|
je @@seemsok
|
|
|
|
|
inc si
|
|
|
|
|
inc di
|
|
|
|
|
jmp @@cmpnamesfunc
|
|
|
|
|
@@notfoundthesb:
|
|
|
|
|
mov al,[es:di]
|
|
|
|
|
cmp al,0
|
|
|
|
|
je @@oktonext
|
|
|
|
|
inc di
|
|
|
|
|
jmp @@notfoundthesb
|
|
|
|
|
@@oktonext:
|
|
|
|
|
inc di
|
|
|
|
|
inc di
|
|
|
|
|
inc di
|
|
|
|
|
jmp @@functions
|
|
|
|
|
@@seemsok:
|
|
|
|
|
mov dx,es
|
|
|
|
|
mov ax,[es:di+1]
|
|
|
|
|
clc
|
|
|
|
|
ret
|
|
|
|
|
@@notfoundattallthesb:
|
|
|
|
|
stc
|
|
|
|
|
ret
|
|
|
|
|
endp mbsearchfunc
|