2007-03-23 17:31:09 +01:00
model tiny , stdcall
p586N
locals
jumps
codeseg
option procalign : byte
2004-06-12 23:34:04 +02:00
2007-03-23 17:31:09 +01:00
include "..\include\fat.h"
include "..\include\mem.h"
include "..\include\divers.h"
2004-06-12 23:34:04 +02:00
2007-03-23 17:31:09 +01:00
org 0h
2004-06-12 23:34:04 +02:00
start:
2007-03-23 17:31:09 +01:00
header exe < , 1 , 0 ,,, offset imports ,, offset realstart >
2004-11-29 23:41:00 +01:00
realstart:
2007-03-23 17:31:09 +01:00
call [ cs : print ], offset msginit
2004-06-12 23:34:04 +02:00
xor bp , bp
replay:
2007-03-23 17:31:09 +01:00
call [ cs : addline ]
2004-06-12 23:34:04 +02:00
noret:
2007-03-23 17:31:09 +01:00
call [ cs : addline ]
2004-11-30 20:30:30 +01:00
mov di , offset di r
2007-03-23 17:31:09 +01:00
call [ cs : getdir ], di
call [ cs : print ], di
call [ cs : print ], offset prompt
2004-06-12 23:34:04 +02:00
mov di , offset buffer
waitchar:
2007-03-23 17:31:09 +01:00
xor ax , ax
2004-06-12 23:34:04 +02:00
int 16h
2004-11-11 18:03:41 +01:00
call convertfr
2004-06-12 23:34:04 +02:00
cmp ah , 59
jne norr
cmp bp , 0
je waitchar
2007-03-23 17:31:09 +01:00
call [ print ],[ word ptr cs : bp ]
call [ copy ],[ word ptr cs : bp ], di
call [ getlength ], di
add di , ax
2004-06-12 23:34:04 +02:00
jmp waitchar
norr:
2004-11-30 20:30:30 +01:00
cmp al , 0dh ;entr<74> e
2004-06-12 23:34:04 +02:00
je entere
2004-11-30 20:30:30 +01:00
cmp al , 08h ;backspace
2004-11-10 17:50:43 +01:00
je backspace
2004-11-30 20:30:30 +01:00
cmp al , 27 ;echap
2004-11-10 17:50:43 +01:00
je es cape
2004-11-10 12:54:51 +01:00
cmp al , ' '
jb waitchar
2004-06-12 23:34:04 +02:00
cmp di , offset buffer + 256
je waitchar
mov [ di ], al
inc di
2007-03-23 17:31:09 +01:00
call [ cs : showchar ], ax
2004-06-12 23:34:04 +02:00
jmp waitchar
2004-11-10 17:50:43 +01:00
escape:
cmp di , offset buffer
je waitchar
2007-03-23 17:31:09 +01:00
call [ cs : getxy ]
2004-11-10 17:50:43 +01:00
mov dx , offset buffer
mov cx , di
sub cx , dx
js waitchar
je waitchar
2007-03-23 17:31:09 +01:00
sub ah , cl
mov cl , ah
xor ah , ah
xor ch , ch
call [ cs : setxy ], cx , ax
2004-11-10 17:50:43 +01:00
mov di , offset buffer
2007-03-23 17:31:09 +01:00
mov [ byte ptr di ], 0
jmp waitchar
2004-11-10 17:50:43 +01:00
backspace:
cmp di , offset buffer
je waitchar
2007-03-23 17:31:09 +01:00
call [ cs : getxy ]
dec ah
mov cl , ah
xor ah , ah
xor ch , ch
call [ cs : setxy ], cx , ax
call [ cs : showchar ], ' '
call [ cs : setxy ], cx , ax
2004-11-10 17:50:43 +01:00
dec di
2007-03-23 17:31:09 +01:00
mov [ byte ptr di ], 0
2004-11-10 17:50:43 +01:00
jmp waitchar
2004-06-12 23:34:04 +02:00
entere:
2007-03-23 17:31:09 +01:00
mov [ byte ptr di ], 0
cmp di , offset buffer
2004-06-12 23:34:04 +02:00
je noret
2007-03-23 17:31:09 +01:00
mov si , offset temp
call [ cs : addline ]
call [ cs : getitem ], offset buffer , si , 0 , ' '
call [ cs : uppercase ], si
2004-06-12 23:34:04 +02:00
mov bx , offset commands
xor bp , bp
2007-03-23 17:31:09 +01:00
xor dx , dx
2004-06-12 23:34:04 +02:00
tre:
mov di ,[ bx ]
cmp di , 0
je error
2007-03-23 17:31:09 +01:00
call [ cs : evalue ], si , di
cmp ax , dx
2004-06-12 23:34:04 +02:00
jb noadd
2007-03-23 17:31:09 +01:00
mov dx , ax
mov bp , bx
2004-11-30 20:30:30 +01:00
noadd:
2007-03-23 17:31:09 +01:00
call [ cs : cmpstr ], si , di
je strisok
add bx , 8
jmp tre
strisok:
mov di , offset temp
call [ cs : copy ], offset buffer , di
call [ cs : uppercase ], di
2004-06-12 23:34:04 +02:00
xor cx , cx
inc cx
2007-03-23 17:31:09 +01:00
call [ cs : getpointeritem ], di , cx , ' '
mov di , ax
cmp [ byte ptr di - 1 ], 0
2004-06-12 23:34:04 +02:00
jne nopod
2007-03-23 17:31:09 +01:00
mov [ byte ptr di ], 0
2004-06-12 23:34:04 +02:00
nopod:
2007-03-23 17:31:09 +01:00
call [ cs : ch ecksyntax ], di ,[ word ptr bx + 4 ], ' '
2004-06-12 23:34:04 +02:00
jc errorprec
2007-03-23 17:31:09 +01:00
mov bx ,[ bx + 2 ]
2004-06-12 23:34:04 +02:00
call bx
jmp replay
error:
mov di , offset buffer
2007-03-23 17:31:09 +01:00
call [ cs : searchchar ], di , '.'
je noaddext
call [ cs : concat ], offset extcom , di
2004-06-12 23:34:04 +02:00
noaddext:
2007-03-23 17:31:09 +01:00
call [ cs : execfile ], di
2004-06-12 23:34:04 +02:00
jc reallyerror
xor bp , bp
jmp replay
reallyerror:
2007-03-23 17:31:09 +01:00
push [ word ptr cs : bp ]
2004-11-30 20:30:30 +01:00
push offset error_syntax
2007-03-23 17:31:09 +01:00
call [ cs : print ]
2004-06-12 23:34:04 +02:00
jmp replay
errorprec:
2004-11-29 23:41:00 +01:00
push offset derror
2007-03-23 17:31:09 +01:00
call [ cs : print ]
2004-06-12 23:34:04 +02:00
jmp replay
2004-11-30 20:30:30 +01:00
code_exit:
2004-06-12 23:34:04 +02:00
pop ax
2004-11-29 23:41:00 +01:00
retf
2004-11-30 20:30:30 +01:00
2007-03-23 17:31:09 +01:00
code_version:
call [ cs : print ], offset version_text
2004-06-12 23:34:04 +02:00
ret
2004-11-30 20:30:30 +01:00
version_text db 'Cos 2000 version 1.4Fr par \c04MrNop' , 0
code_cls:
2007-03-23 17:31:09 +01:00
call [ cs : cl earscreen ]
2004-06-12 23:34:04 +02:00
ret
2004-11-30 20:30:30 +01:00
code_reboot:
push 0ffffh
2004-06-12 23:34:04 +02:00
push 00000h
2004-11-30 20:30:30 +01:00
retf
2007-03-23 17:31:09 +01:00
code_command:
call [ cs : print ], offset def
2004-06-12 23:34:04 +02:00
mov bx , offset commands
showalls:
2007-03-23 17:31:09 +01:00
push [ word ptr bx + 4 ]
push [ word ptr bx + 6 ]
push [ word ptr bx ]
call [ cs : print ], offset commandes
2004-06-12 23:34:04 +02:00
add bx , 8
2007-03-23 17:31:09 +01:00
cmp [ word ptr bx ], 0
jne showalls
endoff:
2004-06-12 23:34:04 +02:00
ret
2004-11-30 20:30:30 +01:00
def db 'Liste des commandes internes\l\l' , 0
commandes db '%0 \h10:\h12%0 \h70%0\l' , 0
code_mode:
2007-03-23 17:31:09 +01:00
call [ cs : gettypeditem ], di , 0 , ' '
2004-06-12 23:34:04 +02:00
and al , 1111b
2007-03-23 17:31:09 +01:00
call [ cs : setvideomode ], ax
call [ cs : cl earscreen ]
2004-06-12 23:34:04 +02:00
ret
2004-11-30 20:30:30 +01:00
code_dir:
2007-03-23 17:31:09 +01:00
call [ cs : getserial ]
push eax
mov si , offset nomdisque
call [ cs : getname ], si
push si
2004-11-30 20:30:30 +01:00
push offset present
2007-03-23 17:31:09 +01:00
call [ cs : print ]
xor ecx , ecx
2004-11-30 20:30:30 +01:00
mov di , offset bufferentry
2007-03-23 17:31:09 +01:00
call [ cs : findfirstfile ], di
2004-11-30 20:30:30 +01:00
jc nofiles
2004-06-12 23:34:04 +02:00
go:
2007-03-23 17:31:09 +01:00
push [ word ptr ( find di ) .result.fileattr ]
push [( find di ) .result.filesize ]
push [( find di ) .result.filetime ]
push [( find di ) .result.filedate ]
push [( find di ) .result.filetimecrea ]
push [( find di ) .result.filedatecrea ]
lea bx ,[( find di ) .result.filename ]
push bx
2004-11-30 20:30:30 +01:00
push offset line
2007-03-23 17:31:09 +01:00
call [ cs : print ]
inc ecx
call [ cs : findnextfile ], di
2004-11-30 20:30:30 +01:00
jnc go
2004-06-12 23:34:04 +02:00
nofiles:
2007-03-23 17:31:09 +01:00
push ecx
2004-11-30 20:30:30 +01:00
push offset filess
2007-03-23 17:31:09 +01:00
call [ cs : print ]
2004-11-30 20:30:30 +01:00
ret
nomdisque db 13 dup ( 0 )
bufferentry db 512 dup ( 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
2007-03-23 17:31:09 +01:00
filess db '\l\l\c02%u Fichier(s) au total\l\c07' , 0
2004-06-12 23:34:04 +02:00
code_cd:
2007-03-23 17:31:09 +01:00
call [ cs : gettypeditem ], di , 0 , ' '
push ax
2004-11-30 20:30:30 +01:00
push offset ch anging
2007-03-23 17:31:09 +01:00
call [ cs : print ]
call [ cs : ch angedir ], ax
2004-11-30 20:30:30 +01:00
jnc okchange
push offset errorchanging
2007-03-23 17:31:09 +01:00
call [ cs : print ]
2004-06-12 23:34:04 +02:00
okchange:
2004-11-30 20:30:30 +01:00
ret
changing db 'Changement de repertoire vers %0\l' , 0
2004-11-29 23:41:00 +01:00
errorchanging db '\c04Impossible d' 'atteindre ce dossier' , 0
2004-11-30 20:30:30 +01:00
code_kill:
2007-03-23 17:31:09 +01:00
call [ cs : gettypeditem ], di , 0 , ' '
push ax
2004-11-30 20:30:30 +01:00
push offset killing
2007-03-23 17:31:09 +01:00
call [ cs : print ]
call [ cs : mbfind ], ax
2004-11-30 20:30:30 +01:00
jc nochanged
2007-03-23 17:31:09 +01:00
call [ cs : mbfree ], ax
2004-11-30 20:30:30 +01:00
jnc okchanged
nochanged:
push offset errorkilling
2007-03-23 17:31:09 +01:00
call [ cs : print ]
2004-11-30 20:30:30 +01:00
okchanged:
ret
killing db 'Fermeture du processus %0\l' , 0
errorkilling db '\c04Impossible de fermer ce processus' , 0
2004-06-12 23:34:04 +02:00
code_refresh:
2007-03-23 17:31:09 +01:00
call [ cs : initdrive ]
2004-11-30 20:30:30 +01:00
jnc okrefresh
2007-03-23 17:31:09 +01:00
call [ cs : print ], offset errorrefreshing
2004-11-30 20:30:30 +01:00
ret
2004-06-12 23:34:04 +02:00
okrefresh:
2007-03-23 17:31:09 +01:00
call [ cs : getserial ]
push eax
mov si , offset nomdisque
call [ cs : getname ], si
push si
2004-11-30 20:30:30 +01:00
push offset present
2007-03-23 17:31:09 +01:00
call [ cs : print ]
2004-11-30 20:30:30 +01:00
ret
2004-11-29 23:41:00 +01:00
errorrefreshing db '\c04Impossible de lire le support' , 0
2004-11-30 20:30:30 +01:00
extcom db '.CE' , 0
2004-06-12 23:34:04 +02:00
2007-03-23 17:31:09 +01:00
code_mem:
call [ cs : print ], offset msg
2004-11-30 20:30:30 +01:00
xor ebx , ebx
xor cx , cx
2004-11-10 12:54:51 +01:00
listmcb:
2007-03-23 17:31:09 +01:00
call [ cs : mbget ], cx
2004-11-30 20:30:30 +01:00
jc fino
2007-03-23 17:31:09 +01:00
dec ax
dec ax
mov gs , ax
2004-11-30 20:30:30 +01:00
inc cx
mov dx , gs
2007-03-23 17:31:09 +01:00
push edx ;Emplacement memoire hex 2
2004-11-29 23:41:00 +01:00
;parent
2007-03-23 17:31:09 +01:00
cmp [ gs : mb.reference ], 0
2004-11-30 20:30:30 +01:00
jne next
push cs
2007-03-23 17:31:09 +01:00
push offset none ;parent lstr0 2x2
add bx ,[ gs : mb.sizes ]
2004-11-30 20:30:30 +01:00
jmp suitemn
2004-11-29 23:41:00 +01:00
next:
2007-03-23 17:31:09 +01:00
mov dx ,[ gs : mb.reference ]
2004-11-30 20:30:30 +01:00
dec dx
dec dx
2007-03-23 17:31:09 +01:00
push dx ;parent lstr0 2x2
push offset ( mb ) .names
2004-11-29 23:41:00 +01:00
suitemn:
2007-03-23 17:31:09 +01:00
cmp [ gs : mb.isresident ], true
2004-11-30 20:30:30 +01:00
jne notresident
2007-03-23 17:31:09 +01:00
push offset resident ;resident str0 2
2004-11-30 20:30:30 +01:00
jmp suitelistmcb
2004-11-10 12:54:51 +01:00
notresident:
2007-03-23 17:31:09 +01:00
push offset nonresident ;resident str0 2
2004-11-10 12:54:51 +01:00
suitelistmcb:
2004-11-30 20:30:30 +01:00
xor edx , edx
2007-03-23 17:31:09 +01:00
mov dx ,[ gs : mb.sizes ]
2004-11-30 20:30:30 +01:00
shl edx , 4
2007-03-23 17:31:09 +01:00
push 6 ;decimal 4 + type 2
2004-11-30 20:30:30 +01:00
push edx
2007-03-23 17:31:09 +01:00
push gs ;nom lstr0 2x2
push offset ( mb ) .names
push offset line2 ;ligne
call [ cs : print ]
2004-11-30 20:30:30 +01:00
jmp listmcb
2004-11-10 12:54:51 +01:00
fino:
2004-11-30 20:30:30 +01:00
shl ebx , 4
push ebx
push offset fin
2007-03-23 17:31:09 +01:00
call [ cs : print ]
2004-11-30 20:30:30 +01:00
ret
resident db "oui" , 0
nonresident db "non" , 0
2007-03-23 17:31:09 +01:00
line2 db "%0P\h15|%w\h25|%0\h30|%0P\h46|%hW\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
2004-11-30 20:30:30 +01:00
none db "." , 0
2004-11-10 12:54:51 +01:00
2004-11-11 18:03:41 +01:00
;converti le jeux scancode/ascii en fr ax->ax
convertfr:
2004-11-30 20:30:30 +01:00
push dx si
mov si , offset fr
2004-11-11 18:03:41 +01:00
searchtouch:
2007-03-23 17:31:09 +01:00
mov dx ,[ cs : si ]
2004-11-30 20:30:30 +01:00
cmp dx , 0
je endofconv
add si , 4
cmp dx , ax
jne searchtouch
2007-03-23 17:31:09 +01:00
mov ax ,[ cs : si - 2 ]
2004-11-11 18:03:41 +01:00
endofconv:
2004-11-30 20:30:30 +01:00
pop dx si
ret
2004-06-12 23:34:04 +02:00
2004-11-30 20:30:30 +01:00
fr: db '1' , 02 , '&' , 02
db '!' , 02 , '1' , 02
db '2' , 03 , '<27> ' , 03
db '@' , 03 , '2' , 03
db '3' , 04 , '"' , 04
db '#' , 04 , '3' , 04
db '4' , 05 , 39 , 05
db '$' , 05 , '4' , 05
db '5' , 06 , '(' , 06
db '%' , 06 , '5' , 06
db '6' , 07 , '-' , 07
db '^' , 07 , '6' , 07
db '7' , 08 , '<27> ' , 08
db '&' , 08 , '7' , 08
db '8' , 09 , '_' , 09
db '*' , 09 , '8' , 09
db '9' , 10 , '<27> ' , 10
db '(' , 10 , '9' , 10
db '0' , 11 , '<27> ' , 11
db ')' , 11 , '0' , 11
db '-' , 12 , ')' , 12
db '_' , 12 , '<27> ' , 12
db 'Q' , 16 , 'A' , 16
db 'q' , 16 , 'a' , 16
db 'W' , 17 , 'Z' , 17
db 'w' , 17 , 'z' , 17
db '{' , 26 , '<27> ' , 26
db '[' , 26 , '<27> ' , 26
db ']' , 27 , '$' , 27
db '}' , 27 , '<27> ' , 27
db 'A' , 30 , 'Q' , 30
db 'a' , 30 , 'q' , 30
db ':' , 39 , 'M' , 39
db ';' , 39 , 'm' , 39
db 39 , 40 , '<27> ' , 40
db '"' , 40 , '%' , 40
db 00 , 40 , '%' , 40
db '\', 43, ' * ' , 43
db '|' , 43 , '<27> ' , 43
db 'Z' , 44 , 'W' , 44
db 'z' , 44 , 'w' , 44
db 'm' , 50 , ',' , 50
db 'M' , 50 , '?' , 50
db ',' , 51 , ';' , 51
db '<' , 51 , '.' , 51
db '.' , 52 , ':' , 52
db '>' , 52 , '/' , 52
db '?' , 53 , '<27> ' , 53
db '/' , 53 , '!' , 53
db '\', 86, ' < ' , 86
db '|' , 86 , '>' , 86
db 00 , 79h , '~' , 03
db 00 , 7ah , '#' , 04
db 00 , 7bh , '{' , 05
db 00 , 7ch , '[' , 06
db 00 , 7dh , '|' , 07
db 00 , 7eh , '`' , 08
db 00 , 7fh , '\' , 09
db 00 , 80h , '^' , 10
db 00 , 81h , '@' , 11
db 00 , 82h , ']' , 12
db 00 , 83h , '}' , 13
db 00 , 00 , 00 , 00
commands dw str_exit , code_exit , syn_exit , help_exit
dw str_version , code_version , syn_version , help_version
dw str_cls , code_cls , syn_cls , help_cls
dw str_reboot , code_reboot , syn_reboot , help_reboot
dw str_command , code_command , syn_command , help_command
dw str_mode , code_mode , syn_mode , help_mode
dw str_dir , code_dir , syn_dir , help_dir
dw str_refresh , code_refresh , syn_refresh , help_refresh
dw str_cd , code_cd , syn_cd , help_cd
dw str_mem , code_mem , syn_mem , help_mem
dw str_kill , code_kill , syn_kill , help_kill
dw 0
str_exit db 'QUIT' , 0
str_version db 'VERS' , 0
str_cls db 'CLEAR' , 0
str_reboot db 'REBOOT' , 0
str_command db 'CMDS' , 0
str_mode db 'MODE' , 0
str_dir db 'DIR' , 0
str_refresh db 'DISK' , 0
str_cd db 'CD' , 0
str_mem db 'MEM' , 0
str_kill db 'KILL' , 0
syn_exit db 0
syn_version db 0
syn_cls db 0
syn_reboot db 0
syn_command db 0
2007-03-23 17:31:09 +01:00
syn_mode db 'FFh' , 0
2004-11-30 20:30:30 +01:00
syn_dir db 0
syn_refresh db 0
2007-03-23 17:31:09 +01:00
syn_cd db '?' , 0
2004-11-30 20:30:30 +01:00
syn_mem db 0
2007-03-23 17:31:09 +01:00
syn_kill db '?' , 0
2004-11-30 20:30:30 +01:00
help_exit db 'Permet de quitter l' 'interpreteur' , 0
help_version db 'Affiche la version de COS' , 0
help_cls db 'Efface l' 'ecran' , 0
help_reboot db 'Redemarre l' 'ordinateur' , 0
help_command db 'Affiche le detail des commandes' , 0
help_mode db 'Modifie le mode video en cours' , 0
help_dir db 'Affiche le contenu du repertoire courant' , 0
help_refresh db 'Lit le support disquette insere' , 0
help_cd db 'Change le repertoire courant' , 0
help_mem db 'Affiche le plan de la memoire' , 0
help_kill db 'Termine le processus cible' , 0
derror db '\c04Erreur de Syntaxe !' , 0
2007-03-23 17:31:09 +01:00
error_syntax db '\c04La commande ou l' 'executable n' 'existe pas ! F1 pour %0' , 0
2004-11-30 20:30:30 +01:00
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
dir db 32 dup ( 0 )
2007-03-23 17:31:09 +01:00
buffer db 256 dup ( 0 )
temp db 256 dup ( 0 )
2004-11-30 20:30:30 +01:00
2007-03-23 17:31:09 +01:00
import ing
use VIDEO , cl earscreen
use VIDEO , setvideomode
use VIDEO , getxy
use VIDEO , setxy
use VIDEO , addline
use VIDEO.LIB , showhex
use VIDEO.LIB , print
use VIDEO.LIB , showchar
use DI SQUE , getdir
use DI SQUE , getserial
use DI SQUE , getname
use DI SQUE , findfirstfile
use DI SQUE , findnextfile
use DI SQUE , execfile
use DI SQUE , initdrive
use DI SQUE , ch angedir
use SYSTEME , mbget
use SYSTEME , mbfind
use SYSTEME , mbfree
use STR0.LIB , uppercase
use STR0.LIB , evalue
use STR0.LIB , copy
use STR0.LIB , ch ecksyntax
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