replace prologs and epilogs in cdecl functions so far
This commit is contained in:
@@ -54,6 +54,7 @@ init:
|
|||||||
%include "errors.inc"
|
%include "errors.inc"
|
||||||
%include "memory.inc"
|
%include "memory.inc"
|
||||||
%include "partition_table.inc"
|
%include "partition_table.inc"
|
||||||
|
%include "cdecl16.inc"
|
||||||
|
|
||||||
%include "fat32/bpb.inc"
|
%include "fat32/bpb.inc"
|
||||||
%include "fat32/fat32_structures.inc"
|
%include "fat32/fat32_structures.inc"
|
||||||
@@ -136,13 +137,6 @@ main:
|
|||||||
call PrintString
|
call PrintString
|
||||||
add sp, 0x2
|
add sp, 0x2
|
||||||
|
|
||||||
; TODO
|
|
||||||
|
|
||||||
; read elf information and place the sections in the file at the correct location
|
|
||||||
; TODO
|
|
||||||
|
|
||||||
; jump to entry point
|
|
||||||
; TODO
|
|
||||||
ERROR STEVIA_DEBUG_HALT
|
ERROR STEVIA_DEBUG_HALT
|
||||||
|
|
||||||
hcf:
|
hcf:
|
||||||
@@ -155,7 +149,7 @@ hcf:
|
|||||||
;
|
;
|
||||||
; ###############
|
; ###############
|
||||||
|
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
InitFATDriver:
|
InitFATDriver:
|
||||||
push bx
|
push bx
|
||||||
|
|
||||||
@@ -200,6 +194,7 @@ InitFATDriver:
|
|||||||
pop bx
|
pop bx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
; load a file to the high memory buffer for the elf parser
|
; load a file to the high memory buffer for the elf parser
|
||||||
; this involves using the low memory buffer for the bios call and moving the file sector by sector to high memory
|
; this involves using the low memory buffer for the bios call and moving the file sector by sector to high memory
|
||||||
;
|
;
|
||||||
@@ -326,7 +321,7 @@ SearchFATDIR:
|
|||||||
pop di
|
pop di
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
; uint32_t NextCluster(uint32_t active_cluster);
|
; uint32_t NextCluster(uint32_t active_cluster);
|
||||||
; if eax >= 0x0FFFFFF8 then there are no more clusters (end of chain)
|
; if eax >= 0x0FFFFFF8 then there are no more clusters (end of chain)
|
||||||
; if eax == 0x0FFFFFF7 then this is a cluster that is marked as bad
|
; if eax == 0x0FFFFFF7 then this is a cluster that is marked as bad
|
||||||
@@ -403,6 +398,7 @@ NextCluster:
|
|||||||
pop si
|
pop si
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
; uint32_t ClusterToLBA(uint32_t cluster)
|
; uint32_t ClusterToLBA(uint32_t cluster)
|
||||||
ClusterToLBA:
|
ClusterToLBA:
|
||||||
push si
|
push si
|
||||||
@@ -419,6 +415,7 @@ ClusterToLBA:
|
|||||||
pop si
|
pop si
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
||||||
ReadFATCluster:
|
ReadFATCluster:
|
||||||
push si
|
push si
|
||||||
@@ -494,6 +491,7 @@ ReadFATCluster:
|
|||||||
; bp-6 = offset
|
; bp-6 = offset
|
||||||
; bp-8 = segment
|
; bp-8 = segment
|
||||||
; bp-10 = ret ptr
|
; bp-10 = ret ptr
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
read_disk_raw:
|
read_disk_raw:
|
||||||
push si
|
push si
|
||||||
|
|
||||||
@@ -539,13 +537,7 @@ read_disk_raw:
|
|||||||
; Prints a C-Style string (null terminated) using BIOS vga teletype call
|
; Prints a C-Style string (null terminated) using BIOS vga teletype call
|
||||||
; void PrintString(char* buf)
|
; void PrintString(char* buf)
|
||||||
PrintString:
|
PrintString:
|
||||||
push bp
|
__CDECL16_ENTRY
|
||||||
mov bp, sp
|
|
||||||
|
|
||||||
push si
|
|
||||||
push di
|
|
||||||
push bx
|
|
||||||
|
|
||||||
mov di, [bp + 4] ; first arg is char*
|
mov di, [bp + 4] ; first arg is char*
|
||||||
.str_len:
|
.str_len:
|
||||||
xor cx, cx ; ECX = 0
|
xor cx, cx ; ECX = 0
|
||||||
@@ -572,23 +564,13 @@ PrintString:
|
|||||||
jcxz PrintString.endp
|
jcxz PrintString.endp
|
||||||
jmp PrintString.print_L0 ; Fetch next character from string
|
jmp PrintString.print_L0 ; Fetch next character from string
|
||||||
.endp:
|
.endp:
|
||||||
pop bx
|
__CDECL16_EXIT
|
||||||
pop di
|
|
||||||
pop si
|
|
||||||
|
|
||||||
mov sp, bp
|
|
||||||
pop bp
|
|
||||||
ret ; Return from procedure
|
ret ; Return from procedure
|
||||||
|
|
||||||
; Prints a single character
|
; Prints a single character
|
||||||
; void PrintCharacter(char c);
|
; void PrintCharacter(char c);
|
||||||
PrintCharacter:
|
PrintCharacter:
|
||||||
push bp
|
__CDECL_ENTRY
|
||||||
mov bp, sp
|
|
||||||
|
|
||||||
push si
|
|
||||||
push di
|
|
||||||
push bx
|
|
||||||
.func_bios:
|
.func_bios:
|
||||||
mov ax, [bp + 4] ; c
|
mov ax, [bp + 4] ; c
|
||||||
mov dx, 0x00ff
|
mov dx, 0x00ff
|
||||||
@@ -599,14 +581,10 @@ PrintCharacter:
|
|||||||
int 0x10 ; call video interrupt
|
int 0x10 ; call video interrupt
|
||||||
|
|
||||||
.endp:
|
.endp:
|
||||||
pop bx
|
__CDECL16_EXIT
|
||||||
pop di
|
|
||||||
pop si
|
|
||||||
|
|
||||||
mov sp, bp
|
|
||||||
pop bp
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
; prints the hex representation of of val_upper:val_lower (4 byte value)
|
; prints the hex representation of of val_upper:val_lower (4 byte value)
|
||||||
; void PrintDWORD(uint16_t val_upper, uint16_t val_lower);
|
; void PrintDWORD(uint16_t val_upper, uint16_t val_lower);
|
||||||
PrintDWORD:
|
PrintDWORD:
|
||||||
@@ -666,12 +644,7 @@ PrintDWORD:
|
|||||||
; void SetTextMode(void)
|
; void SetTextMode(void)
|
||||||
SetTextMode:
|
SetTextMode:
|
||||||
.prolog:
|
.prolog:
|
||||||
push bp
|
__CDECL16_ENTRY
|
||||||
mov bp, sp
|
|
||||||
|
|
||||||
push si
|
|
||||||
push di
|
|
||||||
push bx
|
|
||||||
pushf
|
pushf
|
||||||
.func:
|
.func:
|
||||||
xor ah, ah ; Set Video mode BIOS function
|
xor ah, ah ; Set Video mode BIOS function
|
||||||
@@ -683,12 +656,7 @@ SetTextMode:
|
|||||||
int 0x10 ; call video interrupt
|
int 0x10 ; call video interrupt
|
||||||
.endp:
|
.endp:
|
||||||
popf
|
popf
|
||||||
pop bx
|
__CDECL16_EXIT
|
||||||
pop di
|
|
||||||
pop si
|
|
||||||
|
|
||||||
mov sp, bp
|
|
||||||
pop bp
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Address Range Descriptor Structure
|
; Address Range Descriptor Structure
|
||||||
@@ -769,6 +737,7 @@ SetTextMode:
|
|||||||
; 1 AddressRangeMemory This run is available RAM usable by the operating system.
|
; 1 AddressRangeMemory This run is available RAM usable by the operating system.
|
||||||
; 2 AddressRangeReserved This run of addresses is in use or reserved by the system, and must not be used by the operating system.
|
; 2 AddressRangeReserved This run of addresses is in use or reserved by the system, and must not be used by the operating system.
|
||||||
; Other Undefined Undefined - Reserved for future use.
|
; Other Undefined Undefined - Reserved for future use.
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
GetMemoryMap:
|
GetMemoryMap:
|
||||||
push es ; save segment registers
|
push es ; save segment registers
|
||||||
|
|
||||||
@@ -846,12 +815,7 @@ GetMemoryMap:
|
|||||||
; disables blinking text mode cursor
|
; disables blinking text mode cursor
|
||||||
disable_cursor:
|
disable_cursor:
|
||||||
.prolog:
|
.prolog:
|
||||||
push bp
|
__CDECL16_ENTRY
|
||||||
mov bp, sp
|
|
||||||
|
|
||||||
push si
|
|
||||||
push di
|
|
||||||
push bx
|
|
||||||
pushf
|
pushf
|
||||||
.func:
|
.func:
|
||||||
mov dx, 0x3D4
|
mov dx, 0x3D4
|
||||||
@@ -863,12 +827,7 @@ disable_cursor:
|
|||||||
out dx, al
|
out dx, al
|
||||||
.endp:
|
.endp:
|
||||||
popf
|
popf
|
||||||
pop bx
|
__CDECL16_EXIT
|
||||||
pop di
|
|
||||||
pop si
|
|
||||||
|
|
||||||
mov sp, bp
|
|
||||||
pop bp
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;
|
;
|
||||||
@@ -920,6 +879,7 @@ disable_cursor:
|
|||||||
; Bits 4-5 - Manufacturer defined
|
; Bits 4-5 - Manufacturer defined
|
||||||
; Bits 6-7 - 00: HDD activity LED off; any other value is "on"
|
; Bits 6-7 - 00: HDD activity LED off; any other value is "on"
|
||||||
;
|
;
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
EnableA20:
|
EnableA20:
|
||||||
push bx
|
push bx
|
||||||
push cx
|
push cx
|
||||||
@@ -1005,7 +965,7 @@ EnableA20:
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; TODO: fix the prolog, epilog and stack usage to confirm with cdecl16
|
||||||
EnterUnrealMode:
|
EnterUnrealMode:
|
||||||
cli ; no interrupts
|
cli ; no interrupts
|
||||||
push ds ; save real mode
|
push ds ; save real mode
|
||||||
|
|||||||
Reference in New Issue
Block a user