From d24ead1dd6eb8463c32ce571af4e60a7e835568c Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 14 Oct 1998 21:28:45 +0000 Subject: [PATCH] * initialize fpu so sigfpe is finally generated for fpu errors --- rtl/dos/go32v2/v2prt0.as | 429 ++++----------------------------------- rtl/linux/i386/cprt1.as | 133 ++++++------ rtl/linux/i386/gprt0.as | 92 +++++---- rtl/linux/i386/gprt1.as | 107 +++++----- rtl/linux/i386/prt0.as | 62 +++--- rtl/linux/i386/prt1.as | 85 ++++---- 6 files changed, 303 insertions(+), 605 deletions(-) diff --git a/rtl/dos/go32v2/v2prt0.as b/rtl/dos/go32v2/v2prt0.as index b536e4d31e..bab9244f96 100644 --- a/rtl/dos/go32v2/v2prt0.as +++ b/rtl/dos/go32v2/v2prt0.as @@ -11,9 +11,9 @@ * ss:sp our stack (ss to be freed) * All unspecified registers have unspecified values in them. \*****************************************************************************/ -/* modified by Pierre Muller to become the prt0.s for FPK Pascal */ +/* modified by Pierre Muller to become the prt0.s for FPC Pascal */ - .file "v2prt0.s" + .file "v2prt0.as" /* #include "stubinfo.h" */ STUBINFO = 0 @@ -43,26 +43,19 @@ .comm ___djgpp_selector_limit, 4 .comm ___djgpp_stack_limit, 4 .lcomm sel_buf, 8 + /* ___djgpp_ds_alias defined in go32/exceptn.s */ /* inserted at the end of this file */ /* we use a local copy that will be copied to exceptn.s */ - .globl ___v2prt0_ds_alias + .globl ___v2prt0_ds_alias ___v2prt0_ds_alias: - .long 0 -/* .comm ___djgpp_ds_alias, 4 must be in locked code */ -/* undef MULTIBLOCK */ -/* MULTIBLOCK = 0 does not work */ -/* Win95 sometimes gives a block at an address lower than the base -address of _djgpp => big troubles - That is why I removed the multiblocks - Pierre Muller */ - .data + .long 0 + +.data -/* .ifdef MULTIBLOCK needed anyhow */ ___djgpp_memory_handle_pointer: .long ___djgpp_memory_handle_list+8 /* Next free, first for stub */ .comm ___djgpp_memory_handle_list, 2048 /* Enough for 256 handles */ -/* .endif */ sbrk16_first_byte: .include "sbrk16.ah" @@ -82,31 +75,17 @@ exit16_last_byte: /* hook_387_emulator: .long ___emu387_load_hook */ -/* this pulls in the ident string, generated in .. */ -/* .long ___libc_ident_string */ - /* this is for when main comes from a library */ .long _main - .text + +.text .globl start start: - pushl %ds /* set %es same as %ds */ popl %es /* push/pop 4 bytes shorter than ax */ -.if 0 /* we do this in the stub now */ - movl $edata, %edi /* set all BSS bytes to zero */ - movl $end, %ecx - subl %edi, %ecx - xorl %eax, %eax /* Zero fill value */ - shrl $2, %ecx /* div 4 Longwords not bytes */ - cld - rep - stosl -.endif - /* Enable NULL pointer protection if DPMI supports it */ testb $0x1, __crt0_startup_flags+1 /* include/crt0.h */ jnz 1f @@ -129,6 +108,7 @@ start: jnc ds_alias_ok movb $0x4c, %ah int $0x21 + ds_alias_ok: movw %ax, ___v2prt0_ds_alias movl %eax, %ebx @@ -157,10 +137,6 @@ ds_alias_ok: jz 2f andb $0x7f, __crt0_startup_flags /* clear it if failure */ 2: -.ifdef MULTIBLOCK - testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ - jz 8f -.endif /* Allocate some DOS memory and copy our sbrk helper into it. */ movl $sbrk16_first_byte, %esi movzwl 8(%esi), %ebx @@ -170,6 +146,7 @@ ds_alias_ok: jnc dos_alloc_ok movb $0x4c, %ah int $0x21 + dos_alloc_ok: movw %cs, 2(%esi) /* store API information */ @@ -208,21 +185,6 @@ dos_alloc_ok: movw $0x000c, %ax /* set descriptor */ movl $sel_buf, %edi int $0x31 -.ifdef MULTIBLOCK -8: movl $___djgpp_memory_handle_list+8, %edi - movl %edi, ___djgpp_memory_handle_pointer - xorl %eax, %eax -9: cmpl %eax, (%edi) - je 10f - mov %eax, (%edi) - addl $4, %edi - jmp 9b -10: movw %cs, %bx - movw $0x0006,%ax - int $0x31 - movl %edx,___djgpp_base_address - movw %cx,___djgpp_base_address+2 -.endif /* MULTIBLOCK */ /* Initialize the brk/sbrk variables */ @@ -279,25 +241,6 @@ use_stubinfo_stack_size: movl %eax,__stkbottom /* for stack checks */ movl %eax,U_SYSTEM_STACKBOTTOM -.ifdef LOCK_BOTTOM_STACK -/* test lock one page at bottom of stack to be sure that there is */ -/* not stack overflow, as the minimal size is 128 ko 4ko less is not much !! */ - testb $0x1, __crt0_startup_flags+1 /* include/crt0.h */ - jnz 101f /* just to be sure it is not used */ - movl %eax, %ebx /* Offset __djgpp_stack_limit in mem block */ - addl $0xfff,%ebx - andl $0xfffff000,%ebx /* page align it */ - movw $0x507, %ax -.ifdef MULTIBLOCK - movl ___djgpp_memory_handle_pointer-8, %esi /* last memory block */ -.else /* not MULTIBLOCK */ - movl ___djgpp_memory_handle_list, %esi /* last memory block */ -.endif - movl $1, %ecx /* Set one page */ - movl $zero, %edx - int $0x31 /* Make first stack page page uncommitted */ -101: -.endif /* LOCK_BOTTOM_STACK */ movl ___djgpp_stack_limit,%eax /* Bottom of stack */ addl __stklen, %eax movw %ds, %dx /* set stack */ @@ -305,27 +248,6 @@ use_stubinfo_stack_size: movl %eax, %esp xorl %ebp, %ebp -.if 0 /* done in crt1.c */ - .byte 0x64 /* fs: */ /* set up _go32_info_block structure */ - movzwl STUBINFO_MINKEEP, %eax - movl %eax, U_SYSTEM_GO32_INFO_BLOCK+16 /* .size_of_transfer_buffer */ - .byte 0x64 /* fs: */ - movzwl STUBINFO_DS_SEGMENT, %eax - shll $4, %eax - movl %eax, U_SYSTEM_GO32_INFO_BLOCK+12 /* .linear_address_of_transfer_buffer */ - xorl %eax, %eax - movl $1, %ecx - int $0x31 - jc no_selector - movw %ax, U_SYSTEM_GO32_INFO_BLOCK+26 /* .selector_for_linear_memory */ - movl %eax, %ebx - movl $8, %eax - movl $0x0f, %ecx - movw $0xffff, %dx - int $0x31 /* Set limit 1Mb */ -no_selector: -.endif - call ___prt1_startup /* run program */ jmp exit @@ -363,10 +285,6 @@ exit: cli /* Just in case they didn't unhook ints */ FREESEL U_SYSTEM_GO32_INFO_BLOCK+26 /* selector for linear memory */ FREESEL ___v2prt0_ds_alias /* DS alias for rmcb exceptions */ -.ifdef MULTIBLOCK - testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ - jz 9f -.endif FREESEL sbrk16_api_seg /* sbrk cs */ movw sbrk16_first_byte+6,%dx /* selector for allocated DOS mem */ movw $0x101, %ax @@ -390,17 +308,6 @@ exit: movw %ax,%ss movl $0x400,%esp /* Transfer buffer >= 1024 bytes */ -.ifdef MULTIBLOCK - movl ___djgpp_memory_handle_pointer, %ebx - jmp 7f -6: subl $8, %ebx - movl (%ebx), %edi - movw 2(%ebx), %si - movw $0x502, %ax - int $0x31 -7: cmpl $___djgpp_memory_handle_list+8, %ebx - jne 6b -.endif /* MULTIBLOCK */ xorl %ebp, %ebp /* V1.10 bug fix */ movl ___djgpp_memory_handle_list, %edi movl ___djgpp_memory_handle_list+2, %esi /* Skip word prefixes */ @@ -436,14 +343,6 @@ lock_memory: 13: ret $4 /* Pop the argument */ -.if 0 -brk_hook_ret: - ret - .globl ___sbrk_brk_hook -___sbrk_brk_hook: - .long brk_hook_ret -.endif - .global ___sbrk .align 2 ___sbrk: @@ -451,7 +350,7 @@ ___sbrk: movl 4(%esp), %ecx /* Increment size */ addl %ecx, %eax jnc brk_common - /* Carry is only set if a negative increment or wrap happens. Negative + /* Carry is only set if a negative increment or wrap happens. Negative increment is semi-OK, wrap (only for multiple zone sbrk) isn't. */ test $0x80000000, %ecx /* Clears carry */ jnz brk_common @@ -477,10 +376,6 @@ brk_common: cmpl __what_size_dpmi_thinks_we_are, %eax /* don't bother shrinking */ jbe brk_nochange -.ifdef MULTIBLOCK - testb $0x8, __crt0_startup_flags+1 /* include/crt0.h */ - jz 10f -.endif addl $0x0000ffff, %eax /* round up to 64K block */ andl $0xffff0000, %eax push %eax /* size - save for later */ @@ -521,54 +416,6 @@ brk_common: call lock_memory decl %edx /* limit now, not size */ -.ifdef MULTIBLOCK - jmp 5f -/* Current allocation not large enough, get another block */ -10: movl %ecx, %eax /* Add amt */ - pushl %eax /* Save orig */ - addl $0x0000ffff, %eax /* round up to 64K block */ - andl $0xffff0000, %eax - movl %eax, %edx /* Save size */ - movl %eax, %ecx - movl %eax, %ebx - shrl $16, %ebx /* BX:CX size */ - movw $0x501,%ax - int $0x31 - popl %eax /* Orig size */ - jc brk_error - - pushl %edx /* Size */ - call lock_memory - - pushw %bx - pushw %cx - popl %ecx /* Linear address */ - /* What if the new base address is lower than __djgpp_base_address !!! */ - subl ___djgpp_base_address, %ecx /* New dpmi size */ - cmpl %ecx, __what_size_dpmi_thinks_we_are /* Back to back ? */ - je 4f - movl %ecx, __what_size_dpmi_thinks_we_are - movl %ecx, __what_we_return_to_app_as_old_size -4: - movl __what_we_return_to_app_as_old_size, %ebx /* Base for new block */ - addl %ebx, %eax /* Final address */ - movl %eax, __what_size_app_thinks_it_is -/* Note - save adjusted memory base and memory handle SI:DI here */ - movl ___djgpp_memory_handle_pointer, %ebx - movl %edi, (%ebx) - movw %si, 2(%ebx) - movl %ecx, 4(%ebx) - addl $8, %ebx - cmpl $___djgpp_memory_handle_list+2040, %ebx /* At end? */ - je 11f - movl %ebx, ___djgpp_memory_handle_pointer /* Only if not at end */ -11: - addl %ecx, %edx /* Final address */ - decl %edx /* Limit to end */ -/* If we get a block at a lower address we must skip the limit change */ - cmpl ___djgpp_selector_limit, %edx - jbe 12f -.endif 5: movl %edx, ___djgpp_selector_limit orw $0x0fff, %dx /* low bits set */ movw $0x0008, %ax /* reset CS limit */ @@ -615,14 +462,6 @@ no_deadbeef: no_fill_sbrk_memory: movl %edx, __what_size_dpmi_thinks_we_are -.if 0 /* No purpose */ - pushl ___djgpp_memory_handle_list - pushl ___djgpp_base_address - movl ___sbrk_brk_hook, %eax - call %eax - addl $8, %esp -.endif - brk_nochange: /* successful return */ movl __what_we_return_to_app_as_old_size, %eax jmp brk_return @@ -638,14 +477,6 @@ brk_return: popl %esi ret - .globl __crt0_init_mcount -__crt0_init_mcount: -.ifdef IN_GCRT0 - jmp __mcount_init -.else - ret -.endif - /* From here on this are parts of crt1.c converted to assembler and without any call to libc, so that it works without anything else additions made by Pierre Muller*/ @@ -675,7 +506,7 @@ additions made by Pierre Muller*/ /* .globl ___dpmi_allocate_ldt_descriptors */ /* using pascal convention => not usabel by C code */ ___dpmi_allocate_ldt_descriptors: - pushl %ebp; movl %esp,%ebp + pushl %ebp; movl %esp,%ebp movl 8(%ebp), %ecx movl $0x0000, %eax @@ -802,7 +633,6 @@ _setup_screens: movw %dx, %gs .byte 0x65 movw (%ecx),%ax - /NO_APP cmpw $64896,%ax jne .L26 @@ -830,6 +660,7 @@ _setup_screens: movl $720896,U_SYSTEM_GO32_INFO_BLOCK+8 leave ret + .align 2 .globl _setup_go32_info_block _setup_go32_info_block: @@ -866,7 +697,7 @@ _setup_go32_info_block: call copy_to_c_go32_info_block leave ret - + copy_to_c_go32_info_block: leal U_SYSTEM_GO32_INFO_BLOCK,%esi leal __go32_info_block,%edi @@ -874,18 +705,19 @@ copy_to_c_go32_info_block: rep movsl ret + .data -/* __go32_info_block for C programs */ + /* fpu codeword */ +___fpucw: + .long 0x1332 + /* __go32_info_block for C programs */ .align 2 .globl __go32_info_block .comm __go32_info_block,40 - .globl ___PROXY -___PROXY: - .ascii " !proxy\0" - .globl ___PROXY_LEN - .align 2 -___PROXY_LEN: - .long 7 + +/* + -- prt1_startup -- +*/ .text .align 2 .globl ___prt1_startup @@ -898,42 +730,24 @@ ___prt1_startup: call _setup_core_selector call _setup_screens call _setup_go32_info_block -/* call ___djgpp_exception_setup - call _setup_ENVPment */ incl ___environ_changed -/* pushl $0 - call __use_lfn - addl $4,%esp - call ___crt0_setup_arguments - movl ___crt0_argv,%eax - testl %eax,%eax - je .L55 - movl (%eax),%ebx - jmp .L56 - .align 2,0x90 -.L55: - movl U_SYSTEM_DOS_ARGV0,%ebx -.L56: - pushl %ebx - call ___crt0_load_ENVPment_file - pushl $0 - call __use_lfn - pushl %ebx - call __npxsetup - call __crt0_init_mcount - call ___main */ - pushl U_SYSTEM_ENVP - pushl ___crt0_argv - pushl ___crt0_argc - call _pascal_start - pushl %eax + + finit /* initialize fpu */ + fwait + fldcw ___fpucw + + pushl U_SYSTEM_ENVP + pushl ___crt0_argv + pushl ___crt0_argc + call _pascal_start + pushl %eax /* call _exit changed to */ - call exit + call exit .align 2,0x90 /* .comm U_SYSTEM_DOS_ARGV0,4 */ -.comm ___dos_argv0,4 -.comm ___crt0_argc,4 -.comm ___crt0_argv,4 + .comm ___dos_argv0,4 + .comm ___crt0_argc,4 + .comm ___crt0_argv,4 .globl ___environ_changed ___environ_changed: .long 0 @@ -949,165 +763,6 @@ _swap_out: .global _v2prt0_exceptions_on _v2prt0_exceptions_on: .long 0 -/*.comm __crt0_startup_flags,4 - .comm U_SYSTEM_ENVP,4 */ - -.ifdef test_go32v1 -# -# Called as start(argc, argv, envp) -# -# gs:edx points to prog_info structure. All other registers are OBSOLETE -# but included for backwards compatibility -# - - .text - .globl old_start -old_start: - popl %ebx - popl %eax - movl %eax,__hard_master - movl %esi,___pid - movl %edi,___transfer_buffer - movl %ebx,_ScreenPrimary - movl %ebp,_ScreenSecondary - - cmpl $0, %edx - je Lcopy_none - movw %gs,%cx - movw %ds,%ax - cmpw %cx,%ax - je Lcopy_none - - movl %gs:(%edx), %ecx - cmpl U_SYSTEM_GO32_INFO_BLOCK, %ecx - jbe Lcopy_less - movl U_SYSTEM_GO32_INFO_BLOCK, %ecx -Lcopy_less: - movl $U_SYSTEM_GO32_INFO_BLOCK, %edi - addl $3, %ecx - andl $0xfffffffc, %ecx - movl %ecx, (%edi) - addl $4, %edi - addl $4, %edx - subl $4, %ecx -Lcopy_more: - movl %gs:(%edx), %eax - movl %eax, (%edi) - addl $4, %edx - addl $4, %edi - subl $4, %ecx - jnz Lcopy_more - - movl U_SYSTEM_GO32_INFO_BLOCK+4, %eax - movl %eax, _ScreenPrimary - movl U_SYSTEM_GO32_INFO_BLOCK+8, %eax - movl %eax, _ScreenSecondary - movl U_SYSTEM_GO32_INFO_BLOCK+12, %eax - movl %eax, ___transfer_buffer - movl U_SYSTEM_GO32_INFO_BLOCK+20, %eax - movl %eax, ___pid - movl U_SYSTEM_GO32_INFO_BLOCK+24, %eax - movl %eax, __hard_master - - jmp Lcopy_done - -Lcopy_none: - movl %ebx,U_SYSTEM_GO32_INFO_BLOCK+4 - movl %ebp,U_SYSTEM_GO32_INFO_BLOCK+8 - movl %edi,U_SYSTEM_GO32_INFO_BLOCK+12 - movl $4096,U_SYSTEM_GO32_INFO_BLOCK+16 - movl %esi,U_SYSTEM_GO32_INFO_BLOCK+20 - movl %eax,U_SYSTEM_GO32_INFO_BLOCK+24 - movl $28, U_SYSTEM_GO32_INFO_BLOCK -Lcopy_done: - - movw U_SYSTEM_GO32_INFO_BLOCK+36,%ax - movw %ax,_run_mode - cmpw $4,%ax - jne CanOnlyRunDPMI - call Correct_tbaddress -LtbaddressOK: - movw U_SYSTEM_GO32_INFO_BLOCK+26,%ax - movw %ax,_core_selector - /* core selector in %fs */ - movw %ax,%fs - xorl %esi,%esi - xorl %edi,%edi - xorl %ebp,%ebp - xorl %ebx,%ebx - - movl %esp,%ebx - movl $0x0,%ebp - movl %esp,%ebx - movl 8(%ebx),%eax - movl %eax,U_SYSTEM_ENVP - movl 4(%ebx),%eax - movl %eax,_args - movl (%ebx),%eax - movl %eax,_argc - - call PASCALMAIN - - -exit_again: - movl $0x4c00,%eax - int $0x21 - jmp exit_again - - ret - -Correct_tbaddress: - movl ___transfer_buffer,%eax - addl $1,%eax - andl $0xFFFFF,%eax - movl %eax,___transfer_buffer - movl %eax,U_SYSTEM_GO32_INFO_BLOCK+12 - ret -CanOnlyRunDPMI: - movl $0x4c01,%eax - int $0x21 - jmp exit_again - - .ascii "Can only run in DPMI " - -/* .data - .globl _argc -_argc: - .long 0 - .globl _args -_args: - .long 0 - .globl _run_mode -_run_mode: - .word 0 - .globl _core_selector -_core_selector: - .word 0 - .globl _ENVP -_ENVP: - .long 0 */ - - .globl ___pid -___pid: - .long 42 - - .globl ___transfer_buffer -___transfer_buffer: - .long 0 - - .globl _ScreenSecondary -_ScreenSecondary: - .long 0 - - .globl __hard_master - .globl __hard_slave - .globl __core_select -__hard_master: - .byte 0 -__hard_slave: - .byte 0 - -.endif /* test_go32v1 */ /* this was the prt0.s from the go32v1 version */ // @@ -1167,7 +822,7 @@ _environ: /* in assembler */ /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -/* adapted to assembler for FPK by Pierre Muller */ +/* adapted to assembler for FPC by Pierre Muller */ /* Global variables */ @@ -1193,7 +848,10 @@ __dos_ds: /* $Log$ - Revision 1.3 1998-08-19 10:56:35 pierre + Revision 1.4 1998-10-14 21:28:45 peter + * initialize fpu so sigfpe is finally generated for fpu errors + + Revision 1.3 1998/08/19 10:56:35 pierre + added some special code for C interface to avoid loading of crt1.o or dpmiexcp.o from the libc.a @@ -1201,6 +859,5 @@ __dos_ds: * go32v1, go32v2 recompiles with the new objects * remake3 works again with go32v2 - removed some "optimizes" from daniel which were wrong - */ diff --git a/rtl/linux/i386/cprt1.as b/rtl/linux/i386/cprt1.as index 34c1bdea20..dfe596fd28 100644 --- a/rtl/linux/i386/cprt1.as +++ b/rtl/linux/i386/cprt1.as @@ -16,84 +16,87 @@ # Linux ELF startup code for Free Pascal # - .file "prt1.as" - .text - .globl _start - .type _start,@function + .file "prt1.as" + .text + .globl _start + .type _start,@function _start: - /* First locate the start of the environment variables */ - popl %ecx - movl %esp,%ebx /* Points to the arguments */ - movl %ecx,%eax - incl %eax - shll $2,%eax - addl %esp,%eax - andl $0xfffffff8,%esp /* Align stack */ + /* First locate the start of the environment variables */ + popl %ecx + movl %esp,%ebx /* Points to the arguments */ + movl %ecx,%eax + incl %eax + shll $2,%eax + addl %esp,%eax + andl $0xfffffff8,%esp /* Align stack */ - movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ - movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ - movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ + movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ + movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ + movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ - movl %eax,__environ /* libc environ */ + movl %eax,__environ /* libc environ */ - pushl %eax - pushl %ebx - pushl %ecx - - call __libc_init /* init libc */ - movzwl __fpu_control,%eax - pushl %eax - call __setfpucw - addl $4,%esp - pushl $_fini - call atexit - addl $4,%esp - call _init + pushl %eax + pushl %ebx + pushl %ecx - popl %eax - popl %eax - - call PASCALMAIN /* start the program */ - - .globl _haltproc - .type _haltproc,@function + call __libc_init /* init libc */ + movzwl __fpu_control,%eax + pushl %eax + call __setfpucw + addl $4,%esp + pushl $_fini + call atexit + addl $4,%esp + call _init + + popl %eax + popl %eax + + call PASCALMAIN /* start the program */ + + .globl _haltproc + .type _haltproc,@function _haltproc: - xorl %ebx,%ebx /* load and save exitcode */ - movw U_SYSLINUX_EXITCODE,%bx - pushl %ebx - - call exit /* call libc exit, this will */ - /* write the gmon.out */ - - movl $1,%eax /* exit call */ - popl %ebx - int $0x80 - jmp _haltproc - + xorl %ebx,%ebx /* load and save exitcode */ + movw U_SYSLINUX_EXITCODE,%bx + pushl %ebx + + call exit /* call libc exit, this will */ + /* write the gmon.out */ + + movl $1,%eax /* exit call */ + popl %ebx + int $0x80 + jmp _haltproc + .data - .align 4 - - .globl ___fpc_brk_addr /* heap management */ - .type ___fpc_brk_addr,@object - .size ___fpc_brk_addr,4 + .align 4 + + .globl ___fpc_brk_addr /* heap management */ + .type ___fpc_brk_addr,@object + .size ___fpc_brk_addr,4 ___fpc_brk_addr: - .long 0 - - .globl __curbrk /* necessary for libc */ - .type __curbrk,@object - .size __curbrk,4 + .long 0 + + .globl __curbrk /* necessary for libc */ + .type __curbrk,@object + .size __curbrk,4 __curbrk: - .long 0 - - .globl __environ - .type __environ,@object - .size __environ,4 + .long 0 + + .globl __environ + .type __environ,@object + .size __environ,4 __environ: - .long 0 + .long 0 # # $Log$ -# Revision 1.1 1998-08-12 19:16:09 peter +# Revision 1.2 1998-10-14 21:28:46 peter +# * initialize fpu so sigfpe is finally generated for fpu errors +# +# Revision 1.1 1998/08/12 19:16:09 peter # + loader including libc init and exit # # diff --git a/rtl/linux/i386/gprt0.as b/rtl/linux/i386/gprt0.as index 802109ae0c..933e903cf8 100644 --- a/rtl/linux/i386/gprt0.as +++ b/rtl/linux/i386/gprt0.as @@ -17,59 +17,69 @@ # Note: Needs linking with -lgmon and -lc # - .file "gprt0.as" - .text - .globl __entry + .file "gprt0.as" + .text + .globl __entry __entry: - movl 8(%esp),%eax /* Move the environment pointer */ - movl 4(%esp),%ebx /* Move the argument pointer */ - movl (%esp),%ecx /* Move the argument counter */ - - movl %eax,U_SYSLINUX_ENVP - movl %ebx,U_SYSLINUX_ARGV - movl %ecx,U_SYSLINUX_ARGC + movl 8(%esp),%eax /* Move the environment pointer */ + movl 4(%esp),%ebx /* Move the argument pointer */ + movl (%esp),%ecx /* Move the argument counter */ - pushl $_etext /* Initialize gmon */ - pushl $_start - call monstartup - addl $8,%esp - pushl $_mcleanup - call atexit - addl $4,%esp + movl %eax,U_SYSLINUX_ENVP + movl %ebx,U_SYSLINUX_ARGV + movl %ecx,U_SYSLINUX_ARGC - call PASCALMAIN + finit /* initialize fpu */ + fwait + fldcw ___fpucw - .globl _haltproc - .type _haltproc,@function + pushl $_etext /* Initialize gmon */ + pushl $_start + call monstartup + addl $8,%esp + pushl $_mcleanup + call atexit + addl $4,%esp + + call PASCALMAIN + + .globl _haltproc + .type _haltproc,@function _haltproc: - xorl %ebx,%ebx /* load and save exitcode */ - movw U_SYSLINUX_EXITCODE,%bx - pushl %ebx - - call exit /* call libc exit, this will */ - /* write the gmon.out */ - - movl $1,%eax /* exit call */ - popl %ebx - int $0x80 - jmp _haltproc + xorl %ebx,%ebx /* load and save exitcode */ + movw U_SYSLINUX_EXITCODE,%bx + pushl %ebx + + call exit /* call libc exit, this will */ + /* write the gmon.out */ + + movl $1,%eax /* exit call */ + popl %ebx + int $0x80 + jmp _haltproc .data - .align 4 - .globl ___fpc_brk_addr /* heap management */ - .type ___fpc_brk_addr,@object - .size ___fpc_brk_addr,4 + .align 4 +___fpucw: + .long 0x1332 + + .globl ___fpc_brk_addr /* heap management */ + .type ___fpc_brk_addr,@object + .size ___fpc_brk_addr,4 ___fpc_brk_addr: - - .globl __curbrk /* necessary for libc */ - .type __curbrk,@object - .size __curbrk,4 + + .globl __curbrk /* necessary for libc */ + .type __curbrk,@object + .size __curbrk,4 __curbrk: - .long 0 + .long 0 # # $Log$ -# Revision 1.3 1998-08-08 14:42:09 peter +# Revision 1.4 1998-10-14 21:28:47 peter +# * initialize fpu so sigfpe is finally generated for fpu errors +# +# Revision 1.3 1998/08/08 14:42:09 peter # * added missing ___fpc_sbrk and logs # # diff --git a/rtl/linux/i386/gprt1.as b/rtl/linux/i386/gprt1.as index bdd371fc15..2fc9ecac30 100644 --- a/rtl/linux/i386/gprt1.as +++ b/rtl/linux/i386/gprt1.as @@ -17,67 +17,76 @@ # Note: Needs linking with -lgmon and -lc # - .file "gprt1.as" - .text - .globl _start - .type _start,@function + .file "gprt1.as" + .text + .globl _start + .type _start,@function _start: - /* First locate the start of the environment variables */ - popl %ecx - movl %esp,%ebx /* Points to the arguments */ - movl %ecx,%eax - incl %eax - shll $2,%eax - addl %esp,%eax - andl $0xfffffff8,%esp /* Align stack */ + /* First locate the start of the environment variables */ + popl %ecx + movl %esp,%ebx /* Points to the arguments */ + movl %ecx,%eax + incl %eax + shll $2,%eax + addl %esp,%eax + andl $0xfffffff8,%esp /* Align stack */ - movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ - movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ - movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ + movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ + movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ + movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ - pushl $_etext /* Initialize gmon */ - pushl $_start - call monstartup - addl $8,%esp - pushl $_mcleanup - call atexit - addl $4,%esp - - call PASCALMAIN + finit /* initialize fpu */ + fwait + fldcw ___fpucw - .globl _haltproc - .type _haltproc,@function + pushl $_etext /* Initialize gmon */ + pushl $_start + call monstartup + addl $8,%esp + pushl $_mcleanup + call atexit + addl $4,%esp + + call PASCALMAIN + + .globl _haltproc + .type _haltproc,@function _haltproc: - xorl %ebx,%ebx /* load and save exitcode */ - movw U_SYSLINUX_EXITCODE,%bx - pushl %ebx - - call exit /* call libc exit, this will */ - /* write the gmon.out */ - - movl $1,%eax /* exit call */ - popl %ebx - int $0x80 - jmp _haltproc + xorl %ebx,%ebx /* load and save exitcode */ + movw U_SYSLINUX_EXITCODE,%bx + pushl %ebx + + call exit /* call libc exit, this will */ + /* write the gmon.out */ + + movl $1,%eax /* exit call */ + popl %ebx + int $0x80 + jmp _haltproc .data - .align 4 - - .globl ___fpc_brk_addr /* heap management */ - .type ___fpc_brk_addr,@object - .size ___fpc_brk_addr,4 + .align 4 +___fpucw: + .long 0x1332 + + .globl ___fpc_brk_addr /* heap management */ + .type ___fpc_brk_addr,@object + .size ___fpc_brk_addr,4 ___fpc_brk_addr: - .long 0 - - .globl __curbrk /* necessary for libc */ - .type __curbrk,@object - .size __curbrk,4 + .long 0 + + .globl __curbrk /* necessary for libc */ + .type __curbrk,@object + .size __curbrk,4 __curbrk: - .long 0 + .long 0 # # $Log$ -# Revision 1.3 1998-08-08 14:42:10 peter +# Revision 1.4 1998-10-14 21:28:48 peter +# * initialize fpu so sigfpe is finally generated for fpu errors +# +# Revision 1.3 1998/08/08 14:42:10 peter # * added missing ___fpc_sbrk and logs # # diff --git a/rtl/linux/i386/prt0.as b/rtl/linux/i386/prt0.as index fece9cec17..411400e012 100644 --- a/rtl/linux/i386/prt0.as +++ b/rtl/linux/i386/prt0.as @@ -16,40 +16,50 @@ # Linux a.out startup code for Free Pascal # - .file "prt0.as" - .text - .globl __entry + .file "prt0.as" + .text + .globl __entry __entry: - movl 8(%esp),%eax /* Move the environment pointer */ - movl 4(%esp),%ebx /* Move the argument pointer */ - movl (%esp),%ecx /* Move the argument counter */ - - movl %eax,U_SYSLINUX_ENVP - movl %ebx,U_SYSLINUX_ARGV - movl %ecx,U_SYSLINUX_ARGC + movl 8(%esp),%eax /* Move the environment pointer */ + movl 4(%esp),%ebx /* Move the argument pointer */ + movl (%esp),%ecx /* Move the argument counter */ - call PASCALMAIN + movl %eax,U_SYSLINUX_ENVP + movl %ebx,U_SYSLINUX_ARGV + movl %ecx,U_SYSLINUX_ARGC + + finit /* initialize fpu */ + fwait + fldcw ___fpucw + + call PASCALMAIN + + .globl _haltproc + .type _haltproc,@function +_haltproc: + movl $1,%eax /* exit call */ + xorl %ebx,%ebx + movw U_SYSLINUX_EXITCODE,%bx + int $0x80 + jmp _haltproc - .globl _haltproc - .type _haltproc,@function -_haltproc: - movl $1,%eax /* exit call */ - xorl %ebx,%ebx - movw U_SYSLINUX_EXITCODE,%bx - int $0x80 - jmp _haltproc - .data - .align 4 - .globl ___fpc_brk_addr /* heap management */ - .type ___fpc_brk_addr,@object - .size ___fpc_brk_addr,4 + .align 4 +___fpucw: + .long 0x1332 + + .globl ___fpc_brk_addr /* heap management */ + .type ___fpc_brk_addr,@object + .size ___fpc_brk_addr,4 ___fpc_brk_addr: - .long 0 + .long 0 # # $Log$ -# Revision 1.3 1998-08-08 14:42:11 peter +# Revision 1.4 1998-10-14 21:28:49 peter +# * initialize fpu so sigfpe is finally generated for fpu errors +# +# Revision 1.3 1998/08/08 14:42:11 peter # * added missing ___fpc_sbrk and logs # # diff --git a/rtl/linux/i386/prt1.as b/rtl/linux/i386/prt1.as index a04dc20a73..aecdad9586 100644 --- a/rtl/linux/i386/prt1.as +++ b/rtl/linux/i386/prt1.as @@ -16,53 +16,62 @@ # Linux ELF startup code for Free Pascal # - .file "prt1.as" - .text - .globl _start - .type _start,@function + .file "prt1.as" + .text + .globl _start + .type _start,@function _start: - /* First locate the start of the environment variables */ - popl %ecx - movl %esp,%ebx /* Points to the arguments */ - movl %ecx,%eax - incl %eax - shll $2,%eax - addl %esp,%eax - andl $0xfffffff8,%esp /* Align stack */ + /* First locate the start of the environment variables */ + popl %ecx + movl %esp,%ebx /* Points to the arguments */ + movl %ecx,%eax + incl %eax + shll $2,%eax + addl %esp,%eax + andl $0xfffffff8,%esp /* Align stack */ - movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ - movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ - movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ + movl %eax,U_SYSLINUX_ENVP /* Move the environment pointer */ + movl %ecx,U_SYSLINUX_ARGC /* Move the argument counter */ + movl %ebx,U_SYSLINUX_ARGV /* Move the argument pointer */ + + finit /* initialize fpu */ + fwait + fldcw ___fpucw + + call PASCALMAIN + + .globl _haltproc + .type _haltproc,@function +_haltproc: + movl $1,%eax /* exit call */ + xorl %ebx,%ebx + movw U_SYSLINUX_EXITCODE,%bx + int $0x80 + jmp _haltproc - call PASCALMAIN - - .globl _haltproc - .type _haltproc,@function -_haltproc: - movl $1,%eax /* exit call */ - xorl %ebx,%ebx - movw U_SYSLINUX_EXITCODE,%bx - int $0x80 - jmp _haltproc - .data - .align 4 - - .globl ___fpc_brk_addr /* heap management */ - .type ___fpc_brk_addr,@object - .size ___fpc_brk_addr,4 + .align 4 +___fpucw: + .long 0x1332 + + .globl ___fpc_brk_addr /* heap management */ + .type ___fpc_brk_addr,@object + .size ___fpc_brk_addr,4 ___fpc_brk_addr: - .long 0 - - .globl __curbrk /* necessary for libc */ - .type __curbrk,@object - .size __curbrk,4 + .long 0 + + .globl __curbrk /* necessary for libc */ + .type __curbrk,@object + .size __curbrk,4 __curbrk: - .long 0 + .long 0 # # $Log$ -# Revision 1.3 1998-08-08 14:42:12 peter +# Revision 1.4 1998-10-14 21:28:50 peter +# * initialize fpu so sigfpe is finally generated for fpu errors +# +# Revision 1.3 1998/08/08 14:42:12 peter # * added missing ___fpc_sbrk and logs # #