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-14 12:18:58 +01:00
|
|
|
|
PROC enablea20 FAR
|
|
|
|
|
USES ax
|
|
|
|
|
mov al,0d1h
|
|
|
|
|
out 64h,al
|
|
|
|
|
call a20wait
|
|
|
|
|
mov al,0dfh
|
|
|
|
|
out 60h,al
|
|
|
|
|
call a20wait
|
|
|
|
|
;mov al,0ffh
|
|
|
|
|
;out 64h,al
|
|
|
|
|
;call a20wait
|
|
|
|
|
ret
|
|
|
|
|
endp enablea20
|
|
|
|
|
|
|
|
|
|
PROC disablea20 FAR
|
|
|
|
|
USES ax
|
|
|
|
|
mov al,0d1h
|
|
|
|
|
out 64h,al
|
|
|
|
|
call a20wait
|
|
|
|
|
mov al,0DDh
|
|
|
|
|
out 60h,al
|
|
|
|
|
call a20wait
|
|
|
|
|
;mov al,0ffh
|
|
|
|
|
;out 64h,al
|
|
|
|
|
;call a20wait
|
|
|
|
|
ret
|
|
|
|
|
endp disablea20
|
|
|
|
|
|
|
|
|
|
a20wait:
|
|
|
|
|
in al,64h
|
|
|
|
|
jmp @@suite
|
|
|
|
|
@@suite:
|
|
|
|
|
and al,2
|
|
|
|
|
jnz a20wait
|
|
|
|
|
ret
|
|
|
|
|
;par le system control port A
|
|
|
|
|
;in al,92h
|
|
|
|
|
;or al,2
|
|
|
|
|
;out 92h,al
|
|
|
|
|
|
|
|
|
|
;par le system control port A
|
|
|
|
|
;in al,92h
|
|
|
|
|
;and al,not 2
|
|
|
|
|
;out 92h,al
|
|
|
|
|
|
|
|
|
|
PROC flatmode FAR
|
|
|
|
|
USES eax,bx,ds
|
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
; first, calculate the linear address of GDT
|
|
|
|
|
xor eax,eax
|
|
|
|
|
mov ax,ds
|
|
|
|
|
shl eax,4
|
|
|
|
|
add [dword ptr offset @@gdt+2],eax ; store as GDT linear base addr
|
|
|
|
|
; now load the GDT into the GDTR
|
|
|
|
|
lgdt [fword ptr offset @@gdt] ; load GDT base
|
|
|
|
|
mov bx,1 * size descriptor ; point to first descriptor
|
|
|
|
|
cli ; turn off interrupts
|
|
|
|
|
mov eax,cr0 ; prepare to enter protected mode
|
|
|
|
|
or al,1 ; flip the PE bit
|
|
|
|
|
mov cr0,eax ; we're now in protected mode
|
|
|
|
|
jmp @@suite
|
|
|
|
|
@@suite:
|
|
|
|
|
mov fs,bx ; load the FS segment register
|
|
|
|
|
and al,0FEh ; clear the PE bit again
|
|
|
|
|
mov cr0,eax ; back to real mode
|
|
|
|
|
jmp @@suite2
|
|
|
|
|
@@suite2:
|
|
|
|
|
sti ; resume handling interrupts
|
|
|
|
|
ret ;
|
2007-03-13 21:56:55 +01:00
|
|
|
|
|
2007-03-14 12:18:58 +01:00
|
|
|
|
@@gdt descriptor <offset @@gdtend - offset @@gdt - 1, offset @@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
|
2007-03-27 16:54:21 +02:00
|
|
|
|
USES ax
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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]
|
|
|
|
|
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]
|
2007-03-18 21:44:40 +01:00
|
|
|
|
cmp bx,0
|
|
|
|
|
je @@finishloading
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@loading:
|
|
|
|
|
cmp [dword ptr bx],0
|
|
|
|
|
je @@finishloading
|
|
|
|
|
mov ax,bx
|
|
|
|
|
add ax,4
|
2007-03-14 12:18:58 +01:00
|
|
|
|
pushad
|
|
|
|
|
call biosprint,ax
|
|
|
|
|
popad
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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:
|
|
|
|
|
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
|
2007-03-27 12:22:47 +02:00
|
|
|
|
mov ax,[ss:bp+4]
|
|
|
|
|
mov dx,ax
|
|
|
|
|
dec dx
|
|
|
|
|
dec dx
|
|
|
|
|
mov gs,dx
|
|
|
|
|
cmp [word ptr gs:0x0],'NH'
|
|
|
|
|
je @@oktoset
|
|
|
|
|
mov ax,memorystart
|
|
|
|
|
@@oktoset:
|
|
|
|
|
mov gs,ax
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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
|
2007-03-14 12:18:58 +01:00
|
|
|
|
sete dl
|
2007-03-13 21:56:55 +01:00
|
|
|
|
cmp [es:mb.reference],free
|
|
|
|
|
jne @@notsogood
|
|
|
|
|
mov ax,[es:mb.sizes]
|
|
|
|
|
cmp cx,ax
|
|
|
|
|
ja @@notsogood
|
2007-03-14 12:18:58 +01:00
|
|
|
|
mov [word ptr es:mb.check],"NH"
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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
|
|
|
|
|
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
|
2007-03-14 12:18:58 +01:00
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
2007-03-13 21:56:55 +01:00
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
mov [es:mb.isnotlast],dl
|
|
|
|
|
mov [es:mb.sizes],ax
|
|
|
|
|
@@nofree:
|
|
|
|
|
mov ax,bx
|
|
|
|
|
pop gs
|
2007-03-14 12:18:58 +01:00
|
|
|
|
clc
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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:
|
|
|
|
|
pop gs
|
2007-03-14 12:18:58 +01:00
|
|
|
|
stc
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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
|
2007-03-28 23:26:59 +02:00
|
|
|
|
mov si,offset @@isfree
|
|
|
|
|
lea di,[es:mb.names]
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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
|
2007-03-27 12:22:47 +02:00
|
|
|
|
USES 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]
|
2007-03-28 23:26:59 +02:00
|
|
|
|
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]
|
|
|
|
|
@@search:
|
|
|
|
|
mov es,bx
|
2007-03-14 12:18:58 +01:00
|
|
|
|
lea di,[es:mb.names]
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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
|
2007-03-23 17:46:35 +01:00
|
|
|
|
pushad
|
|
|
|
|
call biosprint,si
|
|
|
|
|
popad
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@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
|
2007-03-23 17:46:35 +01:00
|
|
|
|
call [cs:projfile],si
|
2007-03-13 21:56:55 +01:00
|
|
|
|
jc @@erroronload
|
|
|
|
|
mov [byte ptr bx],':'
|
2007-03-23 17:46:35 +01:00
|
|
|
|
pushad
|
|
|
|
|
call biosprint,si
|
|
|
|
|
popad
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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
|
|
|
|
|
2007-03-23 17:46:35 +01:00
|
|
|
|
;Recherche une fonction point<6E> par DS:%0 en m<>moire et renvoie son adresse en DX:AX
|
2007-03-13 21:56:55 +01:00
|
|
|
|
PROC mbsearchfunc FAR
|
|
|
|
|
ARG @func:word
|
|
|
|
|
USES bx,si,di,es
|
|
|
|
|
mov bx,[@func]
|
2007-03-23 17:46:35 +01:00
|
|
|
|
mov si,bx
|
2007-03-13 21:56:55 +01:00
|
|
|
|
@@findend:
|
|
|
|
|
inc bx
|
|
|
|
|
cmp [byte ptr bx], ':'
|
|
|
|
|
jne @@findend
|
|
|
|
|
mov [byte ptr bx],0
|
2007-03-23 17:46:35 +01:00
|
|
|
|
call mbfind,si
|
2007-03-13 21:56:55 +01:00
|
|
|
|
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
|