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
set disassembly-flavor intel
set architecture i386
set architecture i8086
display/20i $pc+$cs*16
break *0x80010
cont

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,6 @@
use16
align 1
include "..\include\mem.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\divers.h"

View File

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

View File

@ -26,6 +26,10 @@ view: final/cos2000.img
view2: 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
(sleep 2;cgdb -x ./debug/boot.txt)
@ -33,10 +37,10 @@ debug-system: all copy qemu-debug
(sleep 2;cgdb -x ./debug/system.txt)
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-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:
make -C noyau

View File

@ -45,7 +45,7 @@ proc enableirq uses ax cx dx, irq:word
in al,dx
and al,ah
out dx,al
retf
ret
endp
;Desactive une interruption lectronique
@ -66,7 +66,7 @@ proc disableirq uses ax cx dx, irq:word
in al,dx
or al,ah
out dx,al
retf
ret
endp
@ -80,7 +80,7 @@ proc seteoi uses ax dx, irq:word
.master:
mov al,EOI
out MASTERPIC,al
retf
ret
endp
@ -95,7 +95,7 @@ proc readimr uses bx dx, controleur:word
xor ah,ah
in al,dx
pop dx
retf
ret
endp
;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
xor ah,ah
in al,dx
retf
ret
endp
@ -126,7 +126,7 @@ proc readirr uses bx dx, controleur:word
out dx,al
xor ah,ah
in al,dx
retf
ret
endp
;carry si enable et pas carry si pas enable
@ -142,7 +142,7 @@ proc isenableirq uses ax cx dx, irq:word
in al,dx
neg al
bt ax,cx
retf
ret
endp
@ -161,7 +161,7 @@ proc isinserviceirq uses ax cx dx, irq:word
in al,dx
neg al
bt ax,cx
retf
ret
endp
@ -180,7 +180,7 @@ proc isrequestirq uses ax cx dx, irq:word
in al,dx
neg al
bt ax,cx
retf
ret
endp
@ -258,7 +258,7 @@ proc installirqhandler uses eax bx cx edx si di ds es
.end:
pop fs
sti
retf
ret
endp
@ -309,7 +309,7 @@ pop [.regs.secx]
pop [.regs.sebx]
pop [.regs.seax]
pop [.regs.seflags]
retf
ret
endp
proc restorecontextg, pointer:word
@ -332,7 +332,7 @@ mov ds,[cs:.regs.sds]
popfd
pop esi
pop [cs:dummy]
db 0xCA,0x02,0x00 ;retf 2
db 0xCA,0x02,0x00 ;ret 2
endp

View File

@ -20,7 +20,7 @@ proc biosprinth uses ax bx cx edx si di, num:dword
int 10h
dec di
jnz .hexaize
retf
ret
.tab db '0123456789ABCDEF'
endp
@ -42,7 +42,7 @@ proc biosprint uses ax bx cx si, pointer:word
int 10h
jmp .again
.fin:
retf
ret
endp
proc enablea20 uses ax
@ -55,7 +55,7 @@ proc enablea20 uses ax
;mov al,0ffh
;out 64h,al
;call a20wait
retf
ret
endp
proc disablea20 uses ax
@ -68,7 +68,7 @@ proc disablea20 uses ax
;mov al,0ffh
;out 64h,al
;call a20wait
retf
ret
endp
a20wait:
@ -114,7 +114,7 @@ proc flatmode uses eax bx ds
jmp .suite2
.suite2:
sti ; resume handling interrupts
retf ;
ret ;
.gdt:
gdtitse descriptor .gdtend - .gdt - 1, .gdt, 0, 0, 0, 0 ; the GDT itself
@ -126,7 +126,7 @@ endp
proc bioswaitkey uses ax
xor ax,ax
int 16h
retf
ret
endp
firstmb dw 0
@ -184,16 +184,16 @@ popad
dec si
jmp .finishloading
.finishdepands:
retf
ret
.notace:
stc
retf
ret
.error:
stc
retf
ret
.depandserror:
stc
retf
ret
.toresov dw 60 dup (0)
endp
@ -215,10 +215,10 @@ proc mbinit uses ax cx si di ds es
mov cx,.mb.sizeof
rep movsb
clc
retf
ret
.alreadyok:
stc
retf
ret
endp
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
pop gs
clc
retf
ret
.notsogood:
inc bx
inc bx
@ -303,11 +303,11 @@ proc mbcreate uses bx cx dx si di ds es, blocks:word, size:word
.memoryerror:
pop gs
stc
retf
ret
.notenougtmem:
pop gs
stc
retf
ret
endp
;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
je .searchtofree
stdcall mbclean
retf
ret
.memoryerror:
stc
retf
ret
.wasfree:
stc
retf
ret
.wasresident:
stc
retf
ret
.isfree db "libre",0
endp
@ -422,13 +422,13 @@ proc mbclean uses ax bx dx es gs
mov [es:.mb.isnotlast],false
.reallyfinish:
clc
retf
ret
.notenougtmem:
stc
retf
ret
.memoryerror:
stc
retf
ret
endp
;Rend le segment %0 résident
@ -443,10 +443,10 @@ proc mbresident uses bx es, blocks:word
cmp word [es:.mb.check],"NH"
jne .memoryerror
mov [es:.mb.isresident],true
retf
ret
.memoryerror:
stc
retf
ret
endp
;Rend le segment %0 non résident
@ -461,10 +461,10 @@ proc mbnonresident uses bx es, blocks:word
cmp word [es:.mb.check],"NH"
jne .memoryerror
mov [es:.mb.isresident],false
retf
ret
.memoryerror:
stc
retf
ret
endp
@ -483,13 +483,13 @@ proc mbchown uses bx dx es,blocks:word, owner:word
je .wasfree
mov dx,[owner]
mov [es:.mb.reference],dx
retf
ret
.memoryerror:
stc
retf
ret
.wasfree:
stc
retf
ret
endp
;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
stdcall mbcreate,.data,[size]
stdcall mbchown,ax,word [ss:bp+4]
retf
ret
.data db '/data',0
endp
@ -529,16 +529,16 @@ proc mbget uses bx dx es, num:word
je .searchfree
.memoryerror:
stc
retf
ret
.foundmcb:
mov ax,es
inc ax
inc ax
clc
retf
ret
.notfound:
stc
retf
ret
endp
;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
.notfound:
stc
retf
ret
.memoryerror:
stc
retf
ret
.foundmcb:
mov ax,es
inc ax
inc ax
clc
retf
ret
endp
@ -630,16 +630,16 @@ proc mbfindsb uses bx dx si di es, blocks:word, owner:word
je .search
.notfound:
stc
retf
ret
.foundmcb:
mov ax,es
inc ax
inc ax
clc
retf
ret
.memoryerror:
stc
retf
ret
endp
;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
.endofloading:
clc
retf
ret
.notace:
stc
retf
ret
.libnotexist:
stc
retf
ret
.erroronload:
stc
retf
ret
endp
@ -751,8 +751,8 @@ proc mbsearchfunc uses bx si di es, func:word
mov dx,es
mov ax,[es:di+1]
clc
retf
ret
.notfoundattallthesb:
stc
retf
ret
endp

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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