fix: mise à jour du code pour compilation sur LZASM en stdcall Déclaration des imports et exports en utilisant les macros Changement de lettre pour désignation de chaîne dans la fonction "checksyntax" Utilisation de "str0.lib" plutôt qu'une inclusion de code Correction de quelques bogues dans l'application des couleurs

This commit is contained in:
Nicolas Hordé 2007-03-23 16:31:09 +00:00
parent 48fd1d4ca3
commit a733711bc2
1 changed files with 194 additions and 225 deletions

View File

@ -1,50 +1,43 @@
.model tiny model tiny,stdcall
.486 p586N
smart locals
.code jumps
codeseg
option procalign:byte
include "..\include\fat.h"
include "..\include\mem.h"
include "..\include\divers.h"
org 0h org 0h
include ..\include\fat.h
include ..\include\mem.h
include ..\include\divers.h
start: start:
header exe <,1,0,,,offset imports,,> header exe <,1,0,,,offset imports,,offset realstart>
realstart: realstart:
push offset msginit call [cs:print],offset msginit
call [print]
xor bp,bp xor bp,bp
mov dl,' '
call setdelimiter0
replay: replay:
mov ah,6 call [cs:addline]
int 47h
noret: noret:
mov ah,6 call [cs:addline]
int 47h
mov ah,16
mov di,offset dir mov di,offset dir
int 48h call [cs:getdir],di
push offset prompt call [cs:print],di
call [print] call [cs:print],offset prompt
mov di,offset buffer mov di,offset buffer
waitchar: waitchar:
mov ax,0 xor ax,ax
int 16h int 16h
call convertfr call convertfr
cmp ah,59 cmp ah,59
jne norr jne norr
cmp bp,0 cmp bp,0
je waitchar je waitchar
push word ptr cs: [bp-8] call [print],[word ptr cs: bp]
call [print] call [copy],[word ptr cs: bp],di
push cs call [getlength],di
pop es add di,ax
call copy0
call getlength0
add di,cx
jmp waitchar jmp waitchar
norr: norr:
cmp al,0dh ;entrée cmp al,0dh ;entrée
@ -59,116 +52,99 @@ norr:
je waitchar je waitchar
mov [di],al mov [di],al
inc di inc di
push ax call [cs:showchar],ax
call [showchar]
jmp waitchar jmp waitchar
escape: escape:
cmp di,offset buffer cmp di,offset buffer
je waitchar je waitchar
mov ah,24 call [cs:getxy]
int 47h
mov dx,offset buffer mov dx,offset buffer
mov cx,di mov cx,di
sub cx,dx sub cx,dx
js waitchar js waitchar
je waitchar je waitchar
sub bh,cl sub ah,cl
mov ah,25 mov cl,ah
int 47h xor ah,ah
xor ch,ch
call [cs:setxy],cx,ax
mov di,offset buffer mov di,offset buffer
mov byte ptr [di],0 mov [byte ptr di],0
jmp waitchar
backspace: backspace:
cmp di,offset buffer cmp di,offset buffer
je waitchar je waitchar
mov ah,24 call [cs:getxy]
int 47h dec ah
dec bh mov cl,ah
mov ah,25 xor ah,ah
int 47h xor ch,ch
push ' ' call [cs:setxy],cx,ax
call [showchar] call [cs:showchar],' '
mov ah,25 call [cs:setxy],cx,ax
int 47h
dec di dec di
mov byte ptr [di],0 mov [byte ptr di],0
jmp waitchar jmp waitchar
entere: entere:
mov byte ptr [di],0 mov [byte ptr di],0
mov si,offset buffer cmp di,offset buffer
cmp si,di
je noret je noret
mov ah,6 mov si,offset temp
int 47h call [cs:addline]
push cs call [cs:getitem],offset buffer,si,0,' '
pop es call [cs:uppercase],si
mov di,offset buffer2
xor cx,cx
call getitem0
mov si,di
call uppercase0
mov bx,offset commands mov bx,offset commands
xor bp,bp xor bp,bp
xor dx,dx
tre: tre:
mov di,[bx] mov di,[bx]
add bx,8
cmp di,0 cmp di,0
je error je error
push cs call [cs:evalue],si,di
pop es cmp ax,dx
call evalue0
cmp dx,bp
jb noadd jb noadd
mov bp,dx mov dx,ax
mov ax,bx mov bp,bx
noadd: noadd:
call cmpstr0 call [cs:cmpstr],si,di
jne tre je strisok
mov si,offset buffer add bx,8
mov di,offset buffer2 jmp tre
call copy0 strisok:
mov si,di mov di,offset temp
call uppercase0 call [cs:copy],offset buffer,di
call [cs:uppercase],di
xor cx,cx xor cx,cx
inc cx inc cx
call getpointeritem0 call [cs:getpointeritem],di,cx,' '
cmp byte ptr [di-1],0 mov di,ax
cmp [byte ptr di-1],0
jne nopod jne nopod
mov byte ptr [di],0 mov [byte ptr di],0
nopod: nopod:
mov si,di call [cs:checksyntax],di,[word ptr bx+4],' '
mov di,[bx-4]
call checksyntax0
jc errorprec jc errorprec
mov bx,[bx-6] mov bx,[bx+2]
call bx call bx
jmp replay jmp replay
error: error:
mov bp,ax
push cs
pop es
mov dl,'.'
call searchchar0
je noaddext
mov di,offset buffer mov di,offset buffer
mov si,offset extcom call [cs:searchchar],di,'.'
call concat0 je noaddext
call [cs:concat],offset extcom,di
noaddext: noaddext:
mov si,offset buffer call [cs:execfile],di
mov ah,18
int 48h
jc reallyerror jc reallyerror
xor bp,bp xor bp,bp
jmp replay jmp replay
reallyerror: reallyerror:
push [word ptr cs: bp]
push offset error_syntax push offset error_syntax
call [print] call [cs:print]
push word ptr cs: [bp-8]
call [print]
jmp replay jmp replay
errorprec: errorprec:
push offset derror push offset derror
call [print] call [cs:print]
jmp replay jmp replay
code_exit: code_exit:
@ -176,15 +152,13 @@ code_exit:
retf retf
code_version: code_version:
push offset version_text call [cs:print],offset version_text
call [print]
ret ret
version_text db 'Cos 2000 version 1.4Fr par \c04MrNop',0 version_text db 'Cos 2000 version 1.4Fr par \c04MrNop',0
code_cls: code_cls:
mov ah,2 call [cs:clearscreen]
int 47h
ret ret
code_reboot: code_reboot:
@ -193,69 +167,59 @@ code_reboot:
retf retf
code_command: code_command:
push offset def call [cs:print],offset def
call [print]
mov bx,offset commands mov bx,offset commands
showalls: showalls:
push [word ptr bx+4]
push [word ptr bx+6]
push [word ptr bx]
call [cs:print],offset commandes
add bx,8 add bx,8
cmp word ptr [bx],0 cmp [word ptr bx],0
je endoff jne showalls
push word ptr [bx+4] endoff:
push word ptr [bx+6]
push word ptr [bx]
push offset commandes
call [print]
jmp showalls
endoff:
ret ret
def db 'Liste des commandes internes\l\l',0 def db 'Liste des commandes internes\l\l',0
commandes db '%0 \h10:\h12%0 \h70%0\l',0 commandes db '%0 \h10:\h12%0 \h70%0\l',0
code_mode: code_mode:
mov cx,0 call [cs:gettypeditem],di,0,' '
call gettypeditem0
mov ah,0
mov al,dl
and al,1111b and al,1111b
int 47h call [cs:setvideomode],ax
mov ah,2 call [cs:clearscreen]
int 47h
ret ret
code_dir: code_dir:
mov ah,12 call [cs:getserial]
int 48h push eax
push edx mov si,offset nomdisque
mov ah,11 call [cs:getname],si
mov di,offset nomdisque push si
int 48h
push di
push offset present push offset present
call [print] call [cs:print]
xor bp,bp xor ecx,ecx
mov di,offset bufferentry mov di,offset bufferentry
mov ah,7 call [cs:findfirstfile],di
int 48h
jc nofiles jc nofiles
go: go:
push word ptr [di+entries.fileattr] push [word ptr (find di).result.fileattr]
push dword ptr [di+entries.filesize] push [(find di).result.filesize]
push word ptr [di+entries.filetime] push [(find di).result.filetime]
push word ptr [di+entries.filedate] push [(find di).result.filedate]
push word ptr [di+entries.filetimecrea] push [(find di).result.filetimecrea]
push word ptr [di+entries.filedatecrea] push [(find di).result.filedatecrea]
push di lea bx,[(find di).result.filename]
push bx
push offset line push offset line
call [print] call [cs:print]
inc bp inc ecx
mov ah,8 call [cs:findnextfile],di
int 48h
jnc go jnc go
nofiles: nofiles:
push ebp push ecx
push offset filess push offset filess
call [print] call [cs:print]
ret ret
nomdisque db 13 dup (0) nomdisque db 13 dup (0)
@ -263,20 +227,17 @@ bufferentry db 512 dup (0)
present db '\c02Le volume insere est nomme %0, Numero de serie : %hD\l\l',0 present db '\c02Le volume insere est nomme %0, Numero de serie : %hD\l\l',0
line db '\c07%n %d %t %d %t %z %a\l',0 line db '\c07%n %d %t %d %t %z %a\l',0
filess db '\l\l\c02%u Fichier(s) au total\l',0 filess db '\l\l\c02%u Fichier(s) au total\l\c07',0
code_cd: code_cd:
mov cx,0 call [cs:gettypeditem],di,0,' '
call gettypeditem0 push ax
push di
push offset changing push offset changing
call [print] call [cs:print]
mov si,di call [cs:changedir],ax
mov ah,13
int 48h
jnc okchange jnc okchange
push offset errorchanging push offset errorchanging
call [print] call [cs:print]
okchange: okchange:
ret ret
@ -284,21 +245,17 @@ changing db 'Changement de repertoire vers %0\l',0
errorchanging db '\c04Impossible d''atteindre ce dossier',0 errorchanging db '\c04Impossible d''atteindre ce dossier',0
code_kill: code_kill:
mov cx,0 call [cs:gettypeditem],di,0,' '
call gettypeditem0 push ax
push di
push offset killing push offset killing
call [print] call [cs:print]
mov si,di call [cs:mbfind],ax
mov ah,5
int 49h
jc nochanged jc nochanged
mov ah,1 call [cs:mbfree],ax
int 49h
jnc okchanged jnc okchanged
nochanged: nochanged:
push offset errorkilling push offset errorkilling
call [print] call [cs:print]
okchanged: okchanged:
ret ret
@ -306,87 +263,78 @@ killing db 'Fermeture du processus %0\l',0
errorkilling db '\c04Impossible de fermer ce processus',0 errorkilling db '\c04Impossible de fermer ce processus',0
code_refresh: code_refresh:
mov ah,3 call [cs:initdrive]
int 48h
jnc okrefresh jnc okrefresh
push offset errorrefreshing call [cs:print],offset errorrefreshing
call [print]
ret ret
okrefresh: okrefresh:
mov ah,12 call [cs:getserial]
int 48h push eax
push edx mov si,offset nomdisque
mov ah,11 call [cs:getname],si
mov di,offset nomdisque push si
int 48h
push di
push offset present push offset present
call [print] call [cs:print]
ret ret
errorrefreshing db '\c04Impossible de lire le support',0 errorrefreshing db '\c04Impossible de lire le support',0
extcom db '.CE',0 extcom db '.CE',0
code_mem: code_mem:
push offset msg call [cs:print],offset msg
call [print]
xor ebx,ebx xor ebx,ebx
xor cx,cx xor cx,cx
listmcb: listmcb:
mov ah,4 call [cs:mbget],cx
int 49h
jc fino jc fino
dec ax
dec ax
mov gs,ax
inc cx inc cx
;placement mémoire
mov dx,gs mov dx,gs
inc dx push edx ;Emplacement memoire hex 2
inc dx
push edx
;parent ;parent
cmp gs: [mb.reference],0 cmp [gs:mb.reference],0
jne next jne next
push cs push cs
push offset none push offset none ;parent lstr0 2x2
add bx,gs:[mb.sizes] add bx,[gs:mb.sizes]
jmp suitemn jmp suitemn
next: next:
mov dx,gs: [mb.reference] mov dx,[gs:mb.reference]
dec dx dec dx
dec dx dec dx
push dx push dx ;parent lstr0 2x2
push offset mb.names push offset (mb).names
suitemn: suitemn:
;Resident cmp [gs: mb.isresident],true
cmp gs: [mb.isresident],true
jne notresident jne notresident
push offset resident push offset resident ;resident str0 2
jmp suitelistmcb jmp suitelistmcb
notresident: notresident:
push offset nonresident push offset nonresident ;resident str0 2
suitelistmcb: suitelistmcb:
;taille memoire
xor edx,edx xor edx,edx
mov dx,gs: [mb.sizes] mov dx,[gs: mb.sizes]
shl edx,4 shl edx,4
push 6 push 6 ;decimal 4 + type 2
push edx push edx
;nom push gs ;nom lstr0 2x2
push gs push offset (mb).names
push offset mb.names push offset line2 ;ligne
push offset line2 call [cs:print]
call [print]
jmp listmcb jmp listmcb
fino: fino:
shl ebx,4 shl ebx,4
push ebx push ebx
push offset fin push offset fin
call [print] call [cs:print]
ret ret
resident db "oui",0 resident db "oui",0
nonresident db "non",0 nonresident db "non",0
line2 db "%0P\h15%w\h24%0\h30%0P\h46%hW\l",0 line2 db "%0P\h15|%w\h25|%0\h30|%0P\h46|%hW\l",0
fin db "\l\l\c02%u octets de memoire disponible\l",0 fin db "\l\l\c02%u octets de memoire disponible\l\c07",0
msg db "Plan de la memoire\l\lNom Taille Res Parent Mem\l",0 msg db "Plan de la memoire\l\lNom | Taille |Res |Parent |Mem\l",0
none db ".",0 none db ".",0
@ -395,13 +343,13 @@ convertfr:
push dx si push dx si
mov si,offset fr mov si,offset fr
searchtouch: searchtouch:
mov dx,cs: [si] mov dx,[cs: si]
cmp dx,0 cmp dx,0
je endofconv je endofconv
add si,4 add si,4
cmp dx,ax cmp dx,ax
jne searchtouch jne searchtouch
mov ax,cs: [si-2] mov ax,[cs: si-2]
endofconv: endofconv:
pop dx si pop dx si
ret ret
@ -500,12 +448,12 @@ syn_version db 0
syn_cls db 0 syn_cls db 0
syn_reboot db 0 syn_reboot db 0
syn_command db 0 syn_command db 0
syn_mode db 'FFH',0 syn_mode db 'FFh',0
syn_dir db 0 syn_dir db 0
syn_refresh db 0 syn_refresh db 0
syn_cd db '@',0 syn_cd db '?',0
syn_mem db 0 syn_mem db 0
syn_kill db '@',0 syn_kill db '?',0
help_exit db 'Permet de quitter l''interpreteur',0 help_exit db 'Permet de quitter l''interpreteur',0
help_version db 'Affiche la version de COS',0 help_version db 'Affiche la version de COS',0
@ -520,23 +468,44 @@ help_mem db 'Affiche le plan de la memoire',0
help_kill db 'Termine le processus cible',0 help_kill db 'Termine le processus cible',0
derror db '\c04Erreur de Syntaxe !',0 derror db '\c04Erreur de Syntaxe !',0
error_syntax db '\c04La commande ou l''executable n''existe pas ! F1 pour ',0 error_syntax db '\c04La commande ou l''executable n''existe pas ! F1 pour %0',0
prompt db '\c07>',0 prompt db '\c07>',0
msginit db '\m02\e\c07\l\lInterpreteur de commande COS V1.9\lSous license \c05GPL\c07 - Ecrit par \c04MrNop\l\c07Utilisez la commande CMDS pour connaitres les commandes disponibles\l',0 msginit db '\m02\e\c07\l\lInterpreteur de commande COS V1.9\lSous license \c05GPL\c07 - Ecrit par \c04MrNop\l\c07Utilisez la commande CMDS pour connaitres les commandes disponibles\l',0
include str0.asm
dir db 32 dup (0) dir db 32 dup (0)
buffer db 128 dup (0) buffer db 256 dup (0)
buffer2 db 128 dup (0) temp db 256 dup (0)
imports: importing
db "VIDEO.LIB::print",0 use VIDEO,clearscreen
print dd 0 use VIDEO,setvideomode
db "VIDEO.LIB::showhex",0 use VIDEO,getxy
showhex dd 0 use VIDEO,setxy
db "VIDEO.LIB::showchar",0 use VIDEO,addline
showchar dd 0 use VIDEO.LIB,showhex
dw 0 use VIDEO.LIB,print
use VIDEO.LIB,showchar
end start use DISQUE,getdir
use DISQUE,getserial
use DISQUE,getname
use DISQUE,findfirstfile
use DISQUE,findnextfile
use DISQUE,execfile
use DISQUE,initdrive
use DISQUE,changedir
use SYSTEME,mbget
use SYSTEME,mbfind
use SYSTEME,mbfree
use STR0.LIB,uppercase
use STR0.LIB,evalue
use STR0.LIB,copy
use STR0.LIB,checksyntax
use STR0.LIB,searchchar
use STR0.LIB,concat
use STR0.LIB,getitem
use STR0.LIB,cmpstr
use STR0.LIB,getpointeritem
use STR0.LIB,getlength
use STR0.LIB,gettypeditem
endi