home *** CD-ROM | disk | FTP | other *** search
- ;* -------------------------------------------------- *
- ;* NEWENV.ASM *
- ;* Funktion: Vergrößertes Evironment anlegen *
- ;* Compiler: Turbo Asssembler *
- ;* TASM newenv.asm /t *
- ;* -------------------------------------------------- *
- ;* (c) 1991 Christoph Seck & DMV-Verlag *
- ;* -------------------------------------------------- *
- .MODEL tiny
- .CODE
- .STARTUP
-
- ;* -------------------------------------------------- *
-
- mov bx,3 ; Eigenes Enviroment
- mov ax,[bx+29h] ; suchen.
- dec ax ;
- mov own_env,ax ; Dessen MCB merken.
- mov es,ax ; Process ID
- mov cx,es:[bx-2] ; in CX merken.
- add ax,es:[bx] ; Naechsten MCB
- inc ax ; nach DS laden.
- mov ds,ax ;
- cmp cx,[bx-2] ; Ist er der unseres
- je in_reihe ; Programms?
- cmp word ptr [bx-2],0 ; Ist es ein freier
- ; Block?
- ; Wenn nichts davon:
- mov al,'1' ; Return 1 und
- jne nach_raus ; raus.
-
- ; Freien Block ans Enviroment haengen
-
- mov cx,[bx] ; Laenge des freien
- inc cx ; Blocks+dessen MCB
- add es:[bx],cx ; kommt zur Laenge des
- push cs ; Env dazu.
- pop ds ;
- jmp short join ;
-
- ; Enviroment um PSP verlaengern
-
- in_reihe:
- push cs ;
- pop ds ;
- mov es,own_env ; Env Speicherblock
- add word ptr es:[bx],11h; um 11 vergroessern.
- mov cx,[bx-1] ; CX=Top of Memory
- mov ax,ds ; (in Paragraphen).
- sub cx,ax ; CX=Speicher hinter
- ; dem Env.
- ; Laenge des PSP soll
- sub cx,11h ; dazu kommen.
-
- ; Neuer MCB nach CS:100h:
-
- mov byte ptr [bx+0FDh],5ah ; Ist letzter MCB.
- mov word ptr [bx+0FEh],0 ; Gehoert DOS (frei)
- mov [bx+100h],cx ; Und ist 'CX' lang.
-
- join: ; Command PSP
- mov dx,word ptr[bx+13h] ; finden.
- vorne:
- mov es,dx ;
- cmp word ptr es:[bx+13h],dx ; Ist Parent PSP=PSP?
- je ende ;
- mov dx,es:[bx+13h] ;
- jmp vorne ;
- ende:
- mov bp,dx ; In BP wird die Adresse
- ; von Com's PSP
- ; gespeichert.
- mov es,dx ;
- mov ax,es:[bx+29h] ; Command Env finden
- mov com_env,ax ; (PSP:2Ch ansehen).
-
- dec dx ; Commands interne
- mov es,dx ; Env. Adresse finden:
- mov cx,es:[bx] ; CX=Laenge von Com.
- sub cx,10h ; in Paragraphen (steht
- REPT 4 ; in Com's MCB).
- shl cx,1 ; Wir brauchen Byte.
- ENDM ;
- inc dx ;
- mov es,dx ;
- mov di,100h ; Nicht im PSP suchen.
- suchen:
- cmp es:[di],ax ;
- jne war_nix ; Falls gefunden:
- cmp dx,0 ; Erster Treffer?
- je error_2 ; Wenn nicht: raus!
- mov dx,0 ; Sonst: Merken.
- mov si,di ;
- war_nix:
- inc di ;
- loop suchen ;
- cmp dx,0 ; War Suche erfolgreich?
- je gefunden ;
- error_2:
- mov al,'2' ; Return 2 und
- nach_raus:
- mov ah,0Eh ;
- int 10h ;
- sub al,'0' ;
- jmp short raus ; raus.
- gefunden:
- mov ax,own_env ; Korrigieren von Com's
- inc ax ; interner Enviroment
- mov es:[si],ax ; Adresse.
-
- mov es:[bx+29h],ax ; Neues Enviroment
- ; im command.com PSP
- ; eintragen.
- mov ax,com_env ; Com Enviroment
- mov es,ax ; freimachen.
- mov ah,49h ;
- int 21h ;
- mov ax,own_env ;
- mov es,ax ; Eigenes Env=Com Env.
- mov cx,bp ; (Process ID von
- mov es:[bx-2],cx ; Com. eintragen).
- mov al,0 ; Return 0.
-
- raus:
- mov ah,4Ch
- int 21h
-
- ;* -------------------------------------------------- *
- ; DATEN
-
- com_env dw ?
- own_env dw ?
-
- END
-
- ;* -------------------------------------------------- *
- ;* Ende von NEWENV.ASM *
-
-