fix: appel stdcall defaillant

This commit is contained in:
Nicolas Hordé 2019-07-13 20:49:22 +02:00
parent 2a7798dfd3
commit 72bf3f35c2
28 changed files with 175 additions and 69 deletions

View File

@ -1,6 +1,6 @@
target remote localhost:1234 target remote localhost:1234
set disassembly-flavor intel set disassembly-flavor intel
set architecture i386 set architecture i8086
display/20i $pc+$cs*16 display/20i $pc+$cs*16
break *0x80010 break *0x80010
cont cont

View File

@ -150,25 +150,35 @@ macro declare fonction*
macro stdcall proc,[arg] ; directly call STDCALL procedure macro stdcall proc,[arg] ; directly call STDCALL procedure
{ {
common common
size@ccall = 0
if ~ arg eq if ~ arg eq
reverse reverse
push arg push arg
size@ccall = size@ccall+2
common common
end if end if
push cs push cs
call proc call proc
if size@ccall
add sp,size@ccall
end if
} }
macro invoke proc,[arg] ; directly call STDCALL procedure macro invoke proc,[arg] ; directly call STDCALL procedure
{ {
common common
size@ccall = 0
if ~ arg eq if ~ arg eq
reverse reverse
push arg push arg
size@ccall = size@ccall+2
common common
end if end if
call far [cs:proc] call far [cs:proc]
if size@ccall
add sp,size@ccall
end if
} }
macro proc [args] ; define procedure macro proc [args] ; define procedure
@ -195,11 +205,7 @@ macro epiloguedef procname,flag,parmbytes,localbytes,reglist
if parmbytes | localbytes if parmbytes | localbytes
leave leave
end if end if
if flag and 10000b retf }
retn
else
retn parmbytes
end if }
macro define@proc name,statement macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current { local params,flag,regs,parmbytes,localbytes,current
@ -211,7 +217,7 @@ macro define@proc name,statement
flag = 11b \} flag = 11b \}
match =params, params \{ params equ statement match =params, params \{ params equ statement
flag = 0 \} flag = 0 \}
virtual at bp+4 virtual at bp+6
match =uses reglist=,args, params \{ regs equ reglist match =uses reglist=,args, params \{ regs equ reglist
params equ args \} params equ args \}
match =regs =uses reglist, regs params \{ regs equ reglist match =regs =uses reglist, regs params \{ regs equ reglist
@ -219,7 +225,7 @@ macro define@proc name,statement
match =regs, regs \{ regs equ \} match =regs, regs \{ regs equ \}
match =,args, params \{ defargs@proc args \} match =,args, params \{ defargs@proc args \}
match =args@proc args, args@proc params \{ defargs@proc args \} match =args@proc args, args@proc params \{ defargs@proc args \}
parmbytes = $ - (bp+4) parmbytes = $ - (bp+6)
end virtual end virtual
name # % = parmbytes/2 name # % = parmbytes/2
all@vars equ all@vars equ
@ -248,7 +254,7 @@ macro define@proc name,statement
current = $-(bp-localbytes) current = $-(bp-localbytes)
end virtual \} end virtual \}
macro ret operand macro ret operand
\{ match any, operand \\{ retn operand \\} \{ match any, operand \\{ retf operand \\}
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \} \\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2 macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\graphic.h" include "..\include\graphic.h"
include "..\include\3d.h" include "..\include\3d.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"
include "..\include\bmp.h" include "..\include\bmp.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\cpu.h" include "..\include\cpu.h"
include "..\include\pci.h" include "..\include\pci.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\graphic.h" include "..\include\graphic.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -0,0 +1,32 @@
use16
align 1
include "..\include\mem.h"
org 0h
header exe 1
exporting
declare random
declare randomize
ende
randseed dw 1234h
proc random uses dx
mov ax,[cs:randseed]
mov dx,8405h
mul dx
inc ax
mov [cs:randseed],ax
mov ax,dx
retf
endp
proc randomize uses ax cx dx
mov ah,0
int 1ah
mov [cs:randseed],dx
retf
endp

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
org 0h org 0h

View File

@ -26,6 +26,10 @@ view: final/cos2000.img
view2: boot/boot12.bin view2: boot/boot12.bin
(objdump -D -b binary -mi386 -Maddr16,data16 ./boot/boot12.bin) (objdump -D -b binary -mi386 -Maddr16,data16 ./boot/boot12.bin)
debug: debug-system
redebug: clean debug
debug-boot: all copy qemu-debug debug-boot: all copy qemu-debug
(sleep 2;cgdb -x ./debug/boot.txt) (sleep 2;cgdb -x ./debug/boot.txt)
@ -33,10 +37,10 @@ debug-system: all copy qemu-debug
(sleep 2;cgdb -x ./debug/system.txt) (sleep 2;cgdb -x ./debug/system.txt)
qemu-debug: qemu-debug:
(qemu-system-i386 -m 1G -fda ./final/cos2000.img -s -S &) (killall qemu-system-i386;qemu-system-i386 -m 1G -fda ./final/cos2000.img -s -S &)
qemu: qemu:
(qemu-system-i386 -m 1G -fda ./final/cos2000.img -s) (killall qemu-system-i386;qemu-system-i386 -m 1G -fda ./final/cos2000.img -s)
noyau/systeme.sys: noyau/systeme.sys:
make -C noyau make -C noyau

View File

@ -45,7 +45,7 @@ proc enableirq uses ax cx dx, irq:word
in al,dx in al,dx
and al,ah and al,ah
out dx,al out dx,al
retf ret
endp endp
;Desactive une interruption lectronique ;Desactive une interruption lectronique
@ -66,7 +66,7 @@ proc disableirq uses ax cx dx, irq:word
in al,dx in al,dx
or al,ah or al,ah
out dx,al out dx,al
retf ret
endp endp
@ -80,7 +80,7 @@ proc seteoi uses ax dx, irq:word
.master: .master:
mov al,EOI mov al,EOI
out MASTERPIC,al out MASTERPIC,al
retf ret
endp endp
@ -95,7 +95,7 @@ proc readimr uses bx dx, controleur:word
xor ah,ah xor ah,ah
in al,dx in al,dx
pop dx pop dx
retf ret
endp endp
;Lit le registre d'tat d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1 ;Lit le registre d'tat d'un contr“leur IRQ dans ax, 0 master ou slave 1 ds %1
@ -110,7 +110,7 @@ proc readisr uses bx dx, controleur:word
out dx,al out dx,al
xor ah,ah xor ah,ah
in al,dx in al,dx
retf ret
endp endp
@ -126,7 +126,7 @@ proc readirr uses bx dx, controleur:word
out dx,al out dx,al
xor ah,ah xor ah,ah
in al,dx in al,dx
retf ret
endp endp
;carry si enable et pas carry si pas enable ;carry si enable et pas carry si pas enable
@ -142,7 +142,7 @@ proc isenableirq uses ax cx dx, irq:word
in al,dx in al,dx
neg al neg al
bt ax,cx bt ax,cx
retf ret
endp endp
@ -161,7 +161,7 @@ proc isinserviceirq uses ax cx dx, irq:word
in al,dx in al,dx
neg al neg al
bt ax,cx bt ax,cx
retf ret
endp endp
@ -180,7 +180,7 @@ proc isrequestirq uses ax cx dx, irq:word
in al,dx in al,dx
neg al neg al
bt ax,cx bt ax,cx
retf ret
endp endp
@ -258,7 +258,7 @@ proc installirqhandler uses eax bx cx edx si di ds es
.end: .end:
pop fs pop fs
sti sti
retf ret
endp endp
@ -309,7 +309,7 @@ pop [.regs.secx]
pop [.regs.sebx] pop [.regs.sebx]
pop [.regs.seax] pop [.regs.seax]
pop [.regs.seflags] pop [.regs.seflags]
retf ret
endp endp
proc restorecontextg, pointer:word proc restorecontextg, pointer:word
@ -332,7 +332,7 @@ mov ds,[cs:.regs.sds]
popfd popfd
pop esi pop esi
pop [cs:dummy] pop [cs:dummy]
db 0xCA,0x02,0x00 ;retf 2 db 0xCA,0x02,0x00 ;ret 2
endp endp

View File

@ -20,7 +20,7 @@ proc biosprinth uses ax bx cx edx si di, num:dword
int 10h int 10h
dec di dec di
jnz .hexaize jnz .hexaize
retf ret
.tab db '0123456789ABCDEF' .tab db '0123456789ABCDEF'
endp endp
@ -42,7 +42,7 @@ proc biosprint uses ax bx cx si, pointer:word
int 10h int 10h
jmp .again jmp .again
.fin: .fin:
retf ret
endp endp
proc enablea20 uses ax proc enablea20 uses ax
@ -55,7 +55,7 @@ proc enablea20 uses ax
;mov al,0ffh ;mov al,0ffh
;out 64h,al ;out 64h,al
;call a20wait ;call a20wait
retf ret
endp endp
proc disablea20 uses ax proc disablea20 uses ax
@ -68,7 +68,7 @@ proc disablea20 uses ax
;mov al,0ffh ;mov al,0ffh
;out 64h,al ;out 64h,al
;call a20wait ;call a20wait
retf ret
endp endp
a20wait: a20wait:
@ -114,7 +114,7 @@ proc flatmode uses eax bx ds
jmp .suite2 jmp .suite2
.suite2: .suite2:
sti ; resume handling interrupts sti ; resume handling interrupts
retf ; ret ;
.gdt: .gdt:
gdtitse descriptor .gdtend - .gdt - 1, .gdt, 0, 0, 0, 0 ; the GDT itself gdtitse descriptor .gdtend - .gdt - 1, .gdt, 0, 0, 0, 0 ; the GDT itself
@ -126,7 +126,7 @@ endp
proc bioswaitkey uses ax proc bioswaitkey uses ax
xor ax,ax xor ax,ax
int 16h int 16h
retf ret
endp endp
firstmb dw 0 firstmb dw 0
@ -184,16 +184,16 @@ popad
dec si dec si
jmp .finishloading jmp .finishloading
.finishdepands: .finishdepands:
retf ret
.notace: .notace:
stc stc
retf ret
.error: .error:
stc stc
retf ret
.depandserror: .depandserror:
stc stc
retf ret
.toresov dw 60 dup (0) .toresov dw 60 dup (0)
endp endp
@ -215,10 +215,10 @@ proc mbinit uses ax cx si di ds es
mov cx,.mb.sizeof mov cx,.mb.sizeof
rep movsb rep movsb
clc clc
retf ret
.alreadyok: .alreadyok:
stc stc
retf ret
endp endp
afree mb "HN",0,0,0,0A000h-memorystart,"Libre" afree mb "HN",0,0,0,0A000h-memorystart,"Libre"
@ -294,7 +294,7 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word
mov ax,bx mov ax,bx
pop gs pop gs
clc clc
retf ret
.notsogood: .notsogood:
inc bx inc bx
inc bx inc bx
@ -303,11 +303,11 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word
.memoryerror: .memoryerror:
pop gs pop gs
stc stc
retf ret
.notenougtmem: .notenougtmem:
pop gs pop gs
stc stc
retf ret
endp endp
;Libère le bloc de mémoire %0 et ses sous blocs ;Libère le bloc de mémoire %0 et ses sous blocs
@ -359,16 +359,16 @@ proc mbfree uses ax bx cx si di ds es, blocks:word
cmp [es:.mb.isnotlast],true cmp [es:.mb.isnotlast],true
je .searchtofree je .searchtofree
stdcall mbclean stdcall mbclean
retf ret
.memoryerror: .memoryerror:
stc stc
retf ret
.wasfree: .wasfree:
stc stc
retf ret
.wasresident: .wasresident:
stc stc
retf ret
.isfree db "libre",0 .isfree db "libre",0
endp endp
@ -422,13 +422,13 @@ proc mbclean uses ax bx dx es gs
mov [es:.mb.isnotlast],false mov [es:.mb.isnotlast],false
.reallyfinish: .reallyfinish:
clc clc
retf ret
.notenougtmem: .notenougtmem:
stc stc
retf ret
.memoryerror: .memoryerror:
stc stc
retf ret
endp endp
;Rend le segment %0 résident ;Rend le segment %0 résident
@ -443,10 +443,10 @@ proc mbresident uses bx es, blocks:word
cmp word [es:.mb.check],"NH" cmp word [es:.mb.check],"NH"
jne .memoryerror jne .memoryerror
mov [es:.mb.isresident],true mov [es:.mb.isresident],true
retf ret
.memoryerror: .memoryerror:
stc stc
retf ret
endp endp
;Rend le segment %0 non résident ;Rend le segment %0 non résident
@ -461,10 +461,10 @@ proc mbnonresident uses bx es, blocks:word
cmp word [es:.mb.check],"NH" cmp word [es:.mb.check],"NH"
jne .memoryerror jne .memoryerror
mov [es:.mb.isresident],false mov [es:.mb.isresident],false
retf ret
.memoryerror: .memoryerror:
stc stc
retf ret
endp endp
@ -483,13 +483,13 @@ proc mbchown uses bx dx es,blocks:word, owner:word
je .wasfree je .wasfree
mov dx,[owner] mov dx,[owner]
mov [es:.mb.reference],dx mov [es:.mb.reference],dx
retf ret
.memoryerror: .memoryerror:
stc stc
retf ret
.wasfree: .wasfree:
stc stc
retf ret
endp endp
;Alloue un bloc /data de CX caractere pour le process appelant -> ax ;Alloue un bloc /data de CX caractere pour le process appelant -> ax
@ -498,7 +498,7 @@ proc mballoc uses si ds, size:word
pop ds pop ds
stdcall mbcreate,.data,[size] stdcall mbcreate,.data,[size]
stdcall mbchown,ax,word [ss:bp+4] stdcall mbchown,ax,word [ss:bp+4]
retf ret
.data db '/data',0 .data db '/data',0
endp endp
@ -529,16 +529,16 @@ proc mbget uses bx dx es, num:word
je .searchfree je .searchfree
.memoryerror: .memoryerror:
stc stc
retf ret
.foundmcb: .foundmcb:
mov ax,es mov ax,es
inc ax inc ax
inc ax inc ax
clc clc
retf ret
.notfound: .notfound:
stc stc
retf ret
endp endp
;Renvoie en AX le MCB qui correspond a ds:%0 ;Renvoie en AX le MCB qui correspond a ds:%0
@ -577,16 +577,16 @@ proc mbfind uses bx si di es, blocks:word
je .search je .search
.notfound: .notfound:
stc stc
retf ret
.memoryerror: .memoryerror:
stc stc
retf ret
.foundmcb: .foundmcb:
mov ax,es mov ax,es
inc ax inc ax
inc ax inc ax
clc clc
retf ret
endp endp
@ -630,16 +630,16 @@ proc mbfindsb uses bx dx si di es, blocks:word, owner:word
je .search je .search
.notfound: .notfound:
stc stc
retf ret
.foundmcb: .foundmcb:
mov ax,es mov ax,es
inc ax inc ax
inc ax inc ax
clc clc
retf ret
.memoryerror: .memoryerror:
stc stc
retf ret
endp endp
;Resouds les dépendances du bloc de mémoire %0 ;Resouds les dépendances du bloc de mémoire %0
@ -689,16 +689,16 @@ proc mbloadfuncs uses ax bx cx dx si ds, blocks:word
jmp .loadfuncs jmp .loadfuncs
.endofloading: .endofloading:
clc clc
retf ret
.notace: .notace:
stc stc
retf ret
.libnotexist: .libnotexist:
stc stc
retf ret
.erroronload: .erroronload:
stc stc
retf ret
endp endp
@ -751,8 +751,8 @@ proc mbsearchfunc uses bx si di es, func:word
mov dx,es mov dx,es
mov ax,[es:di+1] mov ax,[es:di+1]
clc clc
retf ret
.notfoundattallthesb: .notfoundattallthesb:
stc stc
retf ret
endp endp

View File

@ -1,3 +1,5 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\graphic.h" include "..\include\graphic.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\fat.h" include "..\include\fat.h"
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"
include "..\include\graphic.h" include "..\include\graphic.h"

View File

@ -1,3 +1,5 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\fat.h" include "..\include\fat.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\fat.h" include "..\include\fat.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\fat.h" include "..\include\fat.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.h" include "..\include\mem.h"
include "..\include\divers.h" include "..\include\divers.h"
include "..\include\graphic.h" include "..\include\graphic.h"