From dc0184f27df6692e4c6200d7f13b3d67cccdb2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sun, 14 Jul 2019 12:47:14 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20correction=20des=20structures=20et=20ent?= =?UTF-8?q?=C3=AAtes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/fat.h | 3 +++ include/mem.h | 41 ++++++++++++++++++++++------------- lib/3d.asm | 2 +- lib/bmp.asm | 3 +-- lib/detect.asm | 2 +- lib/graphic.asm | 2 +- lib/lib.asm | 3 +-- lib/math.asm | 2 +- lib/str0.asm | 2 +- lib/video.asm | 2 +- makefile | 2 +- noyau/8259a.asm | 24 ++++++--------------- noyau/disque.asm | 14 ++++-------- noyau/mcb.asm | 50 ++++++++++++++++--------------------------- noyau/systeme.asm | 2 +- noyau/video.asm | 2 +- programs/commande.asm | 48 +++++++++++------------------------------ programs/editeur.asm | 3 +-- programs/exem.asm | 3 +-- programs/gestion.asm | 3 +-- programs/isa.asm | 3 +-- programs/logo.asm | 3 +-- programs/pmode.asm | 3 +-- programs/souris.asm | 3 +-- programs/test.asm | 3 +-- programs/test2d.asm | 3 +-- programs/test3d.asm | 3 +-- programs/verifier.asm | 3 +-- programs/volume.asm | 3 +-- 29 files changed, 94 insertions(+), 146 deletions(-) diff --git a/include/fat.h b/include/fat.h index c4da409..2b8da04 100644 --- a/include/fat.h +++ b/include/fat.h @@ -39,6 +39,9 @@ struc entries .filesize dd 0 .sizeof = $ - .filename } +virtual at 0 +entries entries +end virtual ;Pour recherches struc find files diff --git a/include/mem.h b/include/mem.h index b53aa34..0a98e20 100644 --- a/include/mem.h +++ b/include/mem.h @@ -25,12 +25,18 @@ struc regs ;.sst6 dt 0 ;.sst7 dt 0 } +virtual at 0 +regs regs +end virtual struc tuple off,seg { .off dw 0 ;adresse .seg dw 0 ;segment } +virtual at 0 +tuple tuple ?,? +end virtual struc vector off,seg { @@ -40,8 +46,11 @@ virtual at .data .sizeof = $ - .data end virtual } +virtual at 0 +vector vector ?,? +end virtual -struc ints ;bloc interruption +struc ints;bloc interruption { .number db 0 ;numero de l'interruption .activated db 0 ;activé ou non @@ -60,6 +69,9 @@ struc ints ;bloc interruption .vector8 vector ? .sizeof = $ - .number } +virtual at 0 +ints ints +end virtual struc mb asize,aname ;Bloc de mémoire { @@ -76,18 +88,21 @@ virtual at 0 mb mb ?,? end virtual -struc exe major +struc exe major,exports,imports,sections,starting ;Executable COS { .checks db "CE" ;signature de l'exe .major db 1 ;N° version .checksum dd 0 ;Checksum de l'exe .compressed db 0 ;a 1 si compressé par RLE -.exports dw 0 ;importation de fonctions -.imports dw 0 ;exportation de fonctions -.sections dw 0 ;sections des blocs mémoire -.starting dw 15 +.exports dw exports ;importation de fonctions +.imports dw imports ;exportation de fonctions +.sections dw sections ;sections des blocs mémoire +.starting dw starting } +virtual at 0 +exe exe ?,?,?,?,? +end virtual struc descriptor limit_low,base_low,base_middle,dpltype,limit_high,base_high { @@ -99,6 +114,9 @@ struc descriptor limit_low,base_low,base_middle,dpltype,limit_high,base_high .base_high db 0 .sizeof = $ - .limit_low } +virtual at 0 +descriptor descriptor ?,?,?,?,?,? +end virtual free equ 0 ;Reference quand libre @@ -163,9 +181,6 @@ macro stdcall proc,[arg] ; directly call STDCALL procedure end if push cs call proc - if size@ccall - add sp,size@ccall - end if } macro invoke proc,[arg] ; directly call STDCALL procedure @@ -178,11 +193,7 @@ macro invoke proc,[arg] ; directly call STDCALL procedure size@ccall = size@ccall+2 common end if - call far [cs:proc] - if size@ccall - add sp,size@ccall - end if - } + call far [cs:proc] } macro proc [args] ; define procedure { common @@ -208,7 +219,7 @@ macro epiloguedef procname,flag,parmbytes,localbytes,reglist if parmbytes | localbytes leave end if - retf } + retf parmbytes } macro define@proc name,statement { local params,flag,regs,parmbytes,localbytes,current diff --git a/lib/3d.asm b/lib/3d.asm index 8bd6b38..cdda48b 100644 --- a/lib/3d.asm +++ b/lib/3d.asm @@ -7,7 +7,7 @@ include "..\include\3d.h" org 0h -header exe 1 +header exe 1,exports,imports,0,0 exporting declare draw3d_point diff --git a/lib/bmp.asm b/lib/bmp.asm index 985aa40..a8386f8 100644 --- a/lib/bmp.asm +++ b/lib/bmp.asm @@ -7,8 +7,7 @@ include "..\include\bmp.h" org 0h -start: -header exe 1 +header exe 1,exports,imports,0,0 exporting declare showbmp diff --git a/lib/detect.asm b/lib/detect.asm index 10e1e47..e60964e 100644 --- a/lib/detect.asm +++ b/lib/detect.asm @@ -7,7 +7,7 @@ include "..\include\pci.h" org 0h -header exe 1 +header exe 1,exports,0,0,0 exporting declare cpuinfo diff --git a/lib/graphic.asm b/lib/graphic.asm index ef7477f..80ad7ed 100644 --- a/lib/graphic.asm +++ b/lib/graphic.asm @@ -6,7 +6,7 @@ include "..\include\graphic.h" org 0h -header exe 1 +header exe 1,exports,imports,0,0 exporting declare hline diff --git a/lib/lib.asm b/lib/lib.asm index 0e5968d..16bc9fa 100644 --- a/lib/lib.asm +++ b/lib/lib.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,exports,0,0,0 waitkey: mov ax,0 diff --git a/lib/math.asm b/lib/math.asm index 54a0d60..c6c4648 100644 --- a/lib/math.asm +++ b/lib/math.asm @@ -5,7 +5,7 @@ include "..\include\mem.h" org 0h -header exe 1 +header exe 1,exports,0,0,0 exporting declare random diff --git a/lib/str0.asm b/lib/str0.asm index 59bfe21..54aaa75 100644 --- a/lib/str0.asm +++ b/lib/str0.asm @@ -6,7 +6,7 @@ include "..\include\divers.h" org 0h -header exe 1 +header exe 1,exports,0,0,0 exporting diff --git a/lib/video.asm b/lib/video.asm index eef7229..186e11e 100644 --- a/lib/video.asm +++ b/lib/video.asm @@ -5,7 +5,7 @@ include "..\include\mem.h" org 0h -header exe 1 +header exe 1,exports,imports,0,0 exporting declare print diff --git a/makefile b/makefile index 60f3e7c..30a831c 100644 --- a/makefile +++ b/makefile @@ -2,7 +2,7 @@ all: boot/boot12.bin lib/3d.lib noyau/systeme.sys programs/commande.ce sync install: - (sudo apt-get install fasm qemu fusefat cgdb) + (sudo apt-get install fasm qemu fusefat gdb) clean: make -C final clean diff --git a/noyau/8259a.asm b/noyau/8259a.asm index 0799eda..eb6b8ba 100644 --- a/noyau/8259a.asm +++ b/noyau/8259a.asm @@ -186,10 +186,7 @@ endp proc installirqhandler uses eax bx cx edx si di ds es push fs - virtual at 0 - .intsori ints - end virtual - stdcall mbcreate,interruptionbloc,256*.intsori.sizeof + stdcall mbcreate,interruptionbloc,256*ints.sizeof mov es,ax mov ax,0x0000 mov ds,ax @@ -198,14 +195,11 @@ proc installirqhandler uses eax bx cx edx si di ds es virtual at si .vector vector end virtual - virtual at 0 - .vectorori vector - end virtual mov fs,[.vector.data.seg] mov bx,[.vector.data.off] cmp byte [fs:bx],0xCF ;iret je .founded - add si,.vectorori.sizeof + add si,vector.sizeof cmp si,256*4 jb .searchdummypointer xor edx,edx @@ -250,8 +244,8 @@ proc installirqhandler uses eax bx cx edx si di ds es add bx,coupling mov [.vector.data.seg],cs mov [.vector.data.off],bx - add si,.vectorori.sizeof - add di,.intsori.sizeof + add si,vector.sizeof + add di,ints.sizeof inc cl cmp cl,0 jne .copy @@ -366,10 +360,7 @@ jc .end mov es,ax mov ax,[int] sub ax,256 -virtual at 0 -.intsorig ints -end virtual -mov cx,.intsorig.sizeof +mov cx,ints.sizeof mul cx mov si,ax virtual at si @@ -387,9 +378,6 @@ mov cl,8 virtual at si .vector vector end virtual -virtual at 0 -.vectorori vector -end virtual cmp [es:.vector.content],0 je .end push word [cs:calling_reg.seflags] @@ -405,7 +393,7 @@ cli stdcall savecontext,calling_reg stdcall restorecontextg,function_reg .next: -add si,.vectorori.sizeof +add si,vector.sizeof dec cl jnz .launchall .end: diff --git a/noyau/disque.asm b/noyau/disque.asm index 4c6e202..f7cad00 100644 --- a/noyau/disque.asm +++ b/noyau/disque.asm @@ -3,7 +3,7 @@ include "..\include\fat.h" org 0h -header exe 1 +header exe 1,exports,imports,0,0 exporting @@ -168,10 +168,7 @@ proc execfile, file:word push cs push .arrive push ds - virtual at 0 - .exe exe - end virtual - push word [.exe.starting] + push word [exe.starting] push ds push ds push ds @@ -579,10 +576,7 @@ proc findnextfile uses ax bx cx di si ds es, pointer:word .findnextfileagain: cmp [es:.find.firstsearch],1 je .first - virtual at 0 - .entries2 entries - end virtual - add bx,.entries2.sizeof + add bx,entries.sizeof cmp bx,[cs:clustersize] jb .nopop .first: @@ -635,7 +629,7 @@ proc findnextfile uses ax bx cx di si ds es, pointer:word .find2 find end virtual lea di,[es:.find2.result] - mov cx,.entries2.sizeof + mov cx,entries.sizeof cld rep movsb clc diff --git a/noyau/mcb.asm b/noyau/mcb.asm index c016e0e..2d5de99 100644 --- a/noyau/mcb.asm +++ b/noyau/mcb.asm @@ -98,10 +98,7 @@ proc flatmode uses eax bx ds add dword [.gdt+2],eax ; store as GDT linear base addr ; now load the GDT into the GDTR lgdt fword [.gdt] ; load GDT base - virtual at 0 - .descriptor descriptor - end virtual - mov bx,1 * .descriptor.sizeof ; point to first descriptor + mov bx,1 * descriptor.sizeof ; point to first descriptor cli ; turn off interrupts mov eax,cr0 ; prepare to enter protected mode or al,1 ; flip the PE bit @@ -138,14 +135,11 @@ proc mbloadsection uses ax bx cx si di ds es, blocks:word mov ax,[blocks] mov es,ax mov ds,ax - cmp word [0],"EC" + cmp word [0],"CE" jne .notace lea si,[toresov] mov word [ss:si],0FFFFh - virtual at 0 - .exe exe - end virtual - mov bx,[ds:.exe.sections] + mov bx,[ds:exe.sections] cmp bx,0 je .finishloading .loading: @@ -229,7 +223,7 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word dec dx dec dx mov gs,dx - cmp word [gs:0x0],'NH' + cmp word [gs:0x0],'HN' je .oktoset mov ax,memorystart .oktoset: @@ -245,7 +239,7 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word cmp dl,false je .notenougtmem mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror cmp [es:mb.isnotlast],true sete dl @@ -254,7 +248,7 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word mov ax,[es:mb.sizes] cmp cx,ax ja .notsogood - mov word [es:mb.check],"NH" + mov word [es:mb.check],"HN" mov [es:mb.isnotlast],true mov [es:mb.reference],gs mov [es:mb.isresident],false @@ -311,7 +305,7 @@ proc mbfree uses ax bx cx si di ds es, blocks:word dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror cmp [es:mb.reference],free je .wasfree @@ -330,7 +324,7 @@ proc mbfree uses ax bx cx si di ds es, blocks:word dec bx .searchtofree: mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror inc bx inc bx @@ -373,7 +367,7 @@ proc mbclean uses ax bx dx es gs xor dx,dx .searchfree: mov gs,bx - cmp word [gs:mb.check],"NH" + cmp word [gs:mb.check],"HN" jne .memoryerror inc bx inc bx @@ -425,7 +419,7 @@ proc mbresident uses bx es, blocks:word dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror mov [es:mb.isresident],true ret @@ -440,7 +434,7 @@ proc mbnonresident uses bx es, blocks:word dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror mov [es:mb.isresident],false ret @@ -456,7 +450,7 @@ proc mbchown uses bx dx es,blocks:word, owner:word dec bx dec bx mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror cmp [es:mb.reference],free je .wasfree @@ -490,7 +484,7 @@ proc mbget uses bx dx es, num:word xor dx,dx .searchfree: mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror inc bx inc bx @@ -526,7 +520,7 @@ proc mbfind uses bx si di es, blocks:word .search: mov es,bx lea di,[es:mb.names] - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror inc bx inc bx @@ -573,7 +567,7 @@ proc mbfindsb uses bx dx si di es, blocks:word, owner:word mov dx,[owner] .search: mov es,bx - cmp word [es:mb.check],"NH" + cmp word [es:mb.check],"HN" jne .memoryerror inc bx inc bx @@ -615,12 +609,9 @@ endp ;Resouds les dépendances du bloc de mémoire %0 proc mbloadfuncs uses ax bx cx dx si ds, blocks:word mov ds,[blocks] - cmp word [0],"EC" + cmp word [0],"CE" jne .notace - virtual at 0 - .exe exe - end virtual - mov si,[ds:.exe.imports] + mov si,[ds:exe.imports] cmp si,0 je .endofloading .loadfuncs: @@ -677,9 +668,6 @@ proc mbsearchfunc uses bx si di es, func:word mov bx,[func] mov si,bx .findend: - virtual at 0 - .exe exe - end virtual inc bx cmp byte [bx], ':' jne .findend @@ -688,9 +676,9 @@ proc mbsearchfunc uses bx si di es, func:word mov byte [bx],':' jc .notfoundattallthesb mov es,ax - cmp word [es:.exe.checks],"EC" + cmp word [es:exe.checks],"CE" jne .notfoundattallthesb - mov di,[es:.exe.exports] + mov di,[es:exe.exports] inc bx inc bx .functions: diff --git a/noyau/systeme.asm b/noyau/systeme.asm index 2cddb7b..0189c05 100644 --- a/noyau/systeme.asm +++ b/noyau/systeme.asm @@ -12,7 +12,7 @@ memorystart equ 0052h ;premier bloc de la m org 0h mb0: -header exe 1 +header exe 1,0,imports,allsection,start start: push cs diff --git a/noyau/video.asm b/noyau/video.asm index b13cc00..bcbbe99 100644 --- a/noyau/video.asm +++ b/noyau/video.asm @@ -6,7 +6,7 @@ include "..\include\graphic.h" org 0h -header exe 1 +header exe 1,exports,imports,0,0 exporting declare setvideomode diff --git a/programs/commande.asm b/programs/commande.asm index 1c209ad..f176353 100644 --- a/programs/commande.asm +++ b/programs/commande.asm @@ -9,8 +9,7 @@ include "..\include\cpu.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke print, msginit @@ -509,33 +508,27 @@ suitelistmcb2: invoke print cmp word [fs:0x0],'EC' jne endofdumpformoment - virtual at 0 - .exe exe - end virtual - push dword [fs:.exe.starting] + push dword [fs:exe.starting] push fs push fs - push dword [fs:.exe.sections] + push dword [fs:exe.sections] push fs push fs - push dword [fs:.exe.imports] + push dword [fs:exe.imports] push fs push fs - push dword [fs:.exe.exports] + push dword [fs:exe.exports] push fs push fs - cmp [fs:.exe.compressed],true + cmp [fs:exe.compressed],true jne notcompressed push oui jmp suiteiscompressed notcompressed: push non suiteiscompressed: - virtual at 0 - .exe exe - end virtual - push dword [fs:.exe.checksum] - push dword [fs:.exe.major] + push dword [fs:exe.checksum] + push dword [fs:exe.major] invoke print, dumpshowce endofdumpformoment: ret @@ -582,10 +575,7 @@ haveatargetsections: mov fs,ax cmp word [fs:0x0],'EC' jne errornotace2 - virtual at 0 - .exe exe - end virtual - mov si,[fs:.exe.sections] + mov si,[fs:exe.sections] cmp si,0 je errornosections xor edx,edx @@ -632,10 +622,7 @@ haveatargetexports: mov fs,ax cmp word [fs:0x0],'EC' jne errornotace2 - virtual at 0 - .exe exe - end virtual - mov si,[fs:.exe.exports] + mov si,[fs:exe.exports] cmp si,0 je errornoexports xor edx,edx @@ -682,10 +669,7 @@ haveatargetimports: mov fs,ax cmp word [fs:0x0],'EC' jne errornotace2 - virtual at 0 - .exe exe - end virtual - mov si,[fs:.exe.imports] + mov si,[fs:exe.imports] cmp si,0 je errornoimports xor edx,edx @@ -818,10 +802,7 @@ xor ebx,ebx intoirq: xor eax,eax mov al,[bx+ irqmap] -virtual at 0 -.intsori ints -end virtual -mov dx,.intsori.sizeof +mov dx,ints.sizeof mul dx mov si,ax virtual at si @@ -902,10 +883,7 @@ mov es,ax invoke gettypeditem,di,0,' ' xor edi,edi mov di,ax -virtual at 0 -.intsori ints -end virtual -mov cx,.intsori.sizeof +mov cx,ints.sizeof mul cx mov si,ax virtual at si diff --git a/programs/editeur.asm b/programs/editeur.asm index 2e007a3..09dded6 100644 --- a/programs/editeur.asm +++ b/programs/editeur.asm @@ -7,8 +7,7 @@ include "..\include\graphic.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: mov ax,0305h diff --git a/programs/exem.asm b/programs/exem.asm index bb6d622..736c8a8 100644 --- a/programs/exem.asm +++ b/programs/exem.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke print,message diff --git a/programs/gestion.asm b/programs/gestion.asm index 50d03ae..fc2825a 100644 --- a/programs/gestion.asm +++ b/programs/gestion.asm @@ -8,8 +8,7 @@ include "..\include\graphic.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke saveparamto, infos diff --git a/programs/isa.asm b/programs/isa.asm index e005e05..563f504 100644 --- a/programs/isa.asm +++ b/programs/isa.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,0,0,0,realstart realstart: retf diff --git a/programs/logo.asm b/programs/logo.asm index af7f272..39de5b4 100644 --- a/programs/logo.asm +++ b/programs/logo.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke mballoc,65535 diff --git a/programs/pmode.asm b/programs/pmode.asm index cc445e6..7047661 100644 --- a/programs/pmode.asm +++ b/programs/pmode.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,0,0,0,realstart realstart: mov eax,cr0 diff --git a/programs/souris.asm b/programs/souris.asm index a5b4f01..14da112 100644 --- a/programs/souris.asm +++ b/programs/souris.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke mouseon diff --git a/programs/test.asm b/programs/test.asm index 8f48fa7..d6f6bb2 100644 --- a/programs/test.asm +++ b/programs/test.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke randomize diff --git a/programs/test2d.asm b/programs/test2d.asm index 2811280..deff632 100644 --- a/programs/test2d.asm +++ b/programs/test2d.asm @@ -8,8 +8,7 @@ include "..\include\3d.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke randomize diff --git a/programs/test3d.asm b/programs/test3d.asm index 86030c6..2abdebe 100644 --- a/programs/test3d.asm +++ b/programs/test3d.asm @@ -8,8 +8,7 @@ include "..\include\3d.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart alldata: camera vertex3d 320.0,240.0,70.0 diff --git a/programs/verifier.asm b/programs/verifier.asm index f761ec0..aecf6b6 100644 --- a/programs/verifier.asm +++ b/programs/verifier.asm @@ -6,8 +6,7 @@ include "..\include\divers.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: invoke savestate diff --git a/programs/volume.asm b/programs/volume.asm index 1ecff11..b76e56c 100644 --- a/programs/volume.asm +++ b/programs/volume.asm @@ -7,8 +7,7 @@ include "..\include\graphic.h" org 0h -start: -header exe 1 +header exe 1,0,imports,0,realstart realstart: mov ax,0305h