From a9cba3a71a01b57c219dd37214405d1bbb8cef95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Tue, 9 Jul 2019 10:33:10 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20mise=20=C3=A0=20jour=20vers=20fasm,?= =?UTF-8?q?=20librairies=20et=20noyau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/cpu.h | 1 + include/fat.h | 5 + include/graphic.h | 56 +-- include/mem.h | 519 +++++++++++------------ lib/detect.asm | 628 ++++++++++++++-------------- lib/video.asm | 799 +++++++++++++++++------------------ noyau/8259a.asm | 4 - noyau/disque.asm | 1009 ++++++++++++++++++++++----------------------- noyau/video.asm | 697 ++++++++++++++----------------- 9 files changed, 1785 insertions(+), 1933 deletions(-) diff --git a/include/cpu.h b/include/cpu.h index 8b3a1af..4c5ddeb 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -18,4 +18,5 @@ struc cpu .now3d2 db 0 .htt db 0 .apic db 0 +.sizeof = $ - .vendor } diff --git a/include/fat.h b/include/fat.h index eafd610..c4da409 100644 --- a/include/fat.h +++ b/include/fat.h @@ -3,6 +3,7 @@ struc diskbuffer .size dw 12 .current dw 0FFFFh .chain dw 128 dup (0FFFFh) +.sizeof = $ - .size } struc dpt @@ -18,6 +19,7 @@ struc dpt .formatbyte db 0F6h ;Octet de formatage .headsettlingtime db 000h ;Temps de repos des tˆtes .delaymotornormspeed db 008h ;Temps de mont‚e en vitesse du moteur +.sizeof = $ - .steprateheadunload } struc entries @@ -35,6 +37,7 @@ struc entries .filedate dw 0 .filegroup dw 0 .filesize dd 0 +.sizeof = $ - .filename } ;Pour recherches @@ -45,6 +48,7 @@ struc find files .adressdirectory dw 0 ;En cluster .firstsearch db 1 ;Premiere requete ? .result entries +.sizeof = $ - .files } struc bootinfo vendor,drivename,serialnumber @@ -69,4 +73,5 @@ struc bootinfo vendor,drivename,serialnumber .serialnumber dd 01020304h ;no de serie .drivename db 'COS2000 ' ;nom de volume .typeoffat db 'FAT12 ' ;FAT +.sizeof = $ - .vendor } diff --git a/include/graphic.h b/include/graphic.h index b81249c..25deb5f 100644 --- a/include/graphic.h +++ b/include/graphic.h @@ -1,32 +1,36 @@ struc point -coordx db 0 -coordy db 0 -ends point +{ +.coordx db 0 +.coordy db 0 +} struc vgainf -lines db 0 -columns db 0 -x db 0 -y db 0 -xy dw 0 -colors db 7 -mode db 0FFh -pagesize dw 0 -style db 0 -font db 0 -graphic db 0 -nbpage db 0 -color db 0 -cursor db 0 -segments dw 0 -linesize dw 0 -adress dw 0 -base dw 0 -scrolling db 1 -ends vgainf +{ +.lines db 0 +.columns db 0 +.x db 0 +.y db 0 +.xy dw 0 +.colors db 7 +.modenum db 0FFh +.pagesize dw 0 +.style db 0 +.font db 0 +.graphic db 0 +.nbpage db 0 +.color db 0 +.cursor db 0 +.segments dw 0 +.linesize dw 0 +.adress dw 0 +.base dw 0 +.scrolling db 1 +.sizeof = $ - .lines +} struc vertex2d -px dw ? -py dw ? -ends vertex2d +{ +.px dw ? +.py dw ? +} diff --git a/include/mem.h b/include/mem.h index ca5f254..27df6bf 100644 --- a/include/mem.h +++ b/include/mem.h @@ -111,13 +111,13 @@ macro importing macro noimporting { imports: - dd 0 + ende } macro noexporting { imports: - dd 0 + ende } macro ende @@ -132,7 +132,7 @@ macro endi macro use lib*,fonction* { - db "&lib&::&fonction&",0 + db `lib,"::",`fonction,0 fonction: dd 0 dd 0 @@ -140,277 +140,250 @@ fonction: macro declare fonction* { - db "&fonction&",0 + db `fonction,0 dw fonction } - -; Macroinstructions for defining and calling procedures - -macro stdcall proc,[arg] ; directly call STDCALL procedure - { common - if ~ arg eq - reverse - pushw arg - common - end if - call proc } - -macro invoke proc,[arg] ; indirectly call STDCALL procedure - { common - if ~ arg eq - reverse - pushw arg - common - end if - call [proc] } - -macro ccall proc,[arg] ; directly call CDECL procedure - { common - size@ccall = 0 - if ~ arg eq - reverse - pushw arg - size@ccall = size@ccall+2 - common - end if - call proc - if size@ccall - add sp,size@ccall - end if } - -macro cinvoke proc,[arg] ; indirectly call CDECL procedure - { common - size@ccall = 0 - if ~ arg eq - reverse - pushw arg - size@ccall = size@ccall+2 - common - end if - call [proc] - if size@ccall - add sp,size@ccall - end if } - -macro proc [args] ; define procedure - { common - match name params, args> - \{ define@proc name, \{ prologue name,flag,parmbytes,localbytes,reglist \} - macro locals - \{ virtual at bp-localbytes+current - macro label . \\{ deflocal@proc .,:, \\} - struc db [val] \\{ \common deflocal@proc .,db,val \\} - struc du [val] \\{ \common deflocal@proc .,du,val \\} - struc dw [val] \\{ \common deflocal@proc .,dw,val \\} - struc dp [val] \\{ \common deflocal@proc .,dp,val \\} - struc dd [val] \\{ \common deflocal@proc .,dd,val \\} - struc dt [val] \\{ \common deflocal@proc .,dt,val \\} - struc dq [val] \\{ \common deflocal@proc .,dq,val \\} - struc rb cnt \\{ deflocal@proc .,rb cnt, \\} - struc rw cnt \\{ deflocal@proc .,rw cnt, \\} - struc rp cnt \\{ deflocal@proc .,rp cnt, \\} - struc rd cnt \\{ deflocal@proc .,rd cnt, \\} - struc rt cnt \\{ deflocal@proc .,rt cnt, \\} - struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} - macro endl - \{ purge label - restruc db,du,dw,dp,dd,dt,dq - restruc rb,rw,rp,rd,rt,rq - current = $-(bp-localbytes) - end virtual \} - macro ret operand - \{ match any, operand \\{ retn operand \\} - match , operand \\{ match epilogue:reglist, epilogue@proc: - \\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} - macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 - end if \} } - -macro defargs@proc [arg] - { common - if ~ arg eq - forward - local ..arg,current@arg - match argname:type, arg - \{ current@arg equ argname - label ..arg type - argname equ ..arg - if dqword eq type - dw ?,?,?,?,?,?,?,? - else if tbyte eq type - dw ?,?,?,?,? - else if qword eq type | pword eq type - dw ?,?,?,? - else if dword eq type - dw ?,? - else - dw ? - end if \} - match =current@arg,current@arg - \{ current@arg equ arg - arg equ ..arg - ..arg dw ? \} - common - args@proc equ current@arg - forward - restore current@arg - common - end if } - -macro deflocal@proc name,def,[val] - { common - match vars, all@vars \{ all@vars equ all@vars, \} - all@vars equ all@vars name - forward - local ..var,..tmp - ..var def val - match =?, val \{ ..tmp equ \} - match any =dup (=?), val \{ ..tmp equ \} - match tmp : value, ..tmp : val - \{ tmp: end virtual - initlocal@proc ..var,def value - virtual at tmp\} - common - match first rest, ..var, \{ name equ first \} } - -macro initlocal@proc name,def - { virtual at name - def - size@initlocal = $ - name - end virtual - position@initlocal = 0 - while size@initlocal > position@initlocal - virtual at name - def - if size@initlocal - position@initlocal < 2 - current@initlocal = 1 - load byte@initlocal byte from name+position@initlocal - else if size@initlocal - position@initlocal < 4 - current@initlocal = 2 - load word@initlocal word from name+position@initlocal - else - current@initlocal = 4 - load dword@initlocal dword from name+position@initlocal - end if - end virtual - if current@initlocal = 1 - mov byte [name+position@initlocal],byte@initlocal - else if current@initlocal = 2 - mov word [name+position@initlocal],word@initlocal - else - mov dword [name+position@initlocal],dword@initlocal - end if - position@initlocal = position@initlocal + current@initlocal - end while } - -macro endp - { purge ret,locals,endl - finish@proc - purge finish@proc - restore regs@proc - match all,args@proc \{ restore all \} - restore args@proc - match all,all@vars \{ restore all \} } - -macro local [var] - { common - locals - forward done@local equ - match varname[count]:vartype, var - \{ match =BYTE, vartype \\{ varname rb count - restore done@local \\} - match =WORD, vartype \\{ varname rw count - restore done@local \\} - match =DWORD, vartype \\{ varname rd count - restore done@local \\} - match =PWORD, vartype \\{ varname rp count - restore done@local \\} - match =QWORD, vartype \\{ varname rq count - restore done@local \\} - match =TBYTE, vartype \\{ varname rt count - restore done@local \\} - match =DQWORD, vartype \\{ label varname dqword - rq count+count - restore done@local \\} - match , done@local \\{ virtual - varname vartype - end virtual - rb count*sizeof.\#vartype - restore done@local \\} \} - match :varname:vartype, done@local:var - \{ match =BYTE, vartype \\{ varname db ? - restore done@local \\} - match =WORD, vartype \\{ varname dw ? - restore done@local \\} - match =DWORD, vartype \\{ varname dd ? - restore done@local \\} - match =PWORD, vartype \\{ varname dp ? - restore done@local \\} - match =QWORD, vartype \\{ varname dq ? - restore done@local \\} - match =TBYTE, vartype \\{ varname dt ? - restore done@local \\} - match =DQWORD, vartype \\{ label varname dqword - dq ?,? - restore done@local \\} - match , done@local \\{ varname vartype - restore done@local \\} \} - match ,done@local - \{ var - restore done@local \} - common + +; Macroinstructions for defining and calling procedures + +macro stdcall proc,[arg] ; directly call STDCALL procedure +{ +common + if ~ arg eq + reverse + push arg + common + end if + push cs + call proc +} + +macro invoke proc,[arg] ; directly call STDCALL procedure + { + common + if ~ arg eq + reverse + push arg + common + end if + call far [cs:proc] + } + +macro proc [args] ; define procedure + { common + match name params, args> + \{ define@proc name, \{ prologue name,flag,parmbytes,localbytes,reglist \} + macro locals + \{ virtual at bp-localbytes+current + macro label . \\{ deflocal@proc .,:, \\} + struc db [val] \\{ \common deflocal@proc .,db,val \\} + struc du [val] \\{ \common deflocal@proc .,du,val \\} + struc dw [val] \\{ \common deflocal@proc .,dw,val \\} + struc dp [val] \\{ \common deflocal@proc .,dp,val \\} + struc dd [val] \\{ \common deflocal@proc .,dd,val \\} + struc dt [val] \\{ \common deflocal@proc .,dt,val \\} + struc dq [val] \\{ \common deflocal@proc .,dq,val \\} + struc rb cnt \\{ deflocal@proc .,rb cnt, \\} + struc rw cnt \\{ deflocal@proc .,rw cnt, \\} + struc rp cnt \\{ deflocal@proc .,rp cnt, \\} + struc rd cnt \\{ deflocal@proc .,rd cnt, \\} + struc rt cnt \\{ deflocal@proc .,rt cnt, \\} + struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} + macro endl + \{ purge label + restruc db,du,dw,dp,dd,dt,dq + restruc rb,rw,rp,rd,rt,rq + current = $-(bp-localbytes) + end virtual \} + macro ret operand + \{ match any, operand \\{ retn operand \\} + match , operand \\{ match epilogue:reglist, epilogue@proc: + \\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} + macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 + end if \} } + +macro defargs@proc [arg] + { common + if ~ arg eq + forward + local ..arg,current@arg + match argname:type, arg + \{ current@arg equ argname + label ..arg type + argname equ ..arg + if dqword eq type + dw ?,?,?,?,?,?,?,? + else if tbyte eq type + dw ?,?,?,?,? + else if qword eq type | pword eq type + dw ?,?,?,? + else if dword eq type + dw ?,? + else + dw ? + end if \} + match =current@arg,current@arg + \{ current@arg equ arg + arg equ ..arg + ..arg dw ? \} + common + args@proc equ current@arg + forward + restore current@arg + common + end if } + +macro deflocal@proc name,def,[val] + { common + match vars, all@vars \{ all@vars equ all@vars, \} + all@vars equ all@vars name + forward + local ..var,..tmp + ..var def val + match =?, val \{ ..tmp equ \} + match any =dup (=?), val \{ ..tmp equ \} + match tmp : value, ..tmp : val + \{ tmp: end virtual + initlocal@proc ..var,def value + virtual at tmp\} + common + match first rest, ..var, \{ name equ first \} } + +macro initlocal@proc name,def + { virtual at name + def + size@initlocal = $ - name + end virtual + position@initlocal = 0 + while size@initlocal > position@initlocal + virtual at name + def + if size@initlocal - position@initlocal < 2 + current@initlocal = 1 + load byte@initlocal byte from name+position@initlocal + else if size@initlocal - position@initlocal < 4 + current@initlocal = 2 + load word@initlocal word from name+position@initlocal + else + current@initlocal = 4 + load dword@initlocal dword from name+position@initlocal + end if + end virtual + if current@initlocal = 1 + mov byte [name+position@initlocal],byte@initlocal + else if current@initlocal = 2 + mov word [name+position@initlocal],word@initlocal + else + mov dword [name+position@initlocal],dword@initlocal + end if + position@initlocal = position@initlocal + current@initlocal + end while } + +macro endp + { purge ret,locals,endl + finish@proc + purge finish@proc + restore regs@proc + match all,args@proc \{ restore all \} + restore args@proc + match all,all@vars \{ restore all \} } + +macro local [var] + { common + locals + forward done@local equ + match varname[count]:vartype, var + \{ match =BYTE, vartype \\{ varname rb count + restore done@local \\} + match =WORD, vartype \\{ varname rw count + restore done@local \\} + match =DWORD, vartype \\{ varname rd count + restore done@local \\} + match =PWORD, vartype \\{ varname rp count + restore done@local \\} + match =QWORD, vartype \\{ varname rq count + restore done@local \\} + match =TBYTE, vartype \\{ varname rt count + restore done@local \\} + match =DQWORD, vartype \\{ label varname dqword + rq count+count + restore done@local \\} + match , done@local \\{ virtual + varname vartype + end virtual + rb count*sizeof.\#vartype + restore done@local \\} \} + match :varname:vartype, done@local:var + \{ match =BYTE, vartype \\{ varname db ? + restore done@local \\} + match =WORD, vartype \\{ varname dw ? + restore done@local \\} + match =DWORD, vartype \\{ varname dd ? + restore done@local \\} + match =PWORD, vartype \\{ varname dp ? + restore done@local \\} + match =QWORD, vartype \\{ varname dq ? + restore done@local \\} + match =TBYTE, vartype \\{ varname dt ? + restore done@local \\} + match =DQWORD, vartype \\{ label varname dqword + dq ?,? + restore done@local \\} + match , done@local \\{ varname vartype + restore done@local \\} \} + match ,done@local + \{ var + restore done@local \} + common endl } diff --git a/lib/detect.asm b/lib/detect.asm index b268b83..2c75c51 100644 --- a/lib/detect.asm +++ b/lib/detect.asm @@ -1,17 +1,10 @@ -model tiny,stdcall -p586 -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\cpu.h" include "..\include\pci.h" org 0h -header exe <"CE",1,0,0,offset exports,,,> +header exe 1 exporting declare cpuinfo @@ -26,73 +19,68 @@ declare pcireaddword declare detectvmware ende -PROC detectvmware FAR - USES eax,ebx,ecx,edx +proc detectvmware uses eax ebx ecx edx mov eax,564D5868h mov ebx,12345h mov ecx,00Ah mov edx,5658h in ax,dx cmp ebx,564D5868h - ret -endp detectvmware + retf +endp ;renvoie un pointer dx:ax vers la classe %0 -PROC getpciclass FAR - ARG @class:word - USES di - mov di,[@class] +proc getpciclass uses di, class:word + mov di,[class] and di,0FFh shl di,1 - mov ax,[cs:offset classes+di] + mov ax,[cs:classes+di] mov dx,cs - ret -endp getpciclass + retf +endp ;renvoie un pointer dx:ax vers la sous-classe de %1 et de classe %0 -PROC getpcisubclass FAR - ARG @class:word,@subclass:word - USES di - mov di,[@class] +proc getpcisubclass uses di, class:word,subclass:word + mov di,[class] and di,0FFh shl di,1 - mov di,[cs:offset classesd+di] - mov dx,[@subclass] + mov di,[cs:classesd+di] + mov dx,[subclass] and dx,0FFh cmp dx,80h - jne @@suiteac - mov ax,offset divers - jmp @@found -@@suiteac: + jne .suiteac + mov ax,divers + jmp .found +.suiteac: shl dx,1 add di,dx mov ax,[cs:di] -@@found: +.found: mov dx,cs - ret -endp getpcisubclass + retf +endp divers db 'divers',0 classes: -dw offset class0 -dw offset class1 -dw offset class2 -dw offset class3 -dw offset class4 -dw offset class5 -dw offset class6 -dw offset class7 -dw offset class8 -dw offset class9 -dw offset class10 -dw offset class11 -dw offset class12 -dw offset class13 -dw offset class14 -dw offset class15 -dw offset class16 -dw offset class17 +dw class0 +dw class1 +dw class2 +dw class3 +dw class4 +dw class5 +dw class6 +dw class7 +dw class8 +dw class9 +dw class10 +dw class11 +dw class12 +dw class13 +dw class14 +dw class15 +dw class16 +dw class17 class0 db 'ancien',0 class1 db 'stockage',0 class2 db 'reseau',0 @@ -115,37 +103,37 @@ class17 db 'traitement signal',0 ;Classes et sous classes classesd: -dw offset class0d -dw offset class1d -dw offset class2d -dw offset class3d -dw offset class4d -dw offset class5d -dw offset class6d -dw offset class7d -dw offset class8d -dw offset class9d -dw offset class10d -dw offset class11d -dw offset class12d -dw offset class13d -dw offset class14d -dw offset class15d -dw offset class16d -dw offset class17d +dw class0d +dw class1d +dw class2d +dw class3d +dw class4d +dw class5d +dw class6d +dw class7d +dw class8d +dw class9d +dw class10d +dw class11d +dw class12d +dw class13d +dw class14d +dw class15d +dw class16d +dw class17d class0d: -dw offset subclass00 -dw offset subclass01 +dw subclass00 +dw subclass01 subclass00 db 'divers',0 subclass01 db 'vga',0 class1d: -dw offset subclass10 -dw offset subclass11 -dw offset subclass12 -dw offset subclass13 -dw offset subclass14 +dw subclass10 +dw subclass11 +dw subclass12 +dw subclass13 +dw subclass14 subclass10 db 'scsi',0 subclass11 db 'ide',0 subclass12 db 'disquette',0 @@ -153,11 +141,11 @@ subclass13 db 'ipi',0 subclass14 db 'raid',0 class2d: -dw offset subclass20 -dw offset subclass21 -dw offset subclass22 -dw offset subclass23 -dw offset subclass24 +dw subclass20 +dw subclass21 +dw subclass22 +dw subclass23 +dw subclass24 subclass20 db 'ethernet',0 subclass21 db 'token ring',0 subclass22 db 'fddi',0 @@ -165,37 +153,37 @@ subclass23 db 'atm',0 subclass24 db 'isdn',0 class3d: -dw offset subclass30 -dw offset subclass31 -dw offset subclass32 +dw subclass30 +dw subclass31 +dw subclass32 subclass30 db 'vga',0 subclass31 db 'xga',0 subclass32 db '3D',0 class4d: -dw offset subclass40 -dw offset subclass41 -dw offset subclass42 +dw subclass40 +dw subclass41 +dw subclass42 subclass40 db 'video',0 subclass41 db 'audio',0 subclass42 db 'telephonie',0 class5d: -dw offset subclass50 -dw offset subclass51 +dw subclass50 +dw subclass51 subclass50 db 'ram',0 subclass51 db 'flash',0 class6d: -dw offset subclass60 -dw offset subclass61 -dw offset subclass62 -dw offset subclass63 -dw offset subclass64 -dw offset subclass65 -dw offset subclass66 -dw offset subclass67 -dw offset subclass68 +dw subclass60 +dw subclass61 +dw subclass62 +dw subclass63 +dw subclass64 +dw subclass65 +dw subclass66 +dw subclass67 +dw subclass68 subclass60 db 'hote',0 subclass61 db 'isa',0 subclass62 db 'eisa',0 @@ -207,21 +195,21 @@ subclass67 db 'cardbus',0 subclass68 db 'RACEway',0 class7d: -dw offset subclass70 -dw offset subclass71 -dw offset subclass72 -dw offset subclass73 +dw subclass70 +dw subclass71 +dw subclass72 +dw subclass73 subclass70 db 'serie',0 subclass71 db 'parallele',0 subclass72 db 'serie multiport',0 subclass73 db 'modem',0 class8d: -dw offset subclass80 -dw offset subclass81 -dw offset subclass82 -dw offset subclass83 -dw offset subclass84 +dw subclass80 +dw subclass81 +dw subclass82 +dw subclass83 +dw subclass84 subclass80 db 'pic',0 subclass81 db 'dma',0 subclass82 db 'timer',0 @@ -229,11 +217,11 @@ subclass83 db 'rtc',0 subclass84 db 'hotplug',0 class9d: -dw offset subclass90 -dw offset subclass91 -dw offset subclass92 -dw offset subclass93 -dw offset subclass94 +dw subclass90 +dw subclass91 +dw subclass92 +dw subclass93 +dw subclass94 subclass90 db 'clavier',0 subclass91 db 'stylo',0 subclass92 db 'souris',0 @@ -241,15 +229,15 @@ subclass93 db 'scanner',0 subclass94 db 'joystick',0 class10d: -dw offset subclass100 +dw subclass100 subclass100 db 'station',0 class11d: -dw offset subclass110 -dw offset subclass111 -dw offset subclass112 -dw offset subclass113 -dw offset subclass114 +dw subclass110 +dw subclass111 +dw subclass112 +dw subclass113 +dw subclass114 subclass110 db '386',0 subclass111 db '486',0 subclass112 db 'pentium',0 @@ -257,12 +245,12 @@ subclass113 db 'alpha',0 subclass114 db 'coprocesseur',0 class12d: -dw offset subclass120 -dw offset subclass121 -dw offset subclass122 -dw offset subclass123 -dw offset subclass124 -dw offset subclass125 +dw subclass120 +dw subclass121 +dw subclass122 +dw subclass123 +dw subclass124 +dw subclass125 subclass120 db 'firewire',0 subclass121 db 'access',0 subclass122 db 'ssa',0 @@ -271,87 +259,86 @@ subclass124 db 'fibre',0 subclass125 db 'smbus',0 class13d: -dw offset subclass130 -dw offset subclass131 -dw offset subclass132 +dw subclass130 +dw subclass131 +dw subclass132 subclass130 db 'irda',0 subclass131 db 'ir',0 subclass132 db 'rf',0 class14d: -dw offset subclass140 +dw subclass140 subclass140 db 'IO arch',0 class15d: -dw offset subclass150 -dw offset subclass151 -dw offset subclass152 -dw offset subclass153 +dw subclass150 +dw subclass151 +dw subclass152 +dw subclass153 subclass150 db 'tv',0 subclass151 db 'audio',0 subclass152 db 'voix',0 subclass153 db 'donnees',0 class16d: -dw offset subclass160 -dw offset subclass161 +dw subclass160 +dw subclass161 subclass160 db 'reseau',0 subclass161 db 'jeux',0 class17d: -dw offset subclass170 +dw subclass170 subclass170 db 'dpio',0 ;al=bus cl=deviceid ch=func es:di -PROC getcardinfo FAR - ARG @bus:word,@device:word,@function:word,@pointer:word - USES eax,bx,di - mov di,[@pointer] - cmp [@function],0 - je @@amultiorfirst - call pcireadbyte,[@bus],[@device],0,offset (pcidata).typed +proc getcardinfo uses eax bx di, bus:word,device:word,function:word,pointer:word + mov di,[pointer] + cmp [function],0 + je .amultiorfirst +virtual at 0 +.pcidata pcidata +end virtual + stdcall pcireadbyte,[bus],[device],0,.pcidata.typed and al,multifunction cmp al,0 - jne @@amultiorfirst - mov [word ptr di],0000h - jmp @@notexist -@@amultiorfirst: + jne .amultiorfirst + mov word [di],0000h + jmp .notexist +.amultiorfirst: xor bx,bx -@@goinfos: - call pcireadword,[@bus],[@device],[@function],bx +.goinfos: + stdcall pcireadword,[bus],[device],[function],bx inc bl inc bl cmp bl,2 - ja @@notzarb + ja .notzarb cmp ax,0FFFFh - je @@notexist + je .notexist cmp ax,00000h - je @@notexist -@@notzarb: + je .notexist +.notzarb: mov [ds:di],ax inc di inc di cmp bl,40h - jbe @@goinfos + jbe .goinfos clc - ret -@@notexist: + retf +.notexist: stc - ret -endp getcardinfo + retf +endp ;lit un octet du bus %0 device %1 function %2 nø %3 et le met en AL -PROC pcireadbyte FAR - ARG @bus:word,@device:word,@function:word,@pointer:word - USES bx,dx - mov al,[byte ptr @bus] +proc pcireadbyte uses bx dx, bus:word,device:word,function:word,pointer:word + mov al,byte [bus] mov ah,80h shl eax,16 - mov ah,[byte ptr @device] + mov ah,byte [device] shl ah,3 - or ah,[byte ptr @function] - mov bl,[byte ptr @pointer] + or ah,byte [function] + mov bl,byte [pointer] mov al,bl and al,0fch mov dx,config1addr @@ -360,20 +347,18 @@ PROC pcireadbyte FAR and bl,3 or dl,bl in al,dx - ret -endp pcireadbyte + retf +endp ;lit 2 octet du bus %0 device %1 function %2 nø %3 et le met en AX -PROC pcireadword FAR - ARG @bus:word,@device:word,@function:word,@pointer:word - USES bx,dx - mov al,[byte ptr @bus] +proc pcireadword uses bx dx, bus:word,device:word,function:word,pointer:word + mov al,byte [bus] mov ah,80h shl eax,16 - mov ah,[byte ptr @device] + mov ah,byte [device] shl ah,3 - or ah,[byte ptr @function] - mov bl,[byte ptr @pointer] + or ah,byte [function] + mov bl,byte [pointer] mov al,bl and al,0fch mov dx,config1addr @@ -382,20 +367,18 @@ PROC pcireadword FAR and bl,3 or dl,bl in ax,dx - ret -endp pcireadword + retf +endp ;lit 4 octet du bus %0 device %1 function %2 nø %3 et le met en EAX -PROC pcireaddword FAR - ARG @bus:word,@device:word,@function:word,@pointer:word - USES bx,dx - mov al,[byte ptr @bus] +proc pcireaddword uses bx dx, bus:word,device:word,function:word,pointer:word + mov al,byte [bus] mov ah,80h shl eax,16 - mov ah,[byte ptr @device] + mov ah,byte [device] shl ah,3 - or ah,[byte ptr @function] - mov bl,[byte ptr @pointer] + or ah,byte [function] + mov bl,byte [pointer] mov al,bl and al,0fch mov dx,config1addr @@ -404,263 +387,266 @@ PROC pcireaddword FAR and bl,3 or dl,bl in eax,dx - ret -endp pcireaddword + retf +endp ;Prob avec str pci ;renvoie en %0 la structure pciinf carry if error -PROC pciinfo FAR - ARG @pointer:word - USES ax,bx,cx,edx,edi +proc pciinfo uses ax bx cx edx edi, pointer:word mov ax,0B101h xor edi,edi mov edx," PCI" int 1Ah - jc @@errorpci + jc .errorpci cmp dx,04350h - jne @@errorpci + jne .errorpci cmp ah,0 - jne @@errorpci - mov di,[@pointer] - mov [(pciinf di).version_major],bh - mov [(pciinf di).version_minor],bl - mov [(pciinf di).types],al - mov [(pciinf di).maxbus],cl + jne .errorpci + mov di,[pointer] + virtual at di + .pciinf pciinf + end virtual + mov [.pciinf.version_major],bh + mov [.pciinf.version_minor],bl + mov [.pciinf.types],al + mov [.pciinf.maxbus],cl clc - ret -@@errorpci: + retf +.errorpci: stc - ret -endp pciinfo + retf +endp -;retourne en DS:%1 les set supporté du processeur par rapport a la struct %0 -PROC setinfo FAR - ARG @pointer:word,@set:word - USES bx,si,di - mov di,[@set] - lea si,[ds:cpu.mmx] - add si,[@pointer] - mov bx,offset @@theset -@@set: - cmp [word ptr cs:bx],0FFFFh - je @@endofset - cmp [byte ptr si],1 - jne @@nextset +;retfourne en DS:%1 les set supporté du processeur par rapport a la struct %0 +proc setinfo uses bx si di, pointer:word,set:word + mov di,[set] +virtual at 0 +.cpu cpu +end virtual + lea si,[ds:.cpu.mmx] + add si,[pointer] + mov bx,.theset +.set: + cmp word [cs:bx],0FFFFh + je .endofset + cmp byte [si],1 + jne .nextset push bx mov bx,[cs:bx] -@@put: +.put: mov al,[cs:bx] cmp al,0 - je @@enofput + je .enofput mov [di],al inc bx inc di - jmp @@put -@@enofput: + jmp .put +.enofput: pop bx - @@nextset: + .nextset: inc bx inc bx inc si - jmp @@set - @@endofset: - mov [byte ptr di],0 - ret + jmp .set + .endofset: + mov byte [di],0 + retf -@@theset dw offset @@mmx - dw offset @@mmx2 - dw offset @@sse - dw offset @@sse2 - dw offset @@sse3 - dw offset @@fpu - dw offset @@now3d - dw offset @@now3d2 - dw offset @@htt - dw offset @@apic +.theset dw .mmx + dw .mmx2 + dw .sse + dw .sse2 + dw .sse3 + dw .fpu + dw .now3d + dw .now3d2 + dw .htt + dw .apic dw 0FFFFh -@@mmx db "MMX ",0 -@@mmx2 db "MMX2 ",0 -@@now3d db "3dNow! ",0 -@@now3d2 db "3dNow Extended! ",0 -@@htt db "HyperThreading",0 -@@sse db "SSE ",0 -@@sse2 db "SSE2 ",0 -@@sse3 db "SSE3 ",0 -@@apic db "APIC ",0 -@@fpu db "FPU ",0 +.mmx db "MMX ",0 +.mmx2 db "MMX2 ",0 +.now3d db "3dNow! ",0 +.now3d2 db "3dNow Extended! ",0 +.htt db "HyperThreading",0 +.sse db "SSE ",0 +.sse2 db "SSE2 ",0 +.sse3 db "SSE3 ",0 +.apic db "APIC ",0 +.fpu db "FPU ",0 -endp setinfo +endp -;retourne en DS:%0 les capacités du processeur -PROC cpuinfo FAR - ARG @pointer:word - USES eax,ebx,ecx,edx,si,di,ds,es +;retfourne en DS:%0 les capacités du processeur +proc cpuinfo uses eax ebx ecx edx si di ds es, pointer:word push ds pop es - mov di,[@pointer] + mov di,[pointer] mov al,0 - mov cx,size cpu + virtual at 0 + .cpu cpu + end virtual + mov cx,.cpu.sizeof cld rep stosb - mov di,[@pointer] + mov di,[pointer] call nocpuid ;Test si cpuid est dispo - je @@nocpuidatall + je .nocpuidatall xor eax,eax cpuid ;Fonction 0 de CPUID - mov [dword ptr (cpu di).vendor],ebx ;Vendeur sur 13 octets - mov [dword ptr (cpu di+4).vendor],edx - mov [dword ptr (cpu di+8).vendor],ecx - mov [byte ptr (cpu di+12).vendor],0 + mov dword [.cpu.vendor],ebx ;Vendeur sur 13 octets + mov dword [.cpu.vendor+4],edx + mov dword [.cpu.vendor+8],ecx + mov byte [.cpu.vendor+12],0 cmp eax,1 - jb @@nofonc1 + jb .nofonc1 mov eax,1 cpuid ;Fonction 1 de CPUID mov ebx,eax ;infos de model and ebx,1111b - mov [(cpu di).stepping],bl + mov [.cpu.stepping],bl shr eax,4 mov ebx,eax and ebx,1111b - mov [(cpu di).models],bl + mov [.cpu.models],bl shr eax,4 mov ebx,eax and ebx,1111b - mov [(cpu di).family],bl + mov [.cpu.family],bl shr eax,4 mov ebx,eax and ebx,11b - mov [(cpu di).types],bl + mov [.cpu.types],bl shr eax,2 mov ebx,eax and ebx,1111b - mov [(cpu di).emodels],bl + mov [.cpu.emodels],bl shr eax,4 - mov [(cpu di).efamily],al + mov [.cpu.efamily],al mov ebx,edx and ebx,1 ;infos de jeu d'instruction - setnz [(cpu di).fpu] + setnz [.cpu.fpu] mov ebx,edx and ebx,100000000000000000000000b - setnz [(cpu di).mmx] + setnz [.cpu.mmx] mov ebx,edx and ebx,10000000000000000000000000b - setnz [(cpu di).sse] + setnz [.cpu.sse] mov ebx,edx and ebx,100000000000000000000000000b - setnz [(cpu di).sse2] + setnz [.cpu.sse2] mov ebx,ecx and ebx,1b - setnz [(cpu di).sse3] + setnz [.cpu.sse3] mov ebx,edx and ebx,10000000000000000000000000000b - setnz [(cpu di).htt] -@@nofonc1: + setnz [.cpu.htt] +.nofonc1: mov eax,80000000h ;Fonction 80000000 de CPUID cpuid cmp eax,80000001h - jb @@nofonc8 + jb .nofonc8 mov eax,80000001h ;Fonction 80000000 de CPUID cpuid mov ebx,edx and ebx,10000000000000000000000b - setnz [(cpu di).mmx2] + setnz [.cpu.mmx2] mov ebx,edx and ebx,1000000000000000000000000000000b - setnz [(cpu di).now3d] + setnz [.cpu.now3d] mov ebx,edx and ebx,10000000000000000000000000000000b - setnz [(cpu di).now3d2] + setnz [.cpu.now3d2] mov ebx,edx and ebx,1000000000b - setnz [(cpu di).apic] -@@nofonc8: - mov si,offset @@marks + setnz [.cpu.apic] +.nofonc8: + mov si,.marks push cs pop ds -@@search: - mov di,[@pointer] +.search: + mov di,[pointer] mov cx,12 cld rep cmpsb - jne @@notthegood + jne .notthegood cmp cx,0 - jne @@notthegood + jne .notthegood mov cl,[si] inc si - mov di,[@pointer] + mov di,[pointer] cld rep movsb mov al,0 stosb - mov di,[@pointer] - cmp [es:(cpu di).family],15 - jne @@notextended - mov al,[es:(cpu di).efamily] - mov ah,[es:(cpu di).emodels] + mov di,[pointer] + cmp [es:.cpu.family],15 + jne .notextended + mov al,[es:.cpu.efamily] + mov ah,[es:.cpu.emodels] mov di,[si+2] - jmp @@searchmodel -@@notextended: - mov al,[es:(cpu di).family] - mov ah,[es:(cpu di).models] + jmp .searchmodel +.notextended: + mov al,[es:.cpu.family] + mov ah,[es:.cpu.models] mov di,[si] -@@searchmodel: +.searchmodel: cmp [di],ax - jne @@notgoodfamily + jne .notgoodfamily mov si,di inc si inc si - lea di,[es:cpu.names] - add di,[@pointer] -@@copystr: + lea di,[es:.cpu.names] + add di,[pointer] +.copystr: mov al,[si] mov [es:di],al inc si inc di cmp al,0 - jne @@copystr - jmp @@endofsearch -@@notgoodfamily: + jne .copystr + jmp .endofsearch +.notgoodfamily: inc di -@@nextelement: +.nextelement: inc di - cmp [byte ptr di-1],0 - jne @@nextelement - jmp @@searchmodel -@@notthegood: + cmp byte [di-1],0 + jne .nextelement + jmp .searchmodel +.notthegood: inc si - cmp [word ptr si],0FFFFh - jne @@notthegood + cmp word [si],0FFFFh + jne .notthegood inc si inc si - cmp [word ptr si],0FFFFh - je @@endofsearch - jmp @@search -@@endofsearch: - ret -@@nocpuidatall: - ret + cmp word [si],0FFFFh + je .endofsearch + jmp .search +.endofsearch: + retf +.nocpuidatall: + retf ;tableau avec vendeur taille + chainereelle + pointeur famille + pointeur famille etendue -@@marks db "GenuineIntel",5,"Intel" - dw @@intelfamily,@@intelfamilye +.marks db "GenuineIntel",5,"Intel" + dw .intelfamily,.intelfamilye dw 0FFFFh db "AuthenticAMD",3,"Amd" - dw @@amdfamily,@@amdfamilye + dw .amdfamily,.amdfamilye dw 0FFFFh db "CyrixInstead",5,"Cyrix" - dw @@cyrixfamily,@@cyrixfamilye + dw .cyrixfamily,.cyrixfamilye dw 0FFFFh dw 0FFFFh ;tableau avec famille modele et chaine 0 -@@intelfamily: +.intelfamily: db 4,0,"486 DX-25/33",0 db 4,1,"486 DX-50",0 db 4,2,"486 SX",0 @@ -690,7 +676,7 @@ db 6,11,"Pentium III (0.13 db 7,0,"Itanium (IA-64)",0 db 0FFh,0FFh,"Inconnu",0 -@@intelfamilye: +.intelfamilye: db 0,0,"Pentium IV (0.18 µm)",0 db 0,1,"Pentium IV (0.18 µm)",0 db 0,2,"Pentium IV (0.13 µm)",0 @@ -698,7 +684,7 @@ db 0,3,"Pentium IV (0.09 db 1,0,"Itanium 2 (IA-64)",0 db 0FFh,0FFh,"Inconnu",0 -@@amdfamily: +.amdfamily: db 4,3,"486 DX/2",0 db 4,7,"486 DX/2-WB",0 db 4,8,"486 DX/4",0 @@ -725,12 +711,12 @@ db 6,8,"Athlon (Thoroughbred)",0 db 6,10,"Athlon (Barton)",0 db 0FFh,0FFh,"Inconnu",0 -@@amdfamilye: +.amdfamilye: db 0,4,"Athlon 64",0 db 0,5,"Athlon 64 FX/Opteron",0 db 0FFh,0FFh,"Inconnu",0 -@@cyrixfamily: +.cyrixfamily: db 4,4,"MediaGX",0 db 5,2,"6x86/6x86L",0 db 5,4,"MediaGX MMX Enhanced",0 @@ -742,10 +728,10 @@ db 6,8,"WinChip C5N",0 db 6,9,"WinChip C5XL/WinChip C5P",0 db 0FFh,0FFh,"Inconnu",0 -@@cyrixfamilye: +.cyrixfamilye: db 0FFh,0FFh,"Inconnu",0 -endp cpuinfo +endp ;Test si CPUID est supporté oui=not Equal nocpuid: diff --git a/lib/video.asm b/lib/video.asm index f1b22d6..5881f41 100644 --- a/lib/video.asm +++ b/lib/video.asm @@ -1,15 +1,8 @@ -model tiny,stdcall -p486 -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" org 0h -header exe <"CE",1,0,0,offset exports,offset imports,,> +header exe 1 exporting declare print @@ -52,258 +45,257 @@ endi ;-> %0 %x ;<- ;=================================== -PROC print FAR - ARG @@pointer:word - push ax bx cx si di +proc print pointer:word + push ax bx cx si di xor di,di - mov si,[@@pointer] -@@strinaize0: + mov si,[pointer] +.strinaize0: mov cl,[si] cmp cl,0 - je @@no0 + je .no0 cmp cl,'%' - je @@special + je .special cmp cl,'\' - je @@special2 -@@showit: + je .special2 +.showit: xor ch,ch - call [cs:showchars],cx,0FFFFh + invoke showchars,cx,0FFFFh inc si - jmp @@strinaize0 -@@special: - cmp [byte ptr si+1],'%' - jne @@notshowit + jmp .strinaize0 +.special: + cmp byte [si+1],'%' + jne .notshowit inc si - jmp @@showit -@@notshowit: - mov cl,[byte ptr si+1] + jmp .showit +.notshowit: + mov cl,byte [si+1] cmp cl,'c' - je @@showchars + je .showchars cmp cl,'u' - je @@showint + je .showint cmp cl,'v' - je @@showfixint + je .showfixint cmp cl,'w' - je @@showintr + je .showintr cmp cl,'i' - je @@showsigned + je .showsigned cmp cl,'h' - je @@showhex + je .showhex cmp cl,'b' - je @@showbin + je .showbin cmp cl,'s' - je @@showstring + je .showstring cmp cl,'0' - je @@showstring0 + je .showstring0 cmp cl,'y' - je @@showbcd + je .showbcd cmp cl,'z' - je @@showsize + je .showsize cmp cl,'a' - je @@showattr + je .showattr cmp cl,'n' - je @@showname + je .showname cmp cl,'t' - je @@showtime + je .showtime cmp cl,'d' - je @@showdate + je .showdate clc - jmp @@no0 + jmp .no0 -@@showchars: - cmp [byte ptr si+2],'M' - je @@showmultchar - call [cs:showchars],[word ptr @@pointer+di+2],0FFFFh +.showchars: + cmp byte [si+2],'M' + je .showmultchar + invoke showchars,word [pointer+di+2],0FFFFh add si,2 add di,2 - jmp @@strinaize0 -@@showmultchar: - mov cx,[offset @@pointer+di+2+2] + jmp .strinaize0 +.showmultchar: + mov cx,[.pointer+di+2+2] cmp cx,0 - je @@nextfunc -@@showcharsx: - call [cs:showchars],[word ptr @@pointer+di+2],0FFFFh + je .nextfunc +.showcharsx: + invoke showchars,word [.pointer+di+2],0FFFFh dec cx - jnz @@showcharsx -@@nextfunc: + jnz .showcharsx +.nextfunc: add si,3 add di,4 - jmp @@strinaize0 + jmp .strinaize0 -@@showint: - call showint,[dword ptr @@pointer+di+2] +.showint: + stdcall showint,dword [.pointer+di+2] add si,2 add di,4 - jmp @@strinaize0 + jmp .strinaize0 -@@showfixint: - call showintl,[word ptr @@pointer+di+6],[dword ptr @@pointer+di+2] +.showfixint: + stdcall showintl,word [.pointer+di+6],[dword ptr .pointer+di+2] add di,6 add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@showintr: - call showintr,[word ptr @@pointer+di+6],[dword ptr @@pointer+di+2] +.showintr: + stdcall showintr,word [.pointer+di+6],dword [.pointer+di+2] add di,6 add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@showsigned: - call @@Chosesize - call showsigned - jmp @@strinaize0 +.showsigned: + call .Chosesize + stdcall showsigned + jmp .strinaize0 -@@showhex: - call @@Chosesize - call showhex - jmp @@strinaize0 +.showhex: + call .Chosesize + stdcall showhex + jmp .strinaize0 -@@showbin: - call @@Chosesize - call showbin - jmp @@strinaize0 +.showbin: + call .Chosesize + stdcall showbin + jmp .strinaize0 -@@showstring: +.showstring: cmp [byte ptr si+2],'P' - je @@showstring@@pointer - call showstring,[word ptr @@pointer+di+2] + je .showstring.pointer + stdcall showstring,[word ptr .pointer+di+2] add si,2 add di,2 - jmp @@strinaize0 -@@showstring@@pointer: + jmp .strinaize0 +.showstring.pointer: push ds - mov ds,[offset @@pointer+di+2+2] - call showstring,[word ptr @@pointer+di+2] + mov ds,[offset .pointer+di+2+2] + stdcall showstring,[word ptr .pointer+di+2] add si,3 add di,4 pop ds - jmp @@strinaize0 + jmp .strinaize0 -@@showstring0: +.showstring0: cmp [byte ptr si+2],'P' - je @@showstring0@@pointer - call showstring0,[word ptr offset @@pointer+di+2] + je .showstring0.pointer + stdcall showstring0,[word ptr offset .pointer+di+2] add si,2 add di,2 - jmp @@strinaize0 -@@showstring0@@pointer: + jmp .strinaize0 +.showstring0.pointer: push ds - mov ds,[offset @@pointer+di+2+2] - call showstring0,[word ptr offset @@pointer+di+2] + mov ds,[offset .pointer+di+2+2] + stdcall showstring0,[word ptr offset .pointer+di+2] add si,3 add di,4 pop ds - jmp @@strinaize0 + jmp .strinaize0 -@@showbcd: - call @@Chosesize - call showbcd - jmp @@strinaize0 +.showbcd: + call .Chosesize + stdcall showbcd + jmp .strinaize0 -@@showsize: - call showsize,[dword ptr offset @@pointer+di+2] +.showsize: + stdcall showsize,[dword ptr offset .pointer+di+2] add si,2 add di,4 - jmp @@strinaize0 + jmp .strinaize0 -@@showattr: - call showattr,[word ptr offset @@pointer+di+2] +.showattr: + stdcall showattr,[word ptr offset .pointer+di+2] add si,2 add di,2 - jmp @@strinaize0 + jmp .strinaize0 -@@showname: - call showname,[word ptr offset @@pointer+di+2] +.showname: + stdcall showname,[word ptr offset .pointer+di+2] add si,2 add di,2 - jmp @@strinaize0 + jmp .strinaize0 -@@showtime: - call showtime,[word ptr offset @@pointer+di+2] +.showtime: + stdcall showtime,[word ptr offset .pointer+di+2] add si,2 add di,2 - jmp @@strinaize0 + jmp .strinaize0 -@@showdate: - call showdate,[word ptr offset @@pointer+di+2] +.showdate: + stdcall showdate,[word ptr offset .pointer+di+2] add si,2 add di,2 - jmp @@strinaize0 + jmp .strinaize0 -@@Chosesize: +.Chosesize: pop cx - push [dword ptr offset @@pointer+di+2] + push [dword ptr offset .pointer+di+2] add di,4 cmp [byte ptr si+2],'B' - je @@byte + je .byte cmp [byte ptr si+2],'W' - je @@word + je .word cmp [byte ptr si+2],'D' - je @@dword + je .dword dec si -@@word: +.word: push 16 add si,3 push cx - retn + retfn -@@byte: +.byte: push 8 add si,3 push cx - retn + retfn -@@dword: +.dword: push 32 add si,3 push cx - retn + retfn -@@special2: +.special2: cmp [byte ptr si+1],'\' - jne @@notshowit2 + jne .notshowit2 inc si - jmp @@showit -@@notshowit2: + jmp .showit +.notshowit2: mov cl,[byte ptr si+1] cmp cl,'l' - je @@showline + je .showline cmp cl,'g' - je @@goto + je .goto cmp cl,'h' - je @@gotox + je .gotox cmp cl,'c' - je @@color + je .color cmp cl,'m' - je @@setvideomode + je .setvideomode cmp cl,'e' - je @@clearscreen + je .clearscreen cmp cl,'s' - je @@savestate + je .savestate cmp cl,'r' - je @@restorestate + je .restorestate cmp cl,'i' - je @@enablescroll + je .enablescroll cmp cl,'j' - je @@disablescroll + je .disablescroll cmp cl,'f' - je @@setfont + je .setfont clc - jmp @@no0 + jmp .no0 -@@color: +.color: mov al,[si+2] sub al,'0' shl al,4 add al,[si+3] sub al,'0' xor ah,ah - call [cs:setcolor],ax + invoke setcolor,ax add si,4 - jmp @@strinaize0 + jmp .strinaize0 -@@gotox: +.gotox: mov bh,[si+2] sub bh,'0' mov bl,bh @@ -313,13 +305,13 @@ PROC print FAR add bl,[si+3] sub bl,'0' xor bh,bh - call [cs:getxy] + invoke getxy xor ah,ah - call [cs:setxy],bx,ax + invoke setxy,bx,ax add si,4 - jmp @@strinaize0 + jmp .strinaize0 -@@setvideomode: +.setvideomode: mov ah,[si+2] sub ah,'0' mov al,ah @@ -329,11 +321,11 @@ PROC print FAR add al,[si+3] sub al,'0' xor ah,ah - call [cs:setvideomode],ax + invoke setvideomode,ax add si,4 - jmp @@strinaize0 + jmp .strinaize0 -@@setfont: +.setfont: mov ah,[si+2] sub ah,'0' mov al,ah @@ -343,41 +335,41 @@ PROC print FAR add al,[si+3] sub al,'0' xor ah,ah - call [cs:setfont],ax + invoke setfont,ax add si,4 - jmp @@strinaize0 + jmp .strinaize0 -@@showline: - call [cs:addline] +.showline: + invoke addline add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@clearscreen: - call [cs:clearscreen] +.clearscreen: + invoke clearscreen add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@savestate: - call [cs:savestate] +.savestate: + invoke savestate add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@restorestate: - call [cs:restorestate] +.restorestate: + invoke restorestate add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@enablescroll: - call [cs:enablescroll] +.enablescroll: + invoke enablescroll add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@disablescroll: - call [cs:disablescroll] +.disablescroll: + invoke disablescroll add si,2 - jmp @@strinaize0 + jmp .strinaize0 -@@goto: +.goto: mov ah,[si+2] sub ah,'0' mov al,ah @@ -397,11 +389,11 @@ PROC print FAR add bl,[si+6] sub bl,'0' xor bh,bh - call [cs:setxy],ax,bx + invoke setxy,ax,bx add si,7 - jmp @@strinaize0 + jmp .strinaize0 -@@no0: +.no0: add di,bp mov ax,[ss:bp] ;BP mov bx,[ss:bp+2] ;IP @@ -412,8 +404,8 @@ PROC print FAR mov bp,di pop di si cx bx ax mov sp,bp - ret -ENDP print + retf +endp ;================SHOWDATE============== @@ -421,199 +413,189 @@ ENDP print ;-> %0 ;<- ;====================================== -PROC showdate FAR - ARG @dates:word - USES edx +proc showdate uses edx, dates:word xor edx,edx - mov dx,[@dates] + mov dx,[dates] and dx,11111b - call showintl,2,edx - call [cs:showchars],'/',0FFFFh - mov dx,[@dates] + stdcall showintl,2,edx + invoke showchars,'/',0FFFFh + mov dx,[dates] shr dx,5 and dx,111b - call showintl,2,edx - call [cs:showchars],'/',0FFFFh - mov dx,[@dates] + stdcall showintl,2,edx + invoke showchars,'/',0FFFFh + mov dx,[dates] shr dx,8 and dx,11111111b add dx,1956 - call showintl,2,edx - ret -ENDP showdate + stdcall showintl,2,edx + retf +endp ;================SHOWTIME============== ;Affiche l'heure contenu en %0 ;-> %0 ;<- ;====================================== -PROC showtime FAR - ARG @times:word - USES edx +proc showtime uses edx, times:word xor edx,edx - mov dx,[@times] + mov dx,[times] shr dx,11 and dx,11111b - call showintl,2,edx - call [cs:showchars],':',0FFFFh - mov dx,[@times] + stdcall showintl,2,edx + invoke showchars,':',0FFFFh + mov dx,[times] shr dx,5 and dx,111111b - call showintl,2,edx - call [cs:showchars],':',0FFFFh - mov dx,[@times] + stdcall showintl,2,edx + invoke showchars,':',0FFFFh + mov dx,[times] and dx,11111b shl dx,1 - call showintl,2,edx - ret -ENDP showtime + stdcall showintl,2,edx + retf +endp ;================SHOWNAME============== -;Affiche le nom pointé par ds:%0 +;Affiche le nom pointe par ds:%0 ;-> ds:%0 ;<- ;====================================== -PROC showname FAR - ARG @thename:word - USES cx,si - mov si,[@thename] +proc showname uses cx si, thename:word + mov si,[thename] xor cx,cx -@@showthename: - call [cs:showchars],[word ptr ds:si],0FFFFh +.showthename: + invoke showchars,[word ptr ds:si],0FFFFh inc si inc cx cmp cx,8 - jne @@suiteaname - call [cs:showchars],' ',0FFFFh -@@suiteaname: + jne .suiteaname + invoke showchars,' ',0FFFFh +.suiteaname: cmp cx,8+3 - jb @@showthename - ret -ENDP showname + jb .showthename + retf +endp ;================SHOWATTR============== -;Affiche les attributs spécifié par %0 +;Affiche les attributs specifie par %0 ;-> %0 ;<- ;====================================== -PROC showattr FAR - ARG @attr:word - push 0FFFFh - test [@attr],00000001b - je @@noreadonly +proc showattr, attr:word + push 0FFFFh + test [attr],00000001b + je .noreadonly push 'L' - jmp @@readonly -@@noreadonly: + jmp .readonly +.noreadonly: push '-' -@@readonly: - call [cs:showchars] +.readonly: + invoke showchars push 0FFFFh - test [@attr],00000010b - je @@nohidden + test [attr],00000010b + je .nohidden push 'C' - jmp @@hidden -@@nohidden: + jmp .hidden +.nohidden: push '-' -@@hidden: - call [cs:showchars] +.hidden: + invoke showchars push 0FFFFh - test [@attr],00000100b - je @@nosystem + test [attr],00000100b + je .nosystem push 'S' - jmp @@system -@@nosystem: + jmp .system +.nosystem: push '-' -@@system: - call [cs:showchars] +.system: + invoke showchars push 0FFFFh - test [@attr],00100000b - je @@noarchive + test [attr],00100000b + je .noarchive push 'A' - jmp @@archive -@@noarchive: + jmp .archive +.noarchive: push '-' -@@archive: - call [cs:showchars] +.archive: + invoke showchars push 0FFFFh - test [@attr],00010000b - je @@nodirectory + test [attr],00010000b + je .nodirectory push 'R' - jmp @@directory -@@nodirectory: + jmp .directory +.nodirectory: push '-' -@@directory: - call [cs:showchars] - ret -ENDP showattr +.directory: + invoke showchars + retf +endp ;================SHOWSIZE============== -;Affiche le nom pointé par %0 +;Affiche le nom pointe par %0 ;-> %0 ;<- ;====================================== -PROC showsize FAR - ARG @thesize:dword - USES edx,ds +proc showsize uses edx ds, thesize:dword push cs pop ds - mov edx,[@thesize] + mov edx,[thesize] cmp edx,1073741824 - ja @@giga + ja .giga cmp edx,1048576*9 - ja @@mega + ja .mega cmp edx,1024*9 - ja @@kilo - call showintr,4,edx - call showstring0,offset unit - jmp @@finsize -@@kilo: + ja .kilo + stdcall showintr,4,edx + stdcall showstring0,offset unit + jmp .finsize +.kilo: shr edx,10 - call showintr,4,edx - call showstring0,offset unitkilo - jmp @@finsize -@@mega: + stdcall showintr,4,edx + stdcall showstring0,offset unitkilo + jmp .finsize +.mega: shr edx,20 - call showintr,4,edx - call showstring0,offset unitmega - jmp @@finsize -@@giga: + stdcall showintr,4,edx + stdcall showstring0,offset unitmega + jmp .finsize +.giga: shr edx,30 - call showintr,4,edx - call showstring0,offset unitgiga -@@finsize: - ret + stdcall showintr,4,edx + stdcall showstring0,offset unitgiga +.finsize: + retf unit db ' o ',0 unitkilo db ' ko',0 unitmega db ' mo',0 unitgiga db ' go',0 -ENDP showsize +endp ;==========SHOWSPACE=========== -;met un espace aprés le curseur +;met un espace apres le curseur ;-> ;<- ;============================== -PROC showspace FAR - call [cs:showchars],' ',0FFFFh +proc showspace + invoke showchars,' ',0FFFFh clc - ret -ENDP showspace + retf +endp ;==========SHOWINT=========== -;Affiche un entier %0 aprés le curseur +;Affiche un entier %0 apres le curseur ;-> %0 ;<- ;============================ -PROC showint FAR - ARG @integer:dword - USES eax,bx,cx,edx,esi +proc showint uses eax bx cx edx esi, integer:dword +local showbuffer db 50 dup (0FFh) xor cx,cx - mov eax,[@integer] + mov eax,[integer] mov esi,10 mov bx,offset showbuffer+27 -@@decint: +.decint: xor edx,edx div esi add dl,'0' @@ -621,33 +603,29 @@ PROC showint FAR mov [cs:bx],dl dec bx cmp ax,0 - jne @@decint + jne .decint mov ax,cx -@@showinteger: +.showinteger: inc bx mov cl,[cs:bx] - call [cs:showchars],cx,0FFFFh + invoke showchars,cx,0FFFFh dec ax - jnz @@showinteger - ret - -showbuffer db 50 dup (0FFh) -ENDP showint + jnz .showinteger + retf +endp ;==========SHOWINTL=========== -;Affiche un entier %0 aprés le curseur de taille %1 caractère centré a gauche -;-> %0 un entier % taille en caractères +;Affiche un entier %0 apres le curseur de taille %1 caractere centre a gauche +;-> %0 un entier % taille en caracteres ;<- ;=============================== -PROC showintl FAR - ARG @sizeofint:word,@integer:dword - USES eax,bx,cx,edx,esi,di - mov di,[@sizeofint] +proc showintl eax bx cx edx esi di, sizeofint:word,integer:dword + mov di,[sizeofint] xor cx,cx - mov eax,[@integer] + mov eax,[integer] mov esi,10 mov bx,offset showbuffer+27 -@@decint: +.decint: xor edx,edx div esi add dl,'0' @@ -655,44 +633,42 @@ PROC showintl FAR mov [cs:bx],dl dec bx cmp cx,di - jae @@nomuch + jae .nomuch cmp ax,0 - jne @@decint + jne .decint mov ax,di xchg cx,di sub cx,di -@@rego: +.rego: mov [byte ptr cs:bx],'0' dec bx dec cx - jnz @@rego - jmp @@finishim -@@nomuch: + jnz .rego + jmp .finishim +.nomuch: mov ax,di -@@finishim: -@@showinteger: +.finishim: +.showinteger: inc bx mov cl,[cs:bx] - call [cs:showchars],cx,0FFFFh + invoke showchars,cx,0FFFFh dec ax - jnz @@showinteger - ret -ENDP showintl + jnz .showinteger + retf +endp ;==========SHOWINTR=========== -;Affiche un entier %0 aprés le curseur de taille %1 caractère centré a droite -;-> %0 un entier % taille en caractères +;Affiche un entier %0 apres le curseur de taille %1 caractere centre a droite +;-> %0 un entier % taille en caracteres ;<- ;=============================== -PROC showintr FAR - ARG @sizeofint:word,@integer:dword - USES eax,bx,cx,edx,esi,di - mov di,[@sizeofint] +proc showintr uses eax bx cx edx esi di, sizeofint:word,integer:dword + mov di,[sizeofint] xor cx,cx - mov eax,[@integer] + mov eax,[integer] mov esi,10 mov bx,offset showbuffer+27 -@@decint: +.decint: xor edx,edx div esi add dl,'0' @@ -700,192 +676,179 @@ PROC showintr FAR mov [cs:bx],dl dec bx cmp cx,di - jae @@nomuch + jae .nomuch cmp ax,0 - jne @@decint + jne .decint mov ax,di xchg cx,di sub cx,di -@@rego: +.rego: mov [byte ptr cs:bx],' ' dec bx dec cx - jnz @@rego - jmp @@finishim -@@nomuch: + jnz .rego + jmp .finishim +.nomuch: mov ax,di -@@finishim: -@@showinteger: +.finishim: +.showinteger: inc bx mov cl,[cs:bx] - call [cs:showchars],cx,0FFFFh + invoke showchars,cx,0FFFFh dec ax - jnz @@showinteger - ret -ENDP showintr + jnz .showinteger + retf +endp ;==========SHOWSIGNED=========== -;Affiche un entier %0 de taille %1 aprés le curseur +;Affiche un entier %0 de taille %1 apres le curseur ;-> %0 un entier, %1 la taille ;<- ;=============================== -PROC showsigned FAR - ARG @sizeofint:word,@integer:dword=taille - USES ebx,cx,edx - mov ebx,[@integer] - mov cx,[@sizeofint] +proc showsigned ebx cx edx, sizeofint:word,integer:dword + mov ebx,[integer] + mov cx,[sizeofint] xor edx,edx cmp cx,1 - ja @@signed16 + ja .signed16 mov dl,bl cmp dl,7Fh - jbe @@notsigned + jbe .notsigned neg dl - jmp @@showminus -@@signed16: + jmp .showminus +.signed16: cmp cx,2 - ja @@signed32 + ja .signed32 mov dx,bx cmp dx,7FFFh - jbe @@notsigned + jbe .notsigned neg dx - jmp @@showminus -@@signed32: + jmp .showminus +.signed32: mov edx,ebx cmp edx,7FFFFFFFh - jbe @@notsigned + jbe .notsigned neg edx -@@showminus: - call [cs:showchars],'-',0FFFFh -@@notsigned: - call showint,edx - ret -ENDP showsigned +.showminus: + invoke showchars,'-',0FFFFh +.notsigned: + stdcall showint,edx + retf +endp ;==========SHOWHEX=========== -;Affiche un nombre hexadécimal %0 de taille %1 aprés le curseur +;Affiche un nombre hexadecimal %0 de taille %1 apres le curseur ;-> %0 un entier, %1 la taille ;<- ;============================ -PROC showhex FAR - ARG @sizeofint:word,@integer:dword=taille - USES ax,bx,cx,edx - mov edx,[@integer] - mov cx,[@sizeofint] +proc showhex ax bx cx edx, sizeofint:word,integer:dword + mov edx,[integer] + mov cx,[sizeofint] mov ax,cx shr ax,2 sub cx,32 neg cx shl edx,cl -@@Hexaize: +.Hexaize: rol edx,4 mov bx,dx and bx,0fh mov cl,[cs:bx+offset Tab] - call [cs:showchars],cx,0FFFFh + invoke showchars,cx,0FFFFh dec al - jnz @@Hexaize - ret + jnz .Hexaize + retf Tab db '0123456789ABCDEF' -ENDP showhex +endp ;==========SHOWBIN=========== -;Affiche un nombre binaire %0 de taille %1 aprés le curseur +;Affiche un nombre binaire %0 de taille %1 apres le curseur ;-> %0 un entier, %1 la taille ;<- ;============================ -PROC showbin FAR - ARG @sizeofint:word,@integer:dword=taille - USES ax,cx,edx - mov edx,[@integer] - mov cx,[@sizeofint] +proc showbin ax cx edx, sizeofint:word,integer:dword + mov edx,[integer] + mov cx,[sizeofint] sub cx,32 neg cx shl edx,cl - mov ax,[@sizeofint] -@@binaize: + mov ax,[sizeofint] +.binaize: rol edx,1 mov cl,'0' adc cl,0 - call [cs:showchars],cx,0FFFFh + invoke showchars,cx,0FFFFh dec al - jnz @@binaize - ret -ENDP showbin + jnz .binaize + retf +endp ;==========SHOWBCD=========== -;Affiche un nombre en BCD %0 de taille %1 aprés le curseur +;Affiche un nombre en BCD %0 de taille %1 apres le curseur ;-> %0 un entier, %1 la taille ;<- ;============================ -PROC showbcd FAR - ARG @sizeofint:word,@integer:dword - USES ax,cx,edx - mov edx,[@integer] - mov ax,[@sizeofint] +proc showbcd ax cx edx, sizeofint:word,integer:dword + mov edx,[integer] + mov ax,[sizeofint] mov cx,ax shr ax,2 sub cx,32 neg cx shl edx,cl -@@BCDaize: +.BCDaize: rol edx,4 mov cl,dl and cl,0fh add cl,'0' - call [cs:showchars],cx,0FFFFh + invoke showchars,cx,0FFFFh dec al - jnz @@BCDaize - ret -ENDP showbcd + jnz .BCDaize + retf +endp ;==========SHOWSTRING=========== -;Affiche une chaine de caractère pointée par ds:%1 aprés le curseur +;Affiche une chaine de caractere pointee par ds:%1 apres le curseur ;-> ds:%1 pointeur chaine type pascal ;<- ;=============================== -PROC showstring FAR - ARG @pointer:word - USES bx,si - mov si,[@pointer] +proc showstring bx si, pointer:word + mov si,[pointer] mov bl,[si] -@@strinaize: +.strinaize: inc si - call [cs:showchars],[word ptr si],0FFFFh + invoke showchars,[word ptr si],0FFFFh dec bl - jnz @@strinaize - ret -ENDP showstring + jnz .strinaize + retf +endp ;==========showchars=========== -;Affiche un caractère %0 aprés le curseur -;-> %0 caractère +;Affiche un caractere %0 apres le curseur +;-> %0 caractere ;<- ;=============================== -PROC showchar FAR - ARG @pointer:word - call [cs:showchars],[@pointer],0FFFFh - ret -ENDP showchar +proc showchar, pointer:word + invoke showchars,[pointer],0FFFFh + retf +endp ;==========SHOWSTRING0=========== -;Affiche une chaine de caractère pointée par ds:%1 aprés le curseur -;-> ds:%1 pointeur chaine type zéro terminal +;Affiche une chaine de caractere pointee par ds:%1 apres le curseur +;-> ds:%1 pointeur chaine type zero terminal ;<- ;================================ -PROC showstring0 FAR - ARG @pointer:word - USES cx,si - mov si,[@pointer] -@@strinaize0: +proc showstring0 uses cx si, pointer:word + mov si,[pointer] +.strinaize0: mov cl,[si] cmp cl,0 - je @@no0 - call [cs:showchars],cx,0FFFFh + je .no0 + invoke showchars,cx,0FFFFh inc si - jmp @@strinaize0 -@@no0: - ret -ENDP showstring0 + jmp .strinaize0 +.no0: + retf +endp diff --git a/noyau/8259a.asm b/noyau/8259a.asm index 176d275..7077b93 100644 --- a/noyau/8259a.asm +++ b/noyau/8259a.asm @@ -384,7 +384,3 @@ endp - - - - diff --git a/noyau/disque.asm b/noyau/disque.asm index dcbb188..4c6e202 100644 --- a/noyau/disque.asm +++ b/noyau/disque.asm @@ -1,16 +1,9 @@ -model tiny,stdcall -p486 -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\fat.h" org 0h -header exe <"CE",1,0,0,offset exports,offset imports,,> +header exe 1 exporting @@ -52,10 +45,10 @@ endi ;DPT disquette -mydpt dpt <> +mydpt dpt ;Secteur de boot -myboot bootinfo <> +myboot bootinfo ;Parametres support db 0 @@ -75,14 +68,12 @@ currentdir dw 0 ;En cluster currentdirstr db 128 dup (0) -PROC getfat near - uses ax,bx,dx,si,ds,es +proc getfat uses ax bx dx si ds es push cs pop ds - push cs pop es - call [cs:mbfindsb],offset datafat,cs + invoke mbfindsb,datafat,cs mov es,ax mov ax,cx mov bx,ax @@ -109,75 +100,78 @@ endfat: cmp ax,0FF0h jbe nocarry stc - ret + retf nocarry: clc - ret -endp getfat + retf +endp ;============loadfile=============== ;Charge le fichier ds:%0 en ds:%1 ->ax taille ;-> AH=4 ;<- Flag Carry si erreur ;===================================================== -PROC loadfile FAR - ARG @name:word,@pointer:word - LOCAL @@temp:word:48 - USES cx,si,di,ds,es +proc loadfile uses cx si di ds es, name:word,pointer:word +local temp[48]:WORD push ss pop es - lea di,[@@temp] + lea di,[temp] push ds di - mov si,[@name] + mov si,[name] mov cx,48/4 cld rep movsd push ss pop ds pop di es - call searchfile,di + stdcall searchfile,di jne errorload jc errorload - mov cx,[(find di).result.filegroup] - mov eax,[(find di).result.filesize] + virtual at di + .find find + end virtual + mov cx,[.find.result.filegroup] + mov eax,[.find.result.filesize] push es pop ds - call loadway,cx,eax,[@pointer] + stdcall loadway,cx,eax,[pointer] jc errorload clc - ret + retf errorload: stc xor eax,eax - ret -endp loadfile + retf +endp ;============execfile (Fonction 18)=============== ;Execute le fichier ds:si ;-> AH=18 ;<- Flag Carry si erreur ;===================================================== -PROC execfile FAR - ARG @file:word +proc execfile, file:word pushad push ds es fs gs - mov di,[@file] - call uppercase,di - call projfile,di - jc @@reallyerrornoblock - call [cs:mbfind],di - jc @@reallyerror - call [cs:mbchown],ax,[word ptr ss:bp+4] - jc @@reallyerror + mov di,[file] + stdcall uppercase,di + stdcall projfile,di + jc .reallyerrornoblock + invoke mbfind,di + jc .reallyerror + invoke mbchown,ax,word [ss:bp+4] + jc .reallyerror push ax pop ds - cmp [word ptr ds:0x0],'EC' - jne @@reallyerror + cmp word [ds:0x0],'EC' + jne .reallyerror push ax push cs - push offset @@arrive + push .arrive push ds - push [word ptr (exe).starting] + virtual at 0 + .exe exe + end virtual + push word [.exe.starting] push ds push ds push ds @@ -195,38 +189,36 @@ PROC execfile FAR popf sti db 0CBh -@@arrive: +.arrive: ;cli ;pop ax - ;call [cs:mbfree],ax - call [cs:mbfree] + ;invoke mbfree,ax + invoke mbfree pop gs fs es ds popad clc - ret -@@reallyerror: - call [cs:mbfree],ax -@@reallyerrornoblock: + retf +.reallyerror: + invoke mbfree,ax +.reallyerrornoblock: pop gs fs es ds popad stc - ret -endp execfile + retf +endp ;============projfile (Fonction 17)=============== ;Charge le fichier ds:%0 sur un bloc mémoire -> eax taille ;-> eax taille fichier ;<- Flag Carry si erreur ;===================================================== -PROC projfile FAR -ARG @pointer:word -LOCAL @@temp:word:64 -USES cx,si,di,ds,es +proc projfile uses cx si di ds es, pointer:word +local temp[64]:WORD push ss pop es - lea di,[@@temp] + lea di,[temp] push di - mov si,[@pointer] + mov si,[pointer] mov cx,64/4 cld rep movsd @@ -234,38 +226,41 @@ USES cx,si,di,ds,es pop ds pop di pushad -call [cs:biosprint],di +invoke biosprint,di popad - call uppercase,di - call [cs:mbfind],di - jnc @@notace - call searchfile,di - jne @@errorload - jc @@errorload - mov eax,[es:(find di).result.filesize] - call [cs:mbcreate],di,ax - jc @@errorload - call [cs:mbchown],ax,[word ptr ss:bp+4] - jc @@errorload + stdcall uppercase,di + invoke mbfind,di + jnc .notace + stdcall searchfile,di + jne .errorload + jc .errorload + virtual at di + .find find + end virtual + mov eax,[es:.find.result.filesize] + invoke mbcreate,di,ax + jc .errorload + invoke mbchown,ax,word [ss:bp+4] + jc .errorload mov ds,ax - mov cx,[es:(find di).result.filegroup] - mov eax,[es:(find di).result.filesize] - call loadway,cx,eax,0 - jc @@errorload - cmp [word ptr ds:0x0],'EC' - jne @@notace - call [cs:mbloadfuncs],ds - jc @@errorload - call [cs:mbloadsection],ds - jc @@errorload - @@notace: + mov cx,[es:.find.result.filegroup] + mov eax,[es:.find.result.filesize] + stdcall loadway,cx,eax,0 + jc .errorload + cmp word [ds:0x0],'EC' + jne .notace + invoke mbloadfuncs,ds + jc .errorload + invoke mbloadsection,ds + jc .errorload + .notace: clc - ret -@@errorload: + retf +.errorload: xor eax,eax stc - ret -endp projfile + retf +endp ;=============SearchFile=============== @@ -273,188 +268,185 @@ endp projfile ;-> ;<- Flag Carry si erreur ;====================================== -PROC searchfile FAR -ARG @pointer:word - USES bx,cx,si,di,ds,es - mov si,[@pointer] - lea bx,[es:(find si).result] - call uppercase,si - call findfirstfile,si - jc @@errorsearch - jmp @@founded -@@nextsearch: - call findnextfile,si - jc @@errorsearch -@@founded: - cmp [byte ptr bx],0 - je @@notgood - cmp [byte ptr bx+entries.fileattr],0Fh - je @@nextsearch - call cmpnames,si,bx - jc @@nextsearch -@@okfound: +proc searchfile uses bx cx si di ds es, pointer:word + mov si,[pointer] + virtual at si + .find find + end virtual + lea bx,[es:.find.result] + stdcall uppercase,si + stdcall findfirstfile,si + jc .errorsearch + jmp .founded +.nextsearch: + stdcall findnextfile,si + jc .errorsearch +.founded: + cmp byte [bx],0 + je .notgood + virtual at bx + .entries entries + end virtual + cmp byte [.entries.fileattr],0Fh + je .nextsearch + stdcall cmpnames,si,bx + jc .nextsearch +.okfound: clc - ret -@@notgood: + retf +.notgood: cmp si,0FF5h - ret -@@errorsearch: + retf +.errorsearch: stc - ret -endp searchfile + retf +endp ;Transforme la chaine ds:%0 en maj -PROC uppercase FAR - ARG @strs:word - USES si,ax - mov si,[@strs] -@@uppercaser: +proc uppercase uses si ax, strs:word + mov si,[strs] +.uppercaser: mov al,[si] cmp al,0 - je @@enduppercase + je .enduppercase cmp al,'a' - jb @@nonmaj + jb .nonmaj cmp al,'z' - ja @@nonmaj + ja .nonmaj sub al,'a'-'A' mov [si],al -@@nonmaj: +.nonmaj: inc si - jmp @@uppercaser -@@enduppercase: + jmp .uppercaser +.enduppercase: clc - ret -endp uppercase + retf +endp ;Compare le nom ds:%0 '.' avec ds:%1 -PROC cmpnames FAR - ARG @off1:word,@off2:word - USES ax,cx,si,di,es - mov si,[@off1] - mov di,[@off2] - cmp [byte ptr si],"." - jne @@notaredir - cmp [word ptr si],".." - jne @@onlyonedir - cmp [word ptr di],".." - je @@itok - jmp @@notequal -@@onlyonedir: - cmp [word ptr di]," ." - je @@itok -@@notaredir: +proc cmpnames uses ax cx si di es, off1:word,off2:word + mov si,[off1] + mov di,[off2] + cmp byte [si],"." + jne .notaredir + cmp word [si],".." + jne .onlyonedir + cmp word [di],".." + je .itok + jmp .notequal +.onlyonedir: + cmp word [di]," ." + je .itok +.notaredir: push ds pop es mov cx,8 repe cmpsb - jne @@nequal + jne .nequal inc si - jmp @@equal -@@nequal: - cmp [byte ptr es:di-1],' ' - jne @@notequal -@@equal: - cmp [byte ptr si-1],'.' - jne @@trynoext + jmp .equal +.nequal: + cmp byte [es:di-1],' ' + jne .notequal +.equal: + cmp byte [si-1],'.' + jne .trynoext mov al,' ' rep scasb mov cx,3 rep cmpsb - jne @@nequal2 + jne .nequal2 inc si - jmp @@equal2 -@@nequal2: - cmp [byte ptr es:di-1],' ' - jne @@notequal -@@equal2: - cmp [byte ptr si-1],0 - jne @@notequal -@@itok: + jmp .equal2 +.nequal2: + cmp byte [es:di-1],' ' + jne .notequal +.equal2: + cmp byte [si-1],0 + jne .notequal +.itok: clc - ret -@@notequal: + retf +.notequal: stc - ret -@@trynoext: - cmp [byte ptr si-1],0 - jne @@notequal - jmp @@itok -endp cmpnames + retf +.trynoext: + cmp byte [si-1],0 + jne .notequal + jmp .itok +endp ;charge le fichier de de groupe %0 et de taille %1 -PROC loadway NEAR - ARG @sector:word,@size:dword,@offset:word - USES eax,bx,cx,dx,si,di,ds,es +proc loadway uses eax bx cx dx si di ds es, sector:word,size:dword,offset:word push ds pop es - mov eax,[@size] + mov eax,[size] cmp eax,0 - je @@zeroload + je .zeroload rol eax,16 mov dx,ax ror eax,16 div [cs:clustersize] mov bx,ax - mov cx,[@sector] - mov di,[@offset] + mov cx,[sector] + mov di,[offset] cmp bx,1 - jb @@adjustlast -@@loadfat: - call readcluster,cx,di - jc @@noway + jb .adjustlast +.loadfat: + stdcall readcluster,cx,di + jc .noway add di,[cs:clustersize] - call getfat + stdcall getfat dec bx - jnz @@loadfat -@@adjustlast: + jnz .loadfat +.adjustlast: cmp dx,0 - je @@zeroload + je .zeroload push cs pop ds - mov si,offset bufferread - call readcluster,cx,si - jc @@noway + mov si,bufferread + stdcall readcluster,cx,si + jc .noway mov cx,dx cld rep movsb -@@zeroload: +.zeroload: clc - ret -@@noway: + retf +.noway: stc - ret -endp loadway + retf +endp ;=============INITDRIVE=============== ;Initialise le lecteur pour une utilisation ultérieure ;-> ;<- Flag Carry si erreur ;===================================== -PROC initdrive FAR - USES eax,bx,cx,edx,si,di,ds,es +proc initdrive uses eax bx cx edx si di ds es push cs pop ds push cs pop es mov di,3 -@@againtry: +.againtry: xor ax,ax mov dl,[support] xor dh,dh int 13h - mov bx,offset bufferread + mov bx,bufferread mov ax,0201h mov cx,0001h mov dl,[support] xor dh,dh int 13h - jnc @@oknoagaintry + jnc .oknoagaintry dec di - jnz @@againtry -@@oknoagaintry: - mov si,offset bufferread+3 - mov di,offset myboot - mov cx,size myboot + jnz .againtry +.oknoagaintry: + mov si,bufferread+3 + mov di,myboot + mov cx,myboot.sizeof cld rep movsb mov ax,[myboot.sectorsize] @@ -498,165 +490,175 @@ PROC initdrive FAR xor eax,eax mov ax,[buffer.size] mul [myboot.sectorsize] - call [cs:mbfindsb],offset databuffer,cs - jnc @@hadabufferblock - call [cs:mbcreate],offset databuffer,ax - jc @@errorinit - call [cs:mbresident],ax - jc @@errorinit - call [cs:mbchown],ax,cs - jc @@errorinit -@@hadabufferblock: + invoke mbfindsb,databuffer,cs + jnc .hadabufferblock + invoke mbcreate,databuffer,ax + jc .errorinit + invoke mbresident,ax + jc .errorinit + invoke mbchown,ax,cs + jc .errorinit +.hadabufferblock: mov [buffer.current],0FFFFh mov ax,0FFFFh mov cx,[buffer.size] - mov di,offset buffer.chain + mov di,buffer.chain cld rep stosw xor eax,eax mov ax,[myboot.sectorsperfat] mul [myboot.sectorsize] - call [cs:mbfindsb],offset datafat,cs - jnc @@hadafatbloc - call [cs:mbcreate],offset datafat,ax - jc @@errorinit - call [cs:mbresident],ax - jc @@errorinit - call [cs:mbchown],ax,cs - jc @@errorinit -@@hadafatbloc: + invoke mbfindsb,datafat,cs + jnc .hadafatbloc + invoke mbcreate,datafat,ax + jc .errorinit + invoke mbresident,ax + jc .errorinit + invoke mbchown,ax,cs + jc .errorinit +.hadafatbloc: mov dx,[myboot.sectorsperfat] mov cx,[adressfat] xor di,di ;mov di,offset fatter mov ds,ax -@@seefat: - call readsector,cx,di - jc @@errorinit +.seefat: + stdcall readsector,cx,di + jc .errorinit add di,[cs:myboot.sectorsize] inc cx dec dx - jnz @@seefat + jnz .seefat clc - ret -@@errorinit: + retf +.errorinit: stc - ret -endp initdrive + retf +endp datafat db '/fat',0 databuffer db '/buffer',0 -buffer diskbuffer <> +buffer diskbuffer ;=============FindFirstFile============== ;Renvois dans DS:%1 un bloc d'info ;-> ;<- Flag Carry si erreur ;======================================== -PROC findfirstfile FAR - ARG @pointer:word - USES cx,si - mov si,[@pointer] +proc findfirstfile uses cx si, pointer:word + mov si,[pointer] mov cx,[cs:currentdir] - mov [(find si).adressdirectory],cx + virtual at si + .find find + end virtual + mov [.find.adressdirectory],cx xor cx,cx - mov [(find si).entryplace],cx - mov [(find si).firstsearch],1 - call findnextfile,[@pointer] - ret -endp findfirstfile + mov [.find.entryplace],cx + mov [.find.firstsearch],1 + stdcall findnextfile,[pointer] + retf +endp ;=============FindnextFile============== ;Renvois dans DS:%0 un bloc d'info ;-> ;<- Flag Carry si erreur ;======================================= -PROC findnextfile FAR - ARG @pointer:word - USES ax,bx,cx,di,si,ds,es +proc findnextfile uses ax bx cx di si ds es, pointer:word push cs push ds pop es pop ds - mov si,[@pointer] - mov cx,[es:(find si).adressdirectory] - mov bx,[es:(find si).entryplace] -@@findnextfileagain: - cmp [es:(find si).firstsearch],1 - je @@first - add bx,size entries + mov si,[pointer] + virtual at si + .find find + end virtual + mov cx,[es:.find.adressdirectory] + mov bx,[es:.find.entryplace] +.findnextfileagain: + cmp [es:.find.firstsearch],1 + je .first + virtual at 0 + .entries2 entries + end virtual + add bx,.entries2.sizeof cmp bx,[cs:clustersize] - jb @@nopop -@@first: - mov di,offset bufferentry + jb .nopop +.first: + mov di,bufferentry mov bx,0 cmp [cs:currentdir],0 - jne @@notrootdir - cmp [es:(find si).firstsearch],1 - je @@noaddfirst1 + jne .notrootdir + cmp [es:.find.firstsearch],1 + je .noaddfirst1 inc cx -@@noaddfirst1: +.noaddfirst1: add cx,[cs:adressparent] mov al,[cs:myboot.sectorspercluster] -@@readroot: - call readsector,cx,di - jc @@notwell +.readroot: + stdcall readsector,cx,di + jc .notwell add di,[cs:myboot.sectorsize] dec al - jnz @@readroot + jnz .readroot sub cx,[cs:adressparent] - jmp @@nopop -@@notrootdir: - cmp [es:(find si).firstsearch],1 - je @@noaddfirst2 - call getfat -@@noaddfirst2: - jc @@notwell - call readcluster,cx,di - jc @@notwell -@@nopop: - mov [es:(find si).firstsearch],0 - mov di,offset bufferentry + jmp .nopop +.notrootdir: + cmp [es:.find.firstsearch],1 + je .noaddfirst2 + stdcall getfat +.noaddfirst2: + jc .notwell + stdcall readcluster,cx,di + jc .notwell +.nopop: + mov [es:.find.firstsearch],0 + mov di,bufferentry add di,bx - cmp [byte ptr di],0 - je @@notwell - mov [es:(find si).entryplace],bx - mov [es:(find si).adressdirectory],cx - cmp [byte ptr di],0E5h - je @@findnextfileagain - cmp [byte ptr di+entries.fileattr],28h - je @@findnextfileagain - cmp [byte ptr di+entries.fileattr],0Fh - je @@findnextfileagain + cmp byte [di],0 + je .notwell + mov [es:.find.entryplace],bx + mov [es:.find.adressdirectory],cx + cmp byte [di],0E5h + je .findnextfileagain + virtual at di + .entries entries + end virtual + cmp byte [.entries.fileattr],28h + je .findnextfileagain + cmp byte [.entries.fileattr],0Fh + je .findnextfileagain mov si,di - mov di,[@pointer] - lea di,[es:(find di).result] - mov cx,size entries + mov di,[pointer] + virtual at di + .find2 find + end virtual + lea di,[es:.find2.result] + mov cx,.entries2.sizeof cld rep movsb clc - ret -@@notwell: + retf +.notwell: stc - ret -endp findnextfile + retf +endp ;=============GetFreeSpace=============== ;Renvoie en EDX l'espace disque libre du volume ;-> ;<- Flag Carry si erreur ;======================================== -PROC getfreespace FAR - USES eax,bx +proc getfreespace uses eax bx xor eax,eax - call getsector + stdcall getsector mul [cs:myboot.sectorsize] shl edx,16 add edx,eax pop eax - ret -endp getfreespace + retf +endp ;ax=défectueux bx=libre getsector: @@ -668,7 +670,7 @@ getsector: mov cx,0 goget: push cx - call getfat + stdcall getfat cmp cx,0FF7h jne notdefect inc bx @@ -694,56 +696,52 @@ errorfree: ;-> ;<- Flag Carry si erreur ;======================================= -PROC readcluster FAR - ARG @sector:word,@pointer:word - USES ax,bx,dx,si +proc readcluster uses ax bx dx si, sector:word,pointer:word mov al,[cs:myboot.sectorspercluster] xor ah,ah mov bx,ax - mul [@sector] + mul [sector] add ax,[cs:addingvalue] - mov si,[@pointer] -@@readsectors: - call readsector,ax,si - jc @@errorreadincluster + mov si,[pointer] +.readsectors: + stdcall readsector,ax,si + jc .errorreadincluster add si,[cs:myboot.sectorsize] inc ax dec bx - jnz @@readsectors + jnz .readsectors clc - ret -@@errorreadincluster: + retf +.errorreadincluster: stc - ret -endp readcluster + retf +endp ;=============WRITECLUSTER=============== ;Ecrit le cluster %0 et le met en ds:%1 ;-> ;<- Flag Carry si erreur ;===================================================== -PROC writecluster FAR - ARG @sector:word,@pointer:word - USES ax,bx,dx,si +proc writecluster uses ax bx dx si, sector:word,pointer:word mov al,[cs:myboot.sectorspercluster] xor ah,ah mov bx,ax - mul [@sector] + mul [sector] add ax,[cs:addingvalue] - mov si,[@pointer] -@@writesectors: - call writesector,ax,si - jc @@errorwriteincluster + mov si,[pointer] +.writesectors: + stdcall writesector,ax,si + jc .errorwriteincluster add si,[cs:myboot.sectorsize] inc ax dec bx - jnz @@writesectors + jnz .writesectors clc - ret -@@errorwriteincluster: + retf +.errorwriteincluster: stc - ret -endp writecluster + retf +endp ;=============READSECTOR=============== @@ -751,56 +749,54 @@ endp writecluster ;-> ;<- Flag Carry si erreur ;====================================== -PROC readsector FAR - ARG @sector:word,@pointer:word - USES ax,bx,cx,dx,si,di,ds,es - LOCAL @tempsec +proc readsector uses ax bx cx dx si di ds es, sector:word,pointer:word + local tempsec:WORD push ds push cs pop ds - call [cs:mbfindsb],offset databuffer,cs + invoke mbfindsb,databuffer,cs pop ds mov es,ax - jc @@error - mov si,offset buffer.chain + jc .error + mov si,buffer.chain xor cx,cx - mov ax,[@sector] + mov ax,[sector] mov bx,0FFFFh -@@searchbuffer: +.searchbuffer: cmp [cs:si],ax - je @@preprepcopy - cmp [word ptr cs:si],0FFFEh - jne @@notfree + je .preprepcopy + cmp word [cs:si],0FFFEh + jne .notfree mov bx,cx -@@notfree: - cmp [word ptr cs:si],0FFFFh - je @@theend +.notfree: + cmp word [cs:si],0FFFFh + je .theend inc si inc si inc cx cmp cx,[cs:buffer.size] - jb @@searchbuffer -@@theend: + jb .searchbuffer +.theend: cmp bx,0FFFFh - jnz @@prepread + jnz .prepread cmp cx,[cs:buffer.size] - jb @@read + jb .read mov cx,[cs:buffer.current] -@@searchnext: +.searchnext: inc cx cmp cx,[cs:buffer.size] - jb @@read + jb .read xor cx,cx - jmp @@read -@@prepread: + jmp .read +.prepread: mov cx,bx -@@read: +.read: mov [cs:buffer.current],cx - mov [@tempsec],cx + mov [tempsec],cx mov ax,[cs:myboot.sectorsize] mul cx mov di,ax - mov ax,[@sector] + mov ax,[sector] xor dx,dx div [cs:myboot.sectorspertrack] inc dl @@ -815,112 +811,106 @@ PROC readsector FAR or cl,bl mov bx,di mov si,3 -@@tryagain: +.tryagain: mov ax,0201h int 13h - jnc @@prepcopy + jnc .prepcopy dec si - jnz @@tryagain - mov bx,[@tempsec] + jnz .tryagain + mov bx,[tempsec] shl bx,1 - mov [word ptr bx+offset buffer.chain],0FFFEh -@@error: + mov word [bx+buffer.chain],0FFFEh +.error: stc - ret -@@preprepcopy: - mov [@tempsec],cx -@@prepcopy: - mov bx,[@tempsec] - mov ax,[@tempsec] - mov cx,[@sector] + retf +.preprepcopy: + mov [tempsec],cx +.prepcopy: + mov bx,[tempsec] + mov ax,[tempsec] + mov cx,[sector] shl bx,1 - mov [cs:bx+offset buffer.chain],cx + mov [cs:bx+buffer.chain],cx mov cx,[cs:myboot.sectorsize] mul cx mov di,ax -@@copy: +.copy: push ds push es pop ds pop es mov si,di - mov di,[@pointer] + mov di,[pointer] cld rep movsb -@@done: - ret -endp readsector +.done: + retf +endp ;=============SETBUFFER============ ;change la taille des buffers a %0 ;-> ;<- Flag Carry si erreur ;==================================== -PROC setbuffer FAR - ARG @size:word - USES ax,cx,di,ds,es +proc setbuffer uses ax cx di ds es, size:word push cs push cs pop ds pop es - call [cs:mbfindsb],offset databuffer,cs - jc @@nodatabuffer - call [cs:mbfree],ax -@@nodatabuffer: - mov ax,[@size] + invoke mbfindsb,databuffer,cs + jc .nodatabuffer + invoke mbfree,ax +.nodatabuffer: + mov ax,[size] mov cx,ax mov [buffer.size],ax mul [myboot.sectorsize] - call [cs:mbcreate],offset databuffer,ax - jc @@errorinit - call [cs:mbresident],ax - jc @@errorinit - call [cs:mbchown],ax,cs - jc @@errorinit + invoke mbcreate,databuffer,ax + jc .errorinit + invoke mbresident,ax + jc .errorinit + invoke mbchown,ax,cs + jc .errorinit mov [buffer.current],0FFFFh mov ax,0FFFFh - mov di,offset buffer.chain + mov di,buffer.chain cld rep stosw clc - ret -@@errorinit: + retf +.errorinit: stc - ret -endp setbuffer + retf +endp ;=============GETBUFFER============ ;renvoie la structure de buffer en %0 ;-> ;<- Flag Carry si erreur ;==================================== -PROC getbuffer FAR - ARG @pointer:word - USES ax,cx,di,ds,es +proc getbuffer uses ax cx di ds es, pointer:word push cs push ds pop es pop ds - mov si,offset buffer - mov di,[@pointer] - mov cx,size buffer + mov si,buffer + mov di,[pointer] + mov cx,buffer.sizeof cld rep movsb clc - ret -endp getbuffer + retf +endp ;=============WRITESECTOR============ ;Ecrit le secteur %0 pointé par ds:%1 ;-> ;<- Flag Carry si erreur ;==================================== -PROC writesector FAR - ARG @sector:word,@pointer:word - USES ax,bx,cx,dx,si,es +proc writesector uses ax bx cx dx si es, sector:word,pointer:word push ds pop es - mov ax,[@sector] + mov ax,[sector] xor dx,dx div [cs:myboot.sectorspertrack] inc dl @@ -933,128 +923,122 @@ PROC writesector FAR xchg cl,ch shl cl,6 or cl, bl - mov bx,[@pointer] + mov bx,[pointer] mov si,3 -@@tryagain: +.tryagain: mov ax,0301h int 13h - jnc @@done + jnc .done dec si - jnz @@tryagain -@@done: - ret -endp writesector + jnz .tryagain +.done: + retf +endp ;=============Getname============== ;Renvoie le nom en DS:%0 ;-> AH=11 ;<- Flag Carry si erreur ;================================== -PROC getname FAR - ARG @pointer:word - USES ax,cx,si,di,ds,es +proc getname uses ax cx si di ds es, pointer:word push ds pop es push cs pop ds - mov di,[@pointer] - mov si,offset myboot.drivename + mov di,[pointer] + mov si,myboot.drivename mov cx,11 rep movsb mov al,' ' - mov di,[@pointer] + mov di,[pointer] mov cx,11 repne scasb - mov [byte ptr es:di],0 - ret -endp getname + mov byte [es:di],0 + retf +endp ;=============Getserial============== ;Renvoie le numéro de serie en EAX ;-> ;<- Flag Carry si erreur ;==================================== -PROC getserial FAR +proc getserial FAR mov eax,[cs:myboot.serialnumber] - ret -endp getserial + retf +endp ;=============VERIFYSECTOR============== ;Vérifie le secteur %0 ;-> ;<- Flag Carry si erreur, Flag Equal si secteurs égaux ;======================================= -PROC verifysector FAR - ARG @sector:word - USES ecx,si,di,ds,es +proc verifysector uses ecx si di ds es, sector:word push cs pop es push cs pop ds - mov si,offset bufferread - call readsector,cx,si - call inverse - call writesector,cx,si - jc @@errorverify + mov si,bufferread + stdcall readsector,cx,si + stdcall inverse + stdcall writesector,cx,si + jc .errorverify - mov si,offset bufferwrite - call readsector,cx,si - call inverse - jc @@errorverify + mov si,bufferwrite + stdcall readsector,cx,si + stdcall inverse + jc .errorverify - mov si,offset bufferread - call inverse - call writesector,cx,si - jc @@errorverify + mov si,bufferread + stdcall inverse + stdcall writesector,cx,si + jc .errorverify xor ecx,ecx mov cx,[cs:myboot.sectorsize] shr cx,2 - mov si,offset bufferread - mov di,offset bufferwrite + mov si,bufferread + mov di,bufferwrite cld rep cmpsd -@@errorverify: - ret +.errorverify: + retf -endp verifysector +endp inverse: push si cx xor cx,cx invert: - not [dword ptr si] + not dword [si] add si,4 add cx,4 cmp cx,[cs:myboot.sectorsize] jb invert pop cx si - ret + retf ;=============DecompressRle (Fonction 05H)============== ;decompress ds:si en es:di taille bp d‚compress‚ cx compress‚ ;-> AH=5 ;<- Flag Carry si erreur, Flag Equal si secteurs égaux ;===================================================== -PROC decompressrle FAR - ARG @seg1:word,@off1:word,@seg2:word,@off2:word,@size:word - USES ecx,dx,si,di,ds,es - mov ds,[@seg1] - mov es,[@seg2] - mov si,[@off1] - mov di,[@off2] - mov dx,[@size] -@@decompression: +proc decompressrle uses ecx dx si di ds es,seg1:word,off1:word,seg2:word,off2:word,size:word + mov ds,[seg1] + mov es,[seg2] + mov si,[off1] + mov di,[off2] + mov dx,[size] +.decompression: mov eax,[ds:si] cmp al,'/' - jne @@nocomp + jne .nocomp cmp si,07FFFh-6 - jae @@thenen + jae .thenen mov ecx,eax ror ecx,16 cmp cl,'*' - jne @@nocomp - cmp [byte ptr ds:si+4],'/' - jne @@nocomp + jne .nocomp + cmp byte [ds:si+4],'/' + jne .nocomp mov al,ch mov cl,ah xor ah,ah @@ -1063,46 +1047,44 @@ PROC decompressrle FAR rep stosb add si,5 sub dx,5 - jnz @@decompression - jmp @@thenen -@@nocomp: + jnz .decompression + jmp .thenen +.nocomp: mov [es:di],al inc si inc di dec dx - jnz @@decompression -@@thenen: + jnz .decompression +.thenen: xor eax,eax mov ax,di - sub ax,[@off2] + sub ax,[off2] clc - ret -endp decompressrle + retf +endp ;=============CompressRle (Fonction 06H)============== ;compress ds:si en es:di taille cx d‚compress‚ BP compress‚ ;-> AH=6 ;<- Flag Carry si erreur, Flag Equal si secteurs égaux ;===================================================== -PROC compressrle FAR - ARG @seg1:word,@off1:word,@seg2:word,@off2:word,@size:word - USES ax,bx,cx,dx,si,di,ds,es - mov es,[@seg1] - mov ds,[@seg2] - mov di,[@off1] - mov si,[@off2] - mov dx,[@size] -@@againcomp: +proc compressrle uses ax bx cx dx si di ds es, seg1:word,off1:word,seg2:word,off2:word,size:word + mov es,[seg1] + mov ds,[seg2] + mov di,[off1] + mov si,[off2] + mov dx,[size] +.againcomp: mov bx,di mov al,[es:di] mov cx,dx cmp ch,0 - je @@poo + je .poo mov cl,0ffh ;mov cx,bp ;sub cx,di ;mov ah,cl -@@poo: +.poo: mov ah,cl inc di xor ch,ch @@ -1110,67 +1092,68 @@ PROC compressrle FAR sub cl,ah neg cl cmp cl,6 - jbe @@nocomp2 - mov [dword ptr si],' * /' - mov [byte ptr si+4],'/' + jbe .nocomp2 + mov dword [si],' * /' + mov byte [si+4],'/' mov [si+1],cl mov [si+3],al add si,5 dec di xor ch,ch sub dx,cx - jnz @@againcomp - jmp @@fini -@@nocomp2: + jnz .againcomp + jmp .fini +.nocomp2: mov [si],al inc si inc bx mov di,bx dec dx - jnz @@againcomp -@@fini: + jnz .againcomp +.fini: mov ax,si - sub ax,[@off2] + sub ax,[off2] clc - ret -endp compressrle + retf +endp ;=============Changedir (Fonction 13)============== ;Change le repertoire courant a DS:SI ;-> AH=13 ;<- Flag Carry si erreur, Flag Equal si secteurs égaux ;===================================================== -PROC changedir FAR -ARG @pointer:word -LOCAL @@temp:word:64 -USES cx,si,di,ds,es +proc changedir uses cx si di ds es, pointer:word +local temp[64]:WORD push ss pop es - lea di,[@@temp] + lea di,[temp] push di - mov si,[@pointer] + mov si,[pointer] mov cx,64/4 cld rep movsd push ss pop ds pop di - call searchfile,di - jne @@noch - jc @@noch + stdcall searchfile,di + jne .noch + jc .noch ;cmp [si],005Ch ;'/',0 (root dir) - mov cx,[es:(find di).result.filegroup] + virtual at di + .find find + end virtual + mov cx,[es:.find.result.filegroup] mov [cs:currentdir],cx mov [cs:adressdirectory],cx - cmp [dword ptr es:(find di).result.filename],' .' - je @@theend - cmp [dword ptr es:(find di).result.filename],' ..' - jne @@notback + cmp dword [es:.find.result.filename],' .' + je .theend + cmp dword [es:.find.result.filename],' ..' + jne .notback push cs push cs pop ds pop es - mov di,offset currentdirstr + mov di,currentdirstr mov cx,128 mov al,0 cld @@ -1179,14 +1162,14 @@ USES cx,si,di,ds,es std repne scasb inc di - mov [byte ptr es:di],0 - jmp @@theend -@@notback: + mov byte [es:di],0 + jmp .theend +.notback: push cs push cs pop ds pop es - mov di,offset currentdirstr + mov di,currentdirstr mov cx,128 mov al,0 cld @@ -1198,7 +1181,7 @@ USES cx,si,di,ds,es mov dx,di push ss pop es - lea di,[@@temp] + lea di,[temp] mov si,di mov cx,128 mov al,0 @@ -1213,25 +1196,23 @@ USES cx,si,di,ds,es mov di,dx cld rep movsb -@@theend: +.theend: clc - ret -@@noch: + retf +.noch: stc - ret -endp changedir + retf +endp ;=============getdir============== ;Recupere le repertoire courant a DS:%0 ;-> ;<- Flag Carry si erreur ;================================= -PROC getdir FAR - ARG @pointer:word - USES ax,cx,si,di,ds,es +proc getdir uses ax cx si di ds es, pointer:word push cs pop es - mov di,offset currentdirstr + mov di,currentdirstr mov cx,128 mov al,0 cld @@ -1242,13 +1223,13 @@ PROC getdir FAR pop es push cs pop ds - mov si,offset currentdirstr - mov di,[@pointer] + mov si,currentdirstr + mov di,[pointer] cld rep movsb clc - ret -endp getdir + retf +endp bufferread db 512 dup (0) bufferwrite db 512 dup (0) diff --git a/noyau/video.asm b/noyau/video.asm index e8b6f68..2c970ee 100644 --- a/noyau/video.asm +++ b/noyau/video.asm @@ -1,16 +1,9 @@ -model tiny,stdcall -p486 -locals -jumps -codeseg -option procalign:byte - include "..\include\mem.h" include "..\include\graphic.h" org 0h -header exe <"CE",1,0,0,offset exports,offset imports,,> +header exe 1 exporting declare setvideomode @@ -37,8 +30,8 @@ declare restorescreen declare page2to1 declare page1to2 declare xchgpages -declare waithretrace -declare waitretrace +declare waithretfrace +declare waitretfrace declare getvideoinfos declare savedac declare restoredac @@ -181,7 +174,7 @@ mode11 DB 0E7H DB 100,75 ;============================================DATABLOCK========================================================= -datablock vgainf <0,0,0,0,0,7,0FFh,0,0,0,0,0,0,0,0,0,0,0,1> +datablock vgainf ;=======================================Equivalence pour la clarté du code======================================== sequencer equ 03C4h @@ -201,28 +194,27 @@ planesize equ 65000 ;-> ;<- ;===================================== -PROC enablescroll FAR +proc enablescroll mov [cs:datablock.scrolling],1 - ret -endp enablescroll + retf +endp ;=============DISABLESCROLLING========= ;Désactive le d‚filement ;-> ;<- ;====================================== -PROC disablescroll FAR +proc disablescroll mov [cs:datablock.scrolling],0 - ret -endp disablescroll + retf +endp ;=============ENABLECURSOR============= ;Autorise le d‚filement ;-> ;<- ;====================================== -PROC enablecursor FAR - USES ax,dx +proc enablecursor uses ax dx mov [cs:datablock.cursor],1 mov dx,ccrt mov al,0Ah @@ -238,17 +230,16 @@ PROC enablecursor FAR xor ah,ah mov dl,[cs:datablock.y] xor dh,dh - call setxy,ax,dx - ret -endp enablecursor + stdcall setxy,ax,dx + retf +endp ;=============DISABLECURSOR============= ;D‚sactive le d‚filement ;-> ;<- ;======================================= -PROC disablecursor FAR - USES ax,dx +proc disablecursor uses ax dx mov [cs:datablock.cursor],0 mov dx,ccrt mov al,0Ah @@ -260,60 +251,56 @@ PROC disablecursor FAR dec dx mov al,0Ah out dx,ax - ret -endp disablecursor + retf +endp ;==========SETSTYLE========= ;Change le style du texte a %0 ;-> %0 style ;<- ;============================ -PROC setstyle FAR - ARG @style:word - USES cx - mov ax,[@style] +proc setstyle uses cx, style:word + mov ax,[style] mov [cs:datablock.style],al - ret -endp setstyle + retf +endp ;==========GETSTYLE========= ;Récupère le style du texte dans AX ;-> ;<- AX style ;=========================== -PROC getstyle FAR +proc getstyle mov al,[cs:datablock.style] xor ah,ah - ret -endp getstyle + retf +endp ;=============SetVideoMode========= ;Fixe le mode vidéo courant a %0 ;-> %0 mode d'écran ;<- Carry if error ;================================== -PROC setvideomode FAR - ARG @mode:word - USES ax,cx,dx,di - mov ax,[@mode] +proc setvideomode uses ax cx dx di, modenum:word + mov ax,[modenum] xor ah,ah cmp al,maxmode - ja @@errorsetvideomode - cmp [cs:datablock.mode],5h - jb @@nographic + ja .errorsetvideomode + cmp [cs:datablock.modenum],5h + jb .nographic cmp al,5h - jae @@nographic + jae .nographic call initfont -@@nographic: - cmp [cs:datablock.mode],0FFh - jne @@noinit +.nographic: + cmp [cs:datablock.modenum],0FFh + jne .noinit call initfont -@@noinit: - mov [cs:datablock.mode],al +.noinit: + mov [cs:datablock.modenum],al xor ah,ah mov di,ax shl di,6 - add di,offset mode0 + add di,mode0 mov dx,misc mov al,[cs:di] out dx,al @@ -324,38 +311,38 @@ PROC setvideomode FAR inc di mov dx,sequencer xor ax,ax -@@initsequencer: +.initsequencer: mov ah,[cs:di] out dx,ax inc al inc di cmp al,4 - jbe @@initsequencer + jbe .initsequencer mov ax,0E11h mov dx,ccrt out dx,ax xor ax,ax -@@initcrt: +.initcrt: mov ah,[cs:di] out dx,ax inc al inc di cmp al,24 - jbe @@initcrt + jbe .initcrt mov dx,graphics xor ax,ax -@@initgraphic: +.initgraphic: mov ah,[cs:di] out dx,ax inc al inc di cmp al,8 - jbe @@initgraphic + jbe .initgraphic mov dx,statut in al,dx mov dx,attribs xor ax,ax -@@initattribs: +.initattribs: mov ah,[cs:di] push ax in ax,dx @@ -367,7 +354,7 @@ PROC setvideomode FAR inc al inc di cmp al,20 - jbe @@initattribs + jbe .initattribs mov al,20h out dx,al mov al,[cs:di] @@ -378,24 +365,24 @@ PROC setvideomode FAR mov cl,[cs:di-5] and cl,01000000b cmp cl,0 - je @@colors16 + je .colors16 mov [cs:datablock.color],8 mov cl,4 - jmp @@colors256 -@@colors16: + jmp .colors256 +.colors16: mov [cs:datablock.color],4 mov cl,3 -@@colors256: - cmp [cs:datablock.mode],5 +.colors256: + cmp [cs:datablock.modenum],5 setae [cs:datablock.graphic] - jb @@istext + jb .istext shl ax,cl mov [cs:datablock.segments],0A000h - jmp @@wasgraph -@@istext: + jmp .wasgraph +.istext: mov [cs:datablock.segments],0B800h shl ax,1 -@@wasgraph: +.wasgraph: mov [cs:datablock.pagesize],ax mov ax,planesize xor dx,dx @@ -412,48 +399,47 @@ PROC setvideomode FAR mov [cs:datablock.base],ax mov [cs:datablock.cursor],1 mov [cs:datablock.style],0 - ret -@@errorsetvideomode: - ret -endp setvideomode + retf +.errorsetvideomode: + retf +endp initfont: push ds - call clearscreen + stdcall clearscreen push cs pop ds - call loadfont,offset font8x8,8,1 - call loadfont,offset font8x16,16,0 + stdcall loadfont,font8x8,8,1 + stdcall loadfont,font8x16,16,0 pop ds - ret + retf ;=============GetVideoMode========= ;Renvoie le mode vidéo courant dans AX ;-> ;<- AX ;================================== -PROC getvideomode FAR - mov al,[cs:datablock.mode] +proc getvideomode + mov al,[cs:datablock.modenum] xor ah,ah - ret -endp getvideomode + retf +endp ;=============CLEARSCREEN========= ;Efface l'ecran graphique ou texte ;-> ;<- ;================================= -PROC clearscreen FAR - USES eax,cx,dx,di,es +proc clearscreen uses eax cx dx di es mov cx,planesize mov di,[cs:datablock.adress] shr cx,2 cmp [cs:datablock.graphic],1 - jne @@erasetext + jne .erasetext mov ax,0A000h mov es,ax -@@erasegraph: +.erasegraph: mov ax,0F02h mov dx,sequencer out dx,ax @@ -469,24 +455,24 @@ PROC clearscreen FAR rep stosd mov ax,0005h cmp [cs:datablock.color],4 - je @@not256 + je .not256 mov ax,4005h -@@not256: +.not256: mov dx,graphics out dx,ax mov ax,0003h out dx,ax - jmp @@endoferase -@@erasetext: + jmp .endoferase +.erasetext: mov ax,0B800h mov es,ax mov eax,07200720h cld rep stosd -@@endoferase: - call setxy,0,0 - ret -endp clearscreen +.endoferase: + stdcall setxy,0,0 + retf +endp ;=============SetFont========= @@ -494,13 +480,11 @@ endp clearscreen ;-> %0 n° font ;<- Carry if error ;============================= -PROC setfont FAR - ARG @font:word - USES ax,cx,dx - mov cx,[@font] +proc setfont uses ax cx dx, font:word + mov cx,[font] xor ch,ch cmp cl,7 - ja @@errorsetfont + ja .errorsetfont mov [cs:datablock.font],cl mov ah,cl and cl,11b @@ -510,20 +494,21 @@ PROC setfont FAR mov dx,sequencer mov al,3 out dx,ax - ret -@@errorsetfont: - ret -endp setfont + retf +.errorsetfont: + retf +endp ;=============GetFont========= ;Récupère le n° de la font active AX ;-> ;<- CL n° font, Carry if error ;============================= -PROC getfont FAR +proc getfont mov al,[cs:datablock.font] xor ah,ah -endp getfont + retf +endp ;!!!!!!!!!!!!!!!!!!!! a remettre les anciens params de timing depuis origine ;=============LoadFont======== @@ -531,32 +516,30 @@ endp getfont ;-> %0 n°font, %1 pointeur vers Font, %2 taille police ;<- Carry if error ;============================= -PROC loadfont FAR - ARG @pointer:word,@size:word,@font:word - USES ax,bx,cx,dx,si,di,es - mov si,[@pointer] - mov cx,[@size] - mov bx,[@font] +proc loadfont uses ax bx cx dx si di es, pointer:word, size:word, font:word + mov si,[pointer] + mov cx,[size] + mov bx,[font] cmp bl,7 - ja @@errorloadfont + ja .errorloadfont xor di,di cli mov dx,sequencer -@@doseq: - mov ax,[cs:di+offset reg1] +.doseq: + mov ax,[cs:di+reg1] out dx,ax inc di inc di cmp di,6 - jbe @@doseq + jbe .doseq mov dx,graphics -@@doseq2: - mov ax,[cs:di+offset reg1] +.doseq2: + mov ax,[cs:di+reg1] out dx,ax inc di inc di cmp di,6+6 - jbe @@doseq2 + jbe .doseq2 sti mov ax,0A000h mov es,ax @@ -564,14 +547,14 @@ PROC loadfont FAR mov al,0 xor bh,bh cmp bl,4 - jb @@isless + jb .isless sub bl,4 shl bl,1 inc bl - jmp @@okmake -@@isless: + jmp .okmake +.isless: shl bl,1 -@@okmake: +.okmake: mov di,bx shl di,13 mov bh,cl @@ -580,102 +563,97 @@ PROC loadfont FAR neg bl xor cx,cx cld -@@popz: +.popz: mov cl,bh rep movsb mov cl,bl rep stosb dec dx - jnz @@popz + jnz .popz xor di,di mov dx,sequencer -@@doseqs: - mov ax,[cs:di+offset reg2] +.doseqs: + mov ax,[cs:di+reg2] out dx,ax inc di inc di cmp di,6 - jbe @@doseqs + jbe .doseqs mov dx,graphics -@@doseqs2: - mov ax,[cs:di+offset reg2] +.doseqs2: + mov ax,[cs:di+reg2] out dx,ax inc di inc di cmp di,6+6 - jbe @@doseqs2 - ret -@@errorloadfont: + jbe .doseqs2 + retf +.errorloadfont: stc - ret + retf reg2 dw 0100h, 0302h, 0304h, 0300h dw 0004h, 1005h, 0E06h reg1 dw 0100h, 0402h, 0704h, 0300h dw 0204h, 0005h, 0406h -endp loadfont +endp ;==========SHOWLINE=============== -;remet le curseur text a la ligne avec un retour chariot +;remet le curseur text a la ligne avec un retfour chariot ;-> ;<- ;================================= -PROC addline FAR - USES bx,cx +proc addline uses bx cx mov bl,[cs:datablock.y] xor bh,bh mov cl,[cs:datablock.lines] sub cl,2 cmp bl,cl - jne @@scro + jne .scro dec bl mov cx,1 cmp [cs:datablock.graphic],0 - je @@okscro + je .okscro mov cx,8 -@@okscro: - call scrolldown,cx -@@scro: +.okscro: + stdcall scrolldown,cx +.scro: inc bl - call setxy,0,bx - ret -endp addline + stdcall setxy,0,bx + retf +endp ;==========SETCOLOR========= ;Change les attributs du texte a CL ;-> %0 couleur ;<- ;=========================== -PROC setcolor FAR - ARG @color:word - USES cx - mov cx,[@color] +proc setcolor, color:word + mov cx,[color] mov [cs:datablock.colors],cl - ret -endp setcolor + retf +endp ;==========GETCOLOR========= ;Récupère les attributs du texte dans AX ;-> ;<- AX couleur ;=========================== -PROC getcolor FAR +proc getcolor mov al,[cs:datablock.colors] xor ah,ah - ret -endp getcolor + retf +endp ;==========SCROLLDOWN========= ;defile de %0 lines vers le bas ;-> %0 lines à défiler vers le bas ;<- ;============================= -PROC scrolldown FAR - ARG @line:word - USES ax,cx,dx,si,di,ds,es +proc scrolldown uses ax cx dx si di ds es, line:word cmp [cs:datablock.scrolling],0 - je @@graphp - mov ax,[@line] + je .graphp + mov ax,[line] mul [cs:datablock.linesize] mov si,ax mov cx,[cs:datablock.pagesize] @@ -683,7 +661,7 @@ PROC scrolldown FAR mov di,[cs:datablock.adress] cld cmp [cs:datablock.graphic],1 - jne @@textp + jne .textp mov ax,0A000h mov es,ax mov ds,ax @@ -697,46 +675,43 @@ PROC scrolldown FAR rep movsb mov ax,0005h cmp [cs:datablock.color],4 - je @@not256ok + je .not256ok mov ax,4005h -@@not256ok: +.not256ok: mov dx,graphics out dx,ax mov ax,0003h out dx,ax - jmp @@graphp + jmp .graphp -@@textp: +.textp: mov ax,0B800h mov es,ax mov ds,ax rep movsb -@@graphp: - ret -endp scrolldown +.graphp: + retf +endp ;==========GETXY========= ;Met les coordonnées du curseur dans ah,al au format point ;-> ;<- ah coordonnées x, al coordonnées y ;======================== -PROC getxy FAR - USES bx +proc getxy uses bx mov ah,[cs:datablock.x] mov al,[cs:datablock.y] - ret -endp getxy + retf +endp ;==========SETXY========= ;Change les coordonnées du curseur a X:%0,Y:%1 ;-> %0 coordonnées x, %1 coordonnées y ;<- ;======================== -PROC setxy FAR - ARG @x:word,@y:word - USES ax,bx,dx,di - mov ax,[@y] - mov bx,[@x] +proc setxy uses ax bx dx di, x:word ,y: word + mov ax,[y] + mov bx,[x] mov [cs:datablock.x],bl mov [cs:datablock.y],al mov di,[cs:datablock.adress] @@ -746,22 +721,20 @@ PROC setxy FAR shl di,1 mov [cs:datablock.xy],di call setcursor - ret -endp setxy + retf +endp ;==========SHOWPIXEL========= ;Affiche un pixel de couleur AL en X:%0,Y:%1 ;-> %0 coordonnées x, %1 coordonnées y, %2 couleur ;<- ;============================ -PROC showpixel FAR - ARG @x:word,@y:word,@color:word - USES ax,bx,cx,dx,si,di,es - mov bx,[@x] - mov cx,[@y] - mov ax,[@color] +proc showpixel uses ax bx cx dx si di es, x:word,y:word,color:word + mov bx,[x] + mov cx,[y] + mov ax,[color] cmp [cs:datablock.color],4 - je @@showpixel4 + je .showpixel4 mov si,ax mov ax,cx mov cl,bl @@ -780,9 +753,9 @@ PROC showpixel FAR mov es,bx mov ax,si mov [es:di],al - jmp @@endofshow + jmp .endofshow -@@showpixel4: +.showpixel4: mov dx,ax mov ax,cx mov ch,dl @@ -807,9 +780,9 @@ PROC showpixel FAR mov es,bx mov al,[es:di] mov [es:di],ch -@@endofshow: - ret -endp showpixel +.endofshow: + retf +endp ;!!!!!!!!!!!!!! gerer le mode chain 4 ;==========GETPIXEL========= @@ -817,11 +790,9 @@ endp showpixel ;-> %0 coordonnées x, %1 coordonnées y ;<- AX couleur ;========================================= -PROC getpixel FAR - ARG @x:word,@y:word - USES ax,bx,cx,dx,di,es - mov bx,[@x] - mov cx,[@y] +proc getpixel uses ax bx cx dx di es, x:word,y:word + mov bx,[x] + mov cx,[y] mov ax,cx mov cl,bl mul [cs:datablock.linesize] @@ -837,106 +808,99 @@ PROC getpixel FAR mov bx,0A000h mov es,bx mov al,[es:di] - ret -endp getpixel + retf +endp ;==========GETVGAINFO========= ;Renvoie un bloc de donnée en ES:DI sur l'état de la carte graphique ;<- ES:%0 pointeur ;-> ;============================================= -PROC getvideoinfos FAR - ARG @pointer:word - USES cx,si,di,ds +proc getvideoinfos uses cx si di ds, pointer:word push cs pop ds - mov cx,size datablock - mov si,offset datablock - mov di,[@pointer] + mov cx,datablock.sizeof + mov si,datablock + mov di,[pointer] cld rep movsb - ret -endp getvideoinfos + retf +endp -;==========WAITRETRACE========= -;Synchronisation avec la retrace verticale +;==========WAITretfRACE========= +;Synchronisation avec la retfrace verticale ;<- ;-> ;============================== -PROC waitretrace FAR - USES ax,dx +proc waitretfrace uses ax dx mov dx,3DAh -@@waitr: +.waitr: in al,dx test al,8 - jz @@waitr - ret -endp waitretrace + jz .waitr + retf +endp -;==========WAITHRETRACE========= -;Synchronisation avec la retrace horizontale +;==========WAITHretfRACE========= +;Synchronisation avec la retfrace horizontale ;<- ;-> ;=============================== -PROC waithretrace FAR - USES ax,dx +proc waithretfrace uses ax dx mov dx,3DAh -@@waitr: +.waitr: in al,dx test al,1 - jz @@waitr - ret -endp waithretrace + jz .waitr + retf +endp ;==========GETCHAR========= ;Renvoie en AX le caractère sur le curseur ;<- ;-> ;========================== -PROC getchars FAR - USES di,es +proc getchars uses di es mov ax,0B800h mov es,ax mov di,[cs:datablock.xy] mov al,[es:di] xor ah,ah - ret -endp getchars + retf +endp ;==========SHOWCHAR========= ;Ecrit le caractère ASCII %0 attribut %1 aprés le curseur, en le mettant à jours ;<- ;-> ;=========================== -PROC showchars FAR - ARG @char:word,@attr:word - USES ax,bx,cx,dx,di,es - mov cl,[byte ptr @char] - mov ch,[byte ptr @attr] - cmp [@attr],0FFFFh - jne @@notlastattr +proc showchars uses ax bx cx dx di es, char:word,attr:word + mov cl,byte [char] + mov ch,byte [attr] + cmp [attr],0FFFFh + jne .notlastattr mov ch,[cs:datablock.colors] -@@notlastattr: +.notlastattr: cmp [cs:datablock.graphic],1 - jne @@textaccess + jne .textaccess call emulatechar - jmp @@adjusttext -@@textaccess: + jmp .adjusttext +.textaccess: mov ax,0B800h mov es,ax mov di,[cs:datablock.xy] mov [es:di],cx add [cs:datablock.xy],2 -@@adjusttext: +.adjusttext: inc [cs:datablock.x] mov cl,[cs:datablock.columns] cmp [cs:datablock.x],cl - jb @@noadjusted - call addline -@@noadjusted: + jb .noadjusted + stdcall addline +.noadjusted: call setcursor - ret -endp showchars + retf +endp setcursor: push ax cx dx @@ -963,7 +927,7 @@ emulatechar: mov di,cx and di,11111111b shl di,3 - add di,offset font8x8 + add di,font8x8 mov bl,[cs:datablock.x] mov cl,[cs:datablock.y] xor bh,bh @@ -981,7 +945,7 @@ bouclet: jnz transparent colored: and ax,1111b - call showpixel,bx,cx,ax + stdcall showpixel,bx,cx,ax transparent: pop ax inc bx @@ -1001,77 +965,70 @@ ended: ret ;sauve l'ecran dans un bloc de mémoire -PROC savescreen FAR -USES ax,ds,bp +proc savescreen uses ax ds bp mov bp,sp push cs pop ds -call [cs:mbcreate],offset data3,[cs:datablock.pagesize] -jc @@error -call [cs:mbchown],ax,[word ptr ss:bp+8] -jc @@error +invoke mbcreate,data3,[cs:datablock.pagesize] +jc .error +invoke mbchown,ax,word [ss:bp+8] +jc .error push ax pop ds -call savescreento,0 +stdcall savescreento,0 clc -ret -@@error: +retf +.error: stc -ret -endp savescreen +retf +endp data3 db '/vgascreen',0 ;===================================sauve l'ecran rapidement en ds:%1================ -PROC savescreento FAR - ARG @offset:word - USES ecx,si,di,ds,es +proc savescreento uses ecx si di ds es, offset:word push ds pop es mov cx,0B800h mov ds,cx xor ecx,ecx mov cx,[cs:datablock.pagesize] - mov di,[@offset] + mov di,[offset] shr cx,2 xor si,si cld rep movsd - ret -endp savescreento + retf +endp ;===================================sauve les parametres en ds:%0================ -PROC saveparamto FAR - ARG @offset:word - USES ecx,si,di,ds,es +proc saveparamto uses ecx si di ds es, offset:word push ds pop es push cs pop ds xor ecx,ecx - mov cx,size datablock - mov di,[@offset] - mov si,offset datablock + mov cx,datablock.sizeof + mov di,[offset] + mov si,datablock cld rep movsb - ret -endp saveparamto + retf +endp ;===================================restore les parametres depuis en ds:%0================ -PROC restoreparamfrom FAR - ARG @offset:word - USES ecx,si,di,es +proc restoreparamfrom uses ecx si di es, offset:word push cs pop es xor ecx,ecx - mov cx,size datablock - mov si,[@offset] - call setvideomode,[word ptr (vgainf si).mode] - mov di,offset datablock + mov cx,datablock.sizeof + mov si,[offset] + stdcall setvideomode,word [si+datablock.modenum] + mov di,datablock cld rep movsb - ret -endp restoreparamfrom + retf +endp @@ -1080,47 +1037,43 @@ endp restoreparamfrom ;restaure l'ecran dans un bloc de mémoire -PROC restorescreen FAR -USES ax,ds,bp +proc restorescreen uses ax ds bp mov bp,sp push cs pop ds -call [cs:mbfindsb],offset data3,[word ptr ss:bp+8] -jc @@error +invoke mbfindsb,data3,word [ss:bp+8] +jc .error push ax pop ds -call restorescreenfrom,0 +stdcall restorescreenfrom,0 clc -ret -@@error: +retf +.error: stc -ret -endp restorescreen +retf +endp ;===================================restaure l'ecran rapidement en %1================ -PROC restorescreenfrom FAR - ARG @offset:word - USES ecx,si,di,es +proc restorescreenfrom uses ecx si di es, offset:word mov cx,0B800h mov es,cx xor ecx,ecx mov cx,[cs:datablock.pagesize] - mov si,[@offset] + mov si,[offset] shr cx,2 xor di,di cld rep movsd - ret -endp restorescreenfrom + retf +endp ;===============================Page2to1============================ -PROC page2to1 FAR - USES ecx,si,di,ds,es +proc page2to1 uses ecx si di ds es mov cx,0B800H mov es,cx mov ds,cx @@ -1131,12 +1084,11 @@ PROC page2to1 FAR xor di,di cld rep movsd - ret -endp page2to1 + retf +endp ;===============================Page1to2============================ -PROC page1to2 FAR - USES ecx,si,di,ds,es +proc page1to2 uses ecx si di ds es mov cx,0B800H mov es,cx mov ds,cx @@ -1147,22 +1099,21 @@ PROC page1to2 FAR xor si,si cld rep movsd - ret -endp page1to2 + retf +endp ;===============================xchgPages============================ -PROC xchgpages FAR - USES ax,ecx,si,di,ds,es,bp +proc xchgpages uses ax ecx si di ds es bp mov bp,sp push cs pop ds -call [cs:mbcreate],offset data4,[cs:datablock.pagesize] -jc @@error -call [cs:mbchown],ax,[word ptr ss:bp+18] -jc @@error +invoke mbcreate,data4,[cs:datablock.pagesize] +jc .error +invoke mbchown,ax,word [ss:bp+18] +jc .error push ax pop ds -call savescreento,0 -call page2to1 +stdcall savescreento,0 +stdcall page2to1 xor si,si mov cx,0B800H mov es,cx @@ -1172,13 +1123,13 @@ mov cx,[cs:datablock.pagesize] shr cx,2 cld rep movsd -call [cs:mbfree],ax +invoke mbfree,ax clc -ret -@@error: +retf +.error: stc -ret -endp xchgpages +retf +endp data4 db '/vgatemp',0 @@ -1186,113 +1137,107 @@ data4 db '/vgatemp',0 -;Sauve l'‚tat de la carte dans un bloc mémoire -PROC savestate FAR -USES ax,cx,di,ds,bp +;Sauve l'état de la carte dans un bloc mémoire +proc savestate uses ax cx di ds bp mov bp,sp -mov cx,size datablock +mov cx,datablock.sizeof add cx,[cs:datablock.pagesize] add cx,3*256 push cs pop ds -call [cs:mbcreate],offset data,cx -jc @@error -call [cs:mbchown],ax,[word ptr ss:bp+12] -jc @@error +invoke mbcreate,adata,cx +jc .error +invoke mbchown,ax,word [ss:bp+12] +jc .error push ax pop ds xor di,di -call saveparamto,di -add di,size datablock -call savescreento,di +stdcall saveparamto,di +add di,datablock.sizeof +stdcall savescreento,di add di,[cs:datablock.pagesize] -call savedacto,di +stdcall savedacto,di clc -ret -@@error: +retf +.error: stc -ret -endp savestate +retf +endp -data db '/vga',0 +adata db '/vga',0 -;R‚cupŠre l'‚tat de la carte depuis son bloc mémoire -PROC restorestate FAR -USES ax,cx,di,ds,bp +;Récupère l'état de la carte depuis son bloc mémoire +proc restorestate uses ax cx di ds bp mov bp,sp push cs pop ds -call [cs:mbfindsb],offset data,[word ptr ss:bp+12] -jc @@error +invoke mbfindsb,adata,word [ss:bp+12] +jc .error push ax pop ds xor di,di -call restoreparamfrom,di -add di,size datablock -call restorescreenfrom,di +stdcall restoreparamfrom,di +add di,datablock.sizeof +stdcall restorescreenfrom,di add di,[cs:datablock.pagesize] -call restoredacfrom,di +stdcall restoredacfrom,di clc -ret -@@error: +retf +.error: stc -ret -endp restorestate +retf +endp ;sauve le DAC dans un bloc de mémoire -PROC savedac FAR -USES ax,ds,bp +proc savedac uses ax ds bp mov bp,sp push cs pop ds -call [cs:mbcreate],offset data3,3*256 -jc @@error -call [cs:mbchown],ax,[word ptr ss:bp+8] -jc @@error +invoke mbcreate,data3,3*256 +jc .error +invoke mbchown,ax,word [ss:bp+8] +jc .error push ax pop ds -call savedacto,0 +stdcall savedacto,0 clc -ret -@@error: +retf +.error: stc -ret -endp savedac +retf +endp data2 db '/vgadac',0 -;R‚cupŠre le dac depuis son bloc mémoire -PROC restoredac FAR -USES ax,ds,bp +;Récupère le dac depuis son bloc mémoire +proc restoredac uses ax ds bp mov bp,sp -call [cs:mbfindsb],offset data2,[word ptr ss:bp+8] -jc @@error +invoke mbfindsb,data2,word [ss:bp+8] +jc .error push ax pop ds -call restoredacfrom,0 +stdcall restoredacfrom,0 clc -ret -@@error: +retf +.error: stc -ret -endp restoredac +retf +endp ;sauve le DAC en ds:%0 -PROC savedacto FAR -ARG @offset:word -USES ax,cx,dx,di -mov di,[@offset] +proc savedacto uses ax ds bp, offset:word +mov di,[offset] mov dx,3C7h mov cx,256 -@@save: +.save: mov al,cl dec al out dx,al @@ -1310,19 +1255,17 @@ inc di dec dx dec dx dec cx -jne @@save -ret -endp savedacto +jne .save +retf +endp ;restore le DAC depuis ds:si -PROC restoredacfrom FAR -ARG @offset:word -USES ax,cx,dx,si -mov si,[@offset] +proc restoredacfrom uses ax ds bp, offset:word +mov si,[offset] xor ax,ax mov dx,3C8h mov cx,256 -@@save2: +.save2: mov al,cl dec al out dx,al @@ -1338,9 +1281,9 @@ inc si out dx,al dec dx dec cx -jne @@save2 -ret -endp restoredacfrom +jne .save2 +retf +endp