* use external names

* removed all direct assembler modes
This commit is contained in:
peter 1999-03-01 15:40:48 +00:00
parent 466989af54
commit af8a04a5af
15 changed files with 982 additions and 1133 deletions

View File

@ -630,7 +630,12 @@ begin
end;
{$ASMMODE DIRECT}
var
_swap_in : pointer;external name '_swap_in';
_swap_out : pointer;external name '_swap_out';
_exception_exit : pointer;external name '_exception_exit';
_v2prt0_exceptions_on : longbool;external name '_v2prt0_exceptions_on';
procedure swapvectors;
begin
DosError:=0;
@ -644,15 +649,14 @@ begin
orl %eax,%eax
je .Lexceptions_off
movl _swap_out,%eax
call *%eax
call %eax
jmp .Lno_excep
.Lexceptions_off:
movl _swap_in,%eax
call *%eax
call %eax
.Lno_excep:
end;
end;
{$ASMMODE ATT}
{******************************************************************************
@ -986,7 +990,11 @@ End;
end.
{
$Log$
Revision 1.3 1999-01-22 15:44:59 pierre
Revision 1.4 1999-03-01 15:40:48 peter
* use external names
* removed all direct assembler modes
Revision 1.3 1999/01/22 15:44:59 pierre
Daniel change removed : broke make cycle !!
Revision 1.2 1999/01/22 10:07:03 daniel

View File

@ -106,7 +106,7 @@ function dpmi_set_coprocessor_emulation(flag : longint) : longint;
implementation
{$ASMMODE DIRECT}
{$asmmode ATT}
{$L exceptn.o}
@ -133,8 +133,8 @@ procedure djgpp_cbrk_hdlr;external name '___djgpp_cbrk_hdlr';
var
exceptions_on : boolean;
old_int00 : tseginfo;cvar;external;
old_int75 : tseginfo;cvar;external;
{ old_int00 : tseginfo;cvar;external;
old_int75 : tseginfo;cvar;external; }
const
cbrk_vect : byte = $1b;
@ -188,12 +188,12 @@ end;
movl 12(%esp),%eax
movl %eax,8(%esp)
popl %eax
jmp FPC_setjmp
jmp dpmi_setjmp
end;
end;
function dpmi_setjmp(var rec : dpmi_jmp_buf) : longint;[alias : 'FPC_setjmp'];
function dpmi_setjmp(var rec : dpmi_jmp_buf) : longint;
begin
asm
pushl %edi
@ -229,7 +229,7 @@ begin
movw %fs,46(%edi)
movw %gs,48(%edi)
movw %ss,50(%edi)
movl ___djgpp_exception_state_ptr, %eax
movl djgpp_exception_state_ptr, %eax
movl %eax, 60(%edi)
{ restore EDI }
pop %edi
@ -275,31 +275,24 @@ begin
movl 28(%edi),%esi
subl $28,%esi { We need 7 working longwords on stack }
movl 60(%edi),%eax
es
movl %eax,(%esi) { Exception pointer }
movl %eax,%es:(%esi) { Exception pointer }
movzwl 42(%edi),%eax
es
movl %eax,4(%esi) { DS }
movl %eax,%es:4(%esi) { DS }
movl 20(%edi),%eax
es
movl %eax,8(%esi) { EDI }
movl %eax,%es:8(%esi) { EDI }
movl 16(%edi),%eax
es
movl %eax,12(%esi) { ESI }
movl %eax,%es:12(%esi) { ESI }
movl 32(%edi),%eax
es
movl %eax,16(%esi) { EIP - start of IRET frame }
movl %eax,%es:16(%esi) { EIP - start of IRET frame }
movl 40(%edi),%eax
es
movl %eax,20(%esi) { CS }
movl %eax,%es:20(%esi) { CS }
movl 36(%edi),%eax
es
movl %eax,24(%esi) { EFLAGS }
movl %eax,%es:24(%esi) { EFLAGS }
movl 0(%edi),%eax
movw 44(%edi),%es
movw 50(%edi),%ss
movl %esi,%esp
popl ___djgpp_exception_state_ptr
popl djgpp_exception_state_ptr
popl %ds
popl %edi
popl %esi
@ -501,6 +494,8 @@ end;
const message_level : byte = 0;
procedure ___exit(c:byte);cdecl;external name '___exit';
function do_faulting_finish_message : integer;
var
en : pchar;
@ -615,16 +610,13 @@ begin
simple_exit:
if exceptions_on then
djgpp_exception_toggle;
asm
pushw $1
call ___exit
end;
___exit(1);
end;
function djgpp_exception_state:pexception_state;assembler;
asm
movl ___djgpp_exception_state_ptr,%eax
movl djgpp_exception_state_ptr,%eax
end;
@ -684,14 +676,13 @@ var
cbrk_ori,
cbrk_rmcb : trealseginfo;
cbrk_regs : registers;
v2prt0_exceptions_on : longbool;external name '_v2prt0_exceptions_on';
procedure djgpp_exception_toggle;[alias : '___djgpp_exception_toggle'];
var
_except : tseginfo;
i : longint;
local_ex : boolean;
begin
{$ifdef DPMIEXCP_DEBUG}
if exceptions_on then
@ -702,11 +693,7 @@ begin
{ toggle here to avoid infinite recursion }
{ if a subfunction calls runerror !! }
exceptions_on:=not exceptions_on;
local_ex:=exceptions_on;
asm
movzbl local_ex,%eax
movl %eax,_v2prt0_exceptions_on
end;
v2prt0_exceptions_on:=exceptions_on;
for i:=0 to EXCEPTIONCOUNT-1 do
begin
if get_pm_exception_handler(i,_except) then
@ -779,6 +766,11 @@ begin
end;
var
_swap_in : pointer;external name '_swap_in';
_swap_out : pointer;external name '_swap_out';
_exception_exit : pointer;external name '_exception_exit';
procedure dpmiexcp_exit{(status : longint)};[public,alias : 'excep_exit'];
{ We need to restore hardware interrupt handlers even if somebody calls
`_exit' directly, or else we crash the machine in nested programs.
@ -787,12 +779,9 @@ procedure dpmiexcp_exit{(status : longint)};[public,alias : 'excep_exit'];
begin
if (exceptions_on) then
djgpp_exception_toggle;
asm
xorl %eax,%eax
movl %eax,_exception_exit
movl %eax,_swap_in
movl %eax,_swap_out
end;
_exception_exit:=nil;
_swap_in:=nil;
_swap_out:=nil;
{ restore the FPU state }
dpmi_set_coprocessor_emulation(1);
end;
@ -815,6 +804,9 @@ begin
end;
var
___djgpp_app_DS : word;external name '___djgpp_app_DS';
___djgpp_our_DS : word;external name '___djgpp_our_DS';
procedure djgpp_exception_setup;[alias : '___djgpp_exception_setup'];
var
@ -825,17 +817,11 @@ var
locksize : longint;
i : longint;
begin
asm
movl _exception_exit,%eax
xorl %eax,%eax
jne .L_already
leal excep_exit,%eax
movl %eax,_exception_exit
leal swap_in,%eax
movl %eax,_swap_in
leal swap_out,%eax
movl %eax,_swap_out
end;
if assigned(_exception_exit) then
exit;
_exception_exit:=@dpmiexcp_exit;
_swap_in:=@dpmi_swap_in;
_swap_out:=@dpmi_swap_out;
{ reset signals }
for i := 0 to SIGMAX-1 do
signal_list[i] := SignalHandler(@SIG_DFL);
@ -872,9 +858,6 @@ begin
djgpp_exception_toggle; { Set new values & save old values }
{ get original video mode and save }
old_video_mode := farpeekb(dosmemselector, $449);
asm
.L_already:
end;
end;
@ -907,7 +890,11 @@ begin
end.
{
$Log$
Revision 1.6 1999-02-05 12:49:25 pierre
Revision 1.7 1999-03-01 15:40:49 peter
* use external names
* removed all direct assembler modes
Revision 1.6 1999/02/05 12:49:25 pierre
<> debug conditionnal renamed DPMIEXCP_DEBUG
Revision 1.5 1999/01/22 15:46:33 pierre

View File

@ -21,6 +21,8 @@ procedure npxsetup(prog_name : string);
implementation
{$asmmode ATT}
uses
dxeload,dpmiexcp,strings;
@ -46,12 +48,12 @@ begin
movl mask2, %ecx
notl %ecx
andl %eax, %ecx /* the bits we want to keep */
andl %eax, %ecx { the bits we want to keep }
movl mask2, %edx
andl mask1, %edx /* the bits we want to change */
andl mask1, %edx { the bits we want to change }
orl %ecx, %edx /* the new value */
orl %ecx, %edx { the new value }
pushl %edx
fldcw (%esp)
popl %edx
@ -137,6 +139,8 @@ begin
end;
function __detect_80387:byte;external name '__detect_80387';
procedure npxsetup(prog_name : string);
var
cp : string;
@ -212,7 +216,11 @@ begin
end.
{
$Log$
Revision 1.1 1998-12-21 13:07:02 peter
Revision 1.2 1999-03-01 15:40:50 peter
* use external names
* removed all direct assembler modes
Revision 1.1 1998/12/21 13:07:02 peter
* use -FE
Revision 1.9 1998/10/26 14:49:45 pierre

View File

@ -210,6 +210,8 @@ var
implementation
{$asmmode ATT}
{ the following procedures copy from and to DOS memory using DPMI }
procedure dpmi_dosmemput(seg : word;ofs : word;var data;count : longint);
@ -538,20 +540,20 @@ end ['EAX','EDX'];
end;
procedure test_int31(flag : longint);[alias : 'test_int31'];
procedure test_int31(flag : longint);
begin
asm
pushl %ebx
movw $0,U_GO32_INT31ERROR
movw $0,INT31ERROR
movl flag,%ebx
testb $1,%bl
jz 1f
movw %ax,U_GO32_INT31ERROR
jz .Lti31_1
movw %ax,INT31ERROR
xorl %eax,%eax
jmp 2f
1:
jmp .Lti31_2
.Lti31_1:
movl $1,%eax
2:
.Lti31_2:
popl %ebx
end;
end;
@ -702,6 +704,8 @@ end ['EAX','EDX'];
{ here we must use ___v2prt0_ds_alias instead of from v2prt0.s
because the exception processor sets the ds limit to $fff
at hardware exceptions }
var
___v2prt0_ds_alias : word;external name '___v2prt0_ds_alias';
function get_rm_callback(pm_func : pointer;const reg : trealregs;var rmcb : tseginfo) : boolean;
begin
@ -1072,6 +1076,10 @@ end ['EAX','EDX'];
sti
end;
var
_run_mode : word;external name '_run_mode';
function get_run_mode : word;
begin
@ -1097,6 +1105,9 @@ end ['EAX','EDX'];
end;
end;
var
_core_selector : word;external name '_core_selector';
function get_core_selector : word;
begin
@ -1159,7 +1170,11 @@ end.
{
$Log$
Revision 1.1 1998-12-21 13:07:03 peter
Revision 1.2 1999-03-01 15:40:51 peter
* use external names
* removed all direct assembler modes
Revision 1.1 1998/12/21 13:07:03 peter
* use -FE
Revision 1.12 1998/08/27 10:30:50 pierre

View File

@ -138,7 +138,7 @@ var
old_int75 : tseginfo;cvar;
{$ASMMODE DIRECT}
{$ASMMODE ATT}
{*****************************************************************************
Go32 Helpers
@ -163,8 +163,6 @@ asm
end;
end;
{$ASMMODE ATT}
function tb : longint;
begin
@ -294,14 +292,14 @@ begin
atohex:=rv;
end;
var
_args : ppchar;external name '_args';
procedure setup_arguments;
type arrayword = array [0..0] of word;
var psp : word;
i,j : byte;
quote : char;
proxy_s : string[7];
tempargv : ppchar;
al,proxy_argc,proxy_seg,proxy_ofs,lin : longint;
largs : array[0..127] of pchar;
rm_argv : ^arrayword;
@ -382,13 +380,7 @@ if (argc > 1) and (far_strlen(get_ds,longint(largs[1])) = 6) then
getmem(argv,argc shl 2);
for i := 0 to argc-1 do
argv[i] := largs[i];
tempargv:=argv;
{$ASMMODE DIRECT}
asm
movl tempargv,%eax
movl %eax,_args
end;
{$ASMMODE ATT}
_args:=argv;
end;
@ -419,19 +411,15 @@ begin
end;
var
__stubinfo : p_stub_info;external name '__stubinfo';
___dos_argv0 : pchar;external name '___dos_argv0';
procedure setup_environment;
var env_selector : word;
env_count : longint;
dos_env,cp : pchar;
stubaddr : p_stub_info;
begin
{$ASMMODE DIRECT}
asm
movl __stubinfo,%eax
movl %eax,stubaddr
end;
{$ASMMODE ATT}
stub_info:=stubaddr;
stub_info:=__stubinfo;
getmem(dos_env,stub_info^.env_size);
env_count:=0;
sysseg_move(stub_info^.psp_selector,$2c, get_ds, longint(@env_selector), 2);
@ -465,12 +453,7 @@ begin
if (dos_argv0 = nil) then halt;
strcopy(dos_argv0, cp);
{ update ___dos_argv0 also }
{$ASMMODE DIRECT}
asm
movl U_SYSTEM_DOS_ARGV0,%eax
movl %eax,___dos_argv0
end;
{$ASMMODE ATT}
___dos_argv0:=dos_argv0
end;
@ -545,12 +528,14 @@ end;
{*****************************************************************************
System Dependent Exit code
*****************************************************************************}
Procedure system_exit;
{$ASMMODE DIRECT}
{$ifdef SYSTEMDEBUG}
var h : byte;
{$endif SYSTEMDEBUG}
procedure ___exit(exitcode:byte);cdecl;external name '___exit';
Procedure system_exit;
{$ifdef SYSTEMDEBUG}
var
h : byte;
{$endif SYSTEMDEBUG}
begin
{$ifdef SYSTEMDEBUG}
for h:=0 to max_files do
@ -561,15 +546,11 @@ begin
{ not on normal exit !! PM }
set_pm_interrupt($00,old_int00);
set_pm_interrupt($75,old_int75);
asm
movzbw exitcode,%ax
pushw %ax
call ___exit {frees all dpmi memory !!}
end;
___exit(exitcode);
end;
procedure halt(errnum : byte);
begin
exitcode:=errnum;
do_exit;
@ -595,6 +576,9 @@ begin
end;
var
__stkbottom : longint;external name '__stkbottom';
procedure int_stackcheck(stack_size:longint);[public,alias:'FPC_STACKCHECK'];
{
called when trying to get local stack if the compiler directive $S
@ -613,10 +597,10 @@ begin
movl %esp,%eax
subl %ebx,%eax
{$ifdef SYSTEMDEBUG}
movl U_SYSTEM_LOWESTSTACK,%ebx
movl loweststack,%ebx
cmpl %eax,%ebx
jb .L_is_not_lowest
movl %eax,U_SYSTEM_LOWESTSTACK
movl %eax,loweststack
.L_is_not_lowest:
{$endif SYSTEMDEBUG}
movl __stkbottom,%ebx
@ -633,8 +617,6 @@ begin
end['EAX','EBX'];
HandleError(202);
end;
{$ASMMODE ATT}
{*****************************************************************************
@ -671,20 +653,24 @@ end;
Heap Management
*****************************************************************************}
{$ASMMODE DIRECT}
var
int_heap : longint;external name 'HEAP';
int_heapsize : longint;external name 'HEAPSIZE';
function getheapstart:pointer;assembler;
asm
leal HEAP,%eax
end ['EAX'];
function getheapstart:pointer;
begin
getheapstart:=@int_heap;
end;
function getheapsize:longint;assembler;
asm
movl HEAPSIZE,%eax
end ['EAX'];
function getheapsize:longint;
begin
getheapsize:=int_heapsize;
end;
function ___sbrk(size:longint):longint;cdecl;external name '___sbrk';
function Sbrk(size : longint):longint;assembler;
asm
movl size,%eax
@ -693,7 +679,6 @@ asm
addl $4,%esp
end;
{$ASMMODE ATT}
{ include standard heap management }
{$I heap.inc}
@ -1237,7 +1222,11 @@ Begin
End.
{
$Log$
Revision 1.5 1999-01-18 10:05:50 pierre
Revision 1.6 1999-03-01 15:40:52 peter
* use external names
* removed all direct assembler modes
Revision 1.5 1999/01/18 10:05:50 pierre
+ system_exit procedure added
Revision 1.4 1998/12/30 22:17:59 peter

View File

@ -250,6 +250,7 @@ use_stubinfo_stack_size:
addl __stklen, %eax
movw %ds, %dx /* set stack */
movw %dx, %ss
andl $0xfffffffc,%eax
movl %eax, %esp
xorl %ebp, %ebp
@ -900,7 +901,11 @@ ___PROXY_LEN:
/*
$Log$
Revision 1.4 1999-02-19 12:25:37 pierre
Revision 1.5 1999-03-01 15:40:53 peter
* use external names
* removed all direct assembler modes
Revision 1.4 1999/02/19 12:25:37 pierre
+ ___v2prt0_rmcb_regs in text section for Windows NT
+ catch of calls into zero page for Windows 95
(creates Run Time error 216 or SIGILL exception

View File

@ -15,7 +15,8 @@
**********************************************************************}
{$ASMMODE ATT}
{$asmmode ATT}
{****************************************************************************
Move / Fill
@ -150,8 +151,6 @@ end;
Object Helpers
****************************************************************************}
{$ASMMODE DIRECT}
procedure int_help_constructor;assembler; [public,alias:'FPC_HELP_CONSTRUCTOR'];
asm
{ Entry without preamble, since we need the ESP of the constructor
@ -175,7 +174,7 @@ asm
{ Memory size }
pushl (%eax)
pushl %esi
call FPC_GETMEM
call GetMem
popal
{ Memory position to %esi }
movl (%esi),%esi
@ -249,12 +248,15 @@ asm
{ SELF }
movl %eax,(%edi)
pushl %edi
call FPC_FREEMEM
call FreeMem
addl $4,%esp
.LHD_3:
popal
end;
{$ifndef NEWATT}
{$asmmode DIRECT}
{$endif}
procedure int_new_class;assembler;[public,alias:'FPC_NEW_CLASS'];
asm
@ -291,7 +293,9 @@ asm
.LDISPOSE_CLASS1:
end;
{$ASMMODE ATT}
{$ifndef NEWATT}
{$asmmode att}
{$endif}
{ checks for a correct vmt pointer }
@ -495,12 +499,11 @@ begin
end;
{$ASMMODE DIRECT}
function strpas(p:pchar):string;[public,alias:'FPC_PCHAR_TO_SHORTSTR'];
begin
asm
cld
movl 12(%ebp),%edi
movl p,%edi
movl $0xff,%ecx
xorl %eax,%eax
movl %edi,%esi
@ -508,7 +511,11 @@ begin
scasb
movl %ecx,%eax
{$ifdef NEWATT1}
movl __RESULT,%edi
{$else}
movl 8(%ebp),%edi
{$endif}
notb %al
decl %eax
stosb
@ -531,7 +538,6 @@ begin
movsb
end ['ECX','EAX','ESI','EDI'];
end;
{$ASMMODE ATT}
function strlen(p:pchar):longint;assembler;
@ -643,7 +649,7 @@ begin
incl %ecx
.LM2:
cltd
idivl %esi,%eax
idivl %esi
addb $0x30,%dl // convert Rest to ASCII.
movb %dl,-12(%ebp,%ebx)
incl %ebx
@ -673,7 +679,7 @@ begin
movl $0x0a,%esi // load 10 as dividing constant.
.LM4:
xorl %edx,%edx
divl %esi,%eax
divl %esi
addb $0x30,%dl // convert Rest to ASCII.
movb %dl,-12(%ebp,%ebx)
incl %ebx
@ -739,7 +745,11 @@ end;
{
$Log$
Revision 1.40 1999-02-22 13:23:22 pierre
Revision 1.41 1999-03-01 15:40:55 peter
* use external names
* removed all direct assembler modes
Revision 1.40 1999/02/22 13:23:22 pierre
* VMT field zeroed at destructor forgot offset !!
Revision 1.39 1999/02/05 12:26:25 pierre

View File

@ -14,209 +14,15 @@
**********************************************************************}
{$ASMMODE DIRECT}
{$ifndef DEFAULT_EXTENDED}
{****************************************************************************
Real/Double data type routines
****************************************************************************}
function pi : real;assembler;
asm
fldpi
leave
ret
end [];
function abs(d : real) : real;assembler;
asm
fldl 8(%ebp)
fabs
end [];
function sqr(d : real) : real;assembler;
asm
fldl 8(%ebp)
fldl 8(%ebp)
fmulp
end [];
function sqrt(d : real) : real;assembler;
asm
fldl 8(%ebp)
fsqrt
leave
ret $8
end [];
function arctan(d : real) : real;assembler;
asm
fldl 8(%ebp)
fld1
fpatan
end [];
function cos(d : real) : real;assembler;
asm
fldl 8(%ebp)
fcos
fstsw
sahf
jnp .LCOS1
fstp %st(0)
fldl .LCOS0
jmp .LCOS1
.LCOS0:
.quad 0xffffffffffffffff
.LCOS1:
end ['EAX'];
function exp(d : real) : real;assembler;
asm
// comes from DJ GPP
fldl 8(%ebp)
fldl2e
fmulp
fstcw .LCW1
fstcw .LCW2
fwait
andw $0xf3ff,.LCW2
orw $0x0400,.LCW2
fldcw .LCW2
fldl %st(0)
frndint
fldcw .LCW1
fxch %st(1)
fsub %st(1),%st
f2xm1
fld1
faddp
fscale
fstp %st(1)
jmp .LCW3
// store some help data in the data segment
.data
.LCW1:
.word 0
.LCW2:
.word 0
.text
.LCW3:
end;
function frac(d : real) : real;assembler;
asm
subl $16,%esp
fnstcw -4(%ebp)
fwait
movw -4(%ebp),%cx
orw $0x0c3f,%cx
movw %cx,-8(%ebp)
fldcw -8(%ebp)
fwait
fldl 8(%ebp)
frndint
fldl 8(%ebp)
fsub %st(1)
fstp %st(1)
fclex
fldcw -4(%ebp)
end ['ECX'];
function int(d : real) : real;assembler;
asm
subl $16,%esp
fnstcw -4(%ebp)
fwait
movw -4(%ebp),%cx
orw $0x0c3f,%cx
movw %cx,-8(%ebp)
fldcw -8(%ebp)
fwait
fldl 8(%ebp)
frndint
fclex
fldcw -4(%ebp)
end ['ECX'];
function trunc(d : real) : longint;assembler;
asm
subl $16,%esp
fnstcw -4(%ebp)
fwait
movw -4(%ebp),%cx
orw $0x0c3f,%cx
movw %cx,-8(%ebp)
fldcw -8(%ebp)
fwait
fldl 8(%ebp)
fistpl -8(%ebp)
movl -8(%ebp),%eax
fldcw -4(%ebp)
end ['EAX','ECX'];
function round(d : real) : longint;assembler;
asm
subl $8,%esp
fnstcw -4(%ebp)
fwait
movw $0x1372,-8(%ebp)
fldcw -8(%ebp)
fwait
fldl 8(%ebp)
fistpl -8(%ebp)
movl -8(%ebp),%eax
fldcw -4(%ebp)
end ['EAX','ECX'];
function ln(d : real) : real;assembler;
asm
fldln2
fldl 8(%ebp)
fyl2x
end [];
function sin(d : real) : real;assembler;
asm
fldl 8(%ebp)
fsin
fstsw
sahf
jnp .LSIN1
fstp %st(0)
fldl .LSIN0
jmp .LSIN1
.LSIN0:
.quad 0xffffffffffffffff
.LSIN1:
end ['EAX'];
function power(bas,expo : real) : real;
begin
power:=exp(ln(bas)*expo);
end;
{$else DEFAULT_EXTENDED}
{****************************************************************************
EXTENDED data type routines
****************************************************************************}
{$ifndef NEWATT}
{$asmmode DIRECT}
{$endif}
function pi : extended;assembler;[internconst:in_const_pi];
asm
fldpi
@ -409,8 +215,6 @@
power:=exp(ln(bas)*expo);
end;
{$endif DEFAULT_EXTENDED}
{****************************************************************************
Longint data type routines
@ -539,11 +343,17 @@
{$endif SUPPORT_FIXED}
{$ASMMODE ATT}
{$ifndef NEWATT}
{$asmmode ATT}
{$endif}
{
$Log$
Revision 1.13 1998-12-15 22:42:56 peter
Revision 1.14 1999-03-01 15:40:57 peter
* use external names
* removed all direct assembler modes
Revision 1.13 1998/12/15 22:42:56 peter
* removed temp symbols
Revision 1.12 1998/11/24 12:54:57 peter

View File

@ -14,94 +14,93 @@
**********************************************************************}
{ Run-Time type information routines - processor dependent part }
{$ASMMODE DIRECT}
Procedure Initialize (Data,TypeInfo : pointer);[Public,Alias:'FPC_INITIALIZE'];assembler;
asm
# Save registers
// Save registers
push %eax
push %ebx
push %ecx
push %edx
# decide what type it is
// decide what type it is
movl 12(%ebp),%ebx
movb (%ebx),%al
# This is MANIFESTLY wrong
// This is MANIFESTLY wrong
subb $9,%al
jz .DoAnsiStringInit
jz .LDoAnsiStringInit
decb %al
jz .DoAnsiStringInit
jz .LDoAnsiStringInit
subb $3,%al
jz .DoArrayInit
jz .LDoArrayInit
decb %al
jz .DoRecordInit
jz .LDoRecordInit
decb %al
decb %al
jz .DoObjectInit
jz .LDoObjectInit
decb %al
jz .DoClassInit
jmp .ExitInitialize
.DoObjectInit:
.DoClassInit:
.DoRecordInit:
jz .LDoClassInit
jmp .LExitInitialize
.LDoObjectInit:
.LDoClassInit:
.LDoRecordInit:
incl %ebx
movzbl (%ebx),%eax
# Skip also recordsize.
// Skip also recordsize.
addl $5,%eax
addl %eax,%ebx
# %ebx points to element count. Set in %edx
// %ebx points to element count. Set in %edx
movl (%ebx),%edx
addl $4,%ebx
# %ebx points to First element in record
.MyRecordInitLoop:
// %ebx points to First element in record
.LMyRecordInitLoop:
decl %edx
jl .ExitInitialize
# %ebx points to typeinfo pointer
# Push type
jl .LExitInitialize
// %ebx points to typeinfo pointer
// Push type
pushl (%ebx)
addl $4,%ebx
# %ebx points to offset in record.
# Us it to calculate data
// %ebx points to offset in record.
// Us it to calculate data
movl 8(%ebp),%eax
addl (%ebx),%eax
addl $4,%ebx
# push data
// push data
pushl %eax
call FPC_INITIALIZE
jmp .MyRecordInitLoop
# Array handling
.DoArrayInit:
# Skip array name !!
call INITIALIZE
jmp .LMyRecordInitLoop
// Array handling
.LDoArrayInit:
// Skip array name !!
incl %ebx
movzbl (%ebx),%eax
incl %eax
addl %eax,%ebx
# %ebx points to size. Put size in ecx
// %ebx points to size. Put size in ecx
movl (%ebx),%ecx
addl $4, %ebx
# %ebx points to count. Put count in %edx
// %ebx points to count. Put count in %edx
movl (%ebx),%edx
addl $4, %ebx
# %ebx points to type. Put into ebx.
# Start treating elements.
.MyArrayInitLoop:
// %ebx points to type. Put into ebx.
// Start treating elements.
.LMyArrayInitLoop:
decl %edx
jl .ExitInitialize
# push type
jl .LExitInitialize
// push type
pushl (%ebx)
# calculate data
// calculate data
movl %ecx,%eax
imull %edx,%eax
addl 8(%ebp),%eax
# push data
// push data
pushl %eax
call FPC_INITIALIZE
jmp .MyArrayInitLoop
# AnsiString handling :
.DoAnsiStringInit:
call INITIALIZE
jmp .LMyArrayInitLoop
// AnsiString handling :
.LDoAnsiStringInit:
movl 8(%ebp), %eax
movl $0,(%eax)
.ExitInitialize:
.LExitInitialize:
pop %edx
pop %ecx
pop %ebx
@ -115,84 +114,84 @@ asm
push %ebx
push %ecx
push %edx
# decide what type it is
// decide what type it is
movl 12(%ebp),%ebx
movb (%ebx),%al
subb $9,%al
jz .DoAnsiStringFinal
jz .LDoAnsiStringFinal
decb %al
jz .DoAnsiStringFinal
jz .LDoAnsiStringFinal
subb $3,%al
jz .DoArrayFinal
jz .LDoArrayFinal
decb %al
jz .DoRecordFinal
jz .LDoRecordFinal
decb %al
decb %al
jz .DoObjectFinal
jz .LDoObjectFinal
decb %al
jz .DoClassFinal
jmp .ExitFinalize
.DoClassFinal:
.DoObjectFinal:
.DoRecordFinal:
jz .LDoClassFinal
jmp .LExitFinalize
.LDoClassFinal:
.LDoObjectFinal:
.LDoRecordFinal:
incl %ebx
movzbl (%ebx),%eax
# Skip also recordsize.
// Skip also recordsize.
addl $5,%eax
addl %eax,%ebx
# %ebx points to element count. Set in %edx
// %ebx points to element count. Set in %edx
movl (%ebx),%edx
addl $4,%ebx
# %ebx points to First element in record
.MyRecordFinalLoop:
// %ebx points to First element in record
.LMyRecordFinalLoop:
decl %edx
jl .ExitFinalize
# %ebx points to typeinfo pointer
# Push type
jl .LExitFinalize
// %ebx points to typeinfo pointer
// Push type
pushl (%ebx)
addl $4,%ebx
# %ebx points to offset.
# Use to calculate data
// %ebx points to offset.
// Use to calculate data
movl 8(%ebp),%eax
addl (%ebx),%eax
addl $4,%ebx
# push data
// push data
pushl %eax
call FPC_FINALIZE
jmp .MyRecordFinalLoop
# Array handling
.DoArrayFinal:
# Skip array name !!
call FINALIZE
jmp .LMyRecordFinalLoop
// Array handling
.LDoArrayFinal:
// Skip array name !!
incl %ebx
movzbl (%ebx),%eax
incl %eax
addl %eax,%ebx
# %ebx points to size. Put size in ecx
// %ebx points to size. Put size in ecx
movl (%ebx),%ecx
addl $4, %ebx
# %ebx points to count. Put count in %edx
// %ebx points to count. Put count in %edx
movl (%ebx),%edx
addl $4, %ebx
# %ebx points to type. Put into ebx.
# Start treating elements.
.MyArrayFinalLoop:
// %ebx points to type. Put into ebx.
// Start treating elements.
.LMyArrayFinalLoop:
decl %edx
jl .ExitFinalize
# push type
jl .LExitFinalize
// push type
pushl (%ebx)
# calculate data
// calculate data
movl %ecx,%eax
imull %edx,%eax
addl 8(%ebp),%eax
# push data
// push data
pushl %eax
call FPC_FINALIZE
jmp .MyArrayFinalLoop
# AnsiString handling :
.DoAnsiStringFinal:
call FINALIZE
jmp .LMyArrayFinalLoop
// AnsiString handling :
.LDoAnsiStringFinal:
pushl 8(%ebp)
call FPC_ANSISTR_DECR_REF
.ExitFinalize:
call ANSISTR_DECR_REF
.LExitFinalize:
pop %edx
pop %ecx
pop %ebx
@ -202,82 +201,82 @@ end;
Procedure Addref (Data,TypeInfo : Pointer); [Public,alias : 'FPC_ADDREF'];Assembler;
asm
# Save registers
// Save registers
push %eax
push %ebx
push %ecx
push %edx
# decide what type it is
// decide what type it is
movl 12(%ebp),%ebx
movb (%ebx),%al
subb $9,%al
jz .DoAnsiStringAddRef
jz .LDoAnsiStringAddRef
decb %al
jz .DoAnsiStringAddRef
jz .LDoAnsiStringAddRef
subb $2,%al
jz .DoArrayAddRef
jz .LDoArrayAddRef
decb %al
jz .DoRecordAddRef
jz .LDoRecordAddRef
decb %al
decb %al
jz .DoObjectAddRef
jz .LDoObjectAddRef
decb %al
jz .DoClassAddRef
jmp .ExitAddRef
.DoClassAddRef:
.DoObjectAddRef:
.DoRecordAddRef:
jz .LDoClassAddRef
jmp .LExitAddRef
.LDoClassAddRef:
.LDoObjectAddRef:
.LDoRecordAddRef:
incl %ebx
movzbl (%ebx),%eax
# Skip also recordsize.
// Skip also recordsize.
addl $5,%eax
addl %eax,%ebx
# %ebx points to element count. Set in %edx
// %ebx points to element count. Set in %edx
movl (%ebx),%edx
addl $4,%ebx
# %ebx points to First element in record
.MyRecordAddRefLoop:
// %ebx points to First element in record
.LMyRecordAddRefLoop:
decl %edx
jl .ExitAddRef
# Calculate data
jl .LExitAddRef
// Calculate data
movl 8(%ebp),%eax
addl (%ebx),%eax
addl $4,%ebx
# Push type
// Push type
pushl (%ebx)
addl $4,%ebx
# push data
// push data
pushl %eax
call FPC_ADDREF
jmp .MyRecordAddRefLoop
# Array handling
.DoArrayAddRef:
# %ebx points to size. Put size in ecx
call ADDREF
jmp .LMyRecordAddRefLoop
// Array handling
.LDoArrayAddRef:
// %ebx points to size. Put size in ecx
movl (%ebx),%ecx
addl $4, %ebx
# %ebx points to count. Put count in %edx
// %ebx points to count. Put count in %edx
movl (%ebx),%edx
addl $4, %ebx
# %ebx points to type. Put into ebx.
# Start treating elements.
.MyArrayAddRefLoop:
// %ebx points to type. Put into ebx.
// Start treating elements.
.LMyArrayAddRefLoop:
decl %edx
jl .ExitAddRef
# push type
jl .LExitAddRef
// push type
pushl (%ebx)
# calculate data
// calculate data
movl %ecx,%eax
imull %edx,%eax
addl 8(%ebp),%eax
# push data
// push data
pushl %eax
call FPC_ADDREF
jmp .MyArrayAddRefLoop
# AnsiString handling :
.DoAnsiStringAddRef:
call ADDREF
jmp .LMyArrayAddRefLoop
// AnsiString handling :
.LDoAnsiStringAddRef:
pushl 8(%ebp)
call FPC_ANSISTR_INCR_REF
.ExitAddRef:
call ANSISTR_INCR_REF
.LExitAddRef:
pop %edx
pop %ecx
pop %ebx
@ -287,94 +286,96 @@ end;
Procedure DecRef (Data,TypeInfo : Pointer); [Public,alias : 'FPC_DECREF'];Assembler;
asm
# Save registers
// Save registers
push %eax
push %ebx
push %ecx
push %edx
# decide what type it is
// decide what type it is
movl 12(%ebp),%ebx
movb (%ebx),%al
subb $9,%al
jz .DoAnsiStringDecRef
jz .LDoAnsiStringDecRef
decb %al
jz .DoAnsiStringDecRef
jz .LDoAnsiStringDecRef
subb $2,%al
jz .DoArrayDecRef
jz .LDoArrayDecRef
decb %al
jz .DoRecordDecRef
jz .LDoRecordDecRef
decb %al
decb %al
jz .DoObjectDecRef
jz .LDoObjectDecRef
decb %al
jz .DoClassDecRef
jmp .ExitDecRef
.DoClassDecRef:
.DoObjectDecRef:
.DoRecordDecRef:
jz .LDoClassDecRef
jmp .LExitDecRef
.LDoClassDecRef:
.LDoObjectDecRef:
.LDoRecordDecRef:
incl %ebx
movzbl (%ebx),%eax
# Skip also recordsize.
// Skip also recordsize.
addl $5,%eax
addl %eax,%ebx
# %ebx points to element count. Set in %edx
// %ebx points to element count. Set in %edx
movl (%ebx),%edx
addl $4,%ebx
# %ebx points to First element in record
.MyRecordDecRefLoop:
// %ebx points to First element in record
.LMyRecordDecRefLoop:
decl %edx
jl .ExitDecRef
# Calculate data
jl .LExitDecRef
// Calculate data
movl 8(%ebp),%eax
addl (%ebx),%eax
addl $4,%ebx
# Push type
// Push type
pushl (%ebx)
addl $4,%ebx
# push data
// push data
pushl %eax
call FPC_DECREF
jmp .MyRecordDecRefLoop
# Array handling
.DoArrayDecRef:
# %ebx points to size. Put size in ecx
call DECREF
jmp .LMyRecordDecRefLoop
// Array handling
.LDoArrayDecRef:
// %ebx points to size. Put size in ecx
movl (%ebx),%ecx
addl $4, %ebx
# %ebx points to count. Put count in %edx
// %ebx points to count. Put count in %edx
movl (%ebx),%edx
addl $4, %ebx
# %ebx points to type. Put into ebx.
# Start treating elements.
.MyArrayDecRefLoop:
// %ebx points to type. Put into ebx.
// Start treating elements.
.LMyArrayDecRefLoop:
decl %edx
jl .ExitDecRef
# push type
jl .LExitDecRef
// push type
pushl (%ebx)
# calculate data
// calculate data
movl %ecx,%eax
imull %edx,%eax
addl 8(%ebp),%eax
# push data
// push data
pushl %eax
call FPC_DECREF
jmp .MyArrayDecRefLoop
# AnsiString handling :
.DoAnsiStringDecRef:
call DECREF
jmp .LMyArrayDecRefLoop
// AnsiString handling :
.LDoAnsiStringDecRef:
movl 8(%ebp),%eax
pushl %eax
call FPC_ANSISTR_DECR_REF
.ExitDecRef:
call ANSISTR_DECR_REF
.LExitDecRef:
pop %edx
pop %ecx
pop %ebx
pop %eax
end;
{$ASMMODE DEFAULT}
{
$Log$
Revision 1.15 1998-12-20 14:08:06 michael
Revision 1.16 1999-03-01 15:40:58 peter
* use external names
* removed all direct assembler modes
Revision 1.15 1998/12/20 14:08:06 michael
+ Finalize fixed after florians fix :)
Revision 1.14 1998/12/19 00:22:09 florian

View File

@ -14,8 +14,6 @@
**********************************************************************}
{$ASMMODE ATT}
procedure do_load_small(p : pointer;l:longint);assembler;[public,alias:'FPC_SET_LOAD_SMALL'];
{
load a normal set p from a smallset l
@ -430,7 +428,11 @@ end;
{
$Log$
Revision 1.9 1999-01-20 17:48:02 jonas
Revision 1.10 1999-03-01 15:40:59 peter
* use external names
* removed all direct assembler modes
Revision 1.9 1999/01/20 17:48:02 jonas
+ fixed bug0163 (set1 <= set2 support)
Revision 1.8 1998/12/15 22:43:00 peter

View File

@ -14,8 +14,6 @@
**********************************************************************}
{$ASMMODE DIRECT}
Function SetJmp (Var S : Jmp_buf) : longint;assembler;[Public, alias : 'FPC_SETJMP'];
asm
movl 8(%ebp),%eax
@ -45,14 +43,16 @@ asm
movl 8(%ecx),%edi
movl 12(%ecx),%ebp
movl 16(%ecx),%esp
jmp *20(%ecx)
jmp 20(%ecx)
end;
{$ASMMODE ATT}
{
$Log$
Revision 1.4 1998-09-14 10:48:13 peter
Revision 1.5 1999-03-01 15:41:00 peter
* use external names
* removed all direct assembler modes
Revision 1.4 1998/09/14 10:48:13 peter
* FPC_ names
* Heap manager is now system independent

View File

@ -15,12 +15,11 @@
**********************************************************************}
{$ASMMODE DIRECT}
function strpas(p : pchar) : string;
begin
asm
cld
movl 12(%ebp),%edi
movl p,%edi
movl $0xff,%ecx
xorl %eax,%eax
movl %edi,%esi
@ -28,7 +27,11 @@
scasb
movl %ecx,%eax
{$ifdef NEWATT1}
movl __RESULT,%edi
{$else}
movl 8(%ebp),%edi
{$endif}
notb %al
decl %eax
stosb
@ -51,7 +54,7 @@
movsb
end ['ECX','EAX','ESI','EDI'];
end;
{$ASMMODE ATT}
function strpcopy(d : pchar;const s : string) : pchar;
@ -77,7 +80,11 @@
{
$Log$
Revision 1.2 1999-02-25 10:07:02 michael
Revision 1.3 1999-03-01 15:41:01 peter
* use external names
* removed all direct assembler modes
Revision 1.2 1999/02/25 10:07:02 michael
+ Added header and log
}

View File

@ -37,8 +37,8 @@
Function NewAnsiString (Len : Longint) : Pointer; forward;
Procedure DisposeAnsiString (Var S : Pointer); forward;
Procedure Decr_Ansi_Ref (Var S : Pointer); forward;
Procedure Incr_Ansi_Ref (Var S : Pointer); forward;
Procedure AnsiStr_Decr_Ref (Var S : Pointer); forward;
Procedure AnsiStr_Incr_Ref (Var S : Pointer); forward;
Procedure AssignAnsiString (Var S1 : Pointer; S2 : Pointer); forward;
Function Ansi_String_Concat (S1,S2 : Pointer): Pointer; forward;
Procedure Ansi_ShortString_Concat (Var S1: AnsiString; Var S2 : ShortString); forward;
@ -114,7 +114,7 @@ begin
end;
Procedure Decr_Ansi_Ref (Var S : Pointer);[Public,Alias:'FPC_ANSISTR_DECR_REF'];
Procedure AnsiStr_Decr_Ref (Var S : Pointer);[Public,Alias:'FPC_ANSISTR_DECR_REF'];
{
Decreases the ReferenceCount of a non constant ansistring;
If the reference count is zero, deallocate the string;
@ -136,7 +136,7 @@ Begin
end;
Procedure Incr_Ansi_Ref (Var S : Pointer);[Public,Alias:'FPC_ANSISTR_INCR_REF'];
Procedure AnsiStr_Incr_Ref (Var S : Pointer);[Public,Alias:'FPC_ANSISTR_INCR_REF'];
Begin
If S=Nil then
exit;
@ -161,7 +161,7 @@ begin
SNew:=NewAnsiString (PAnsiRec(Pointer(S)-FirstOff)^.len);
Move (Pointer(S)^,SNew^,PAnsiRec(Pointer(S)-FirstOff)^.len+1);
PAnsiRec(SNew-FirstOff)^.len:=PAnsiRec(Pointer(S)-FirstOff)^.len;
Decr_Ansi_Ref (Pointer(S)); { Thread safe }
ansistr_decr_ref (Pointer(S)); { Thread safe }
Pointer(S):=SNew;
end;
end;
@ -176,7 +176,7 @@ begin
If PAnsiRec(S2-FirstOff)^.Ref>0 then
Inc(PAnsiRec(S2-FirstOff)^.ref);
{ Decrease the reference count on the old S1 }
Decr_Ansi_Ref (S1);
ansistr_decr_ref (S1);
{ And finally, have S1 pointing to S2 (or its copy) }
S1:=S2;
end;
@ -309,16 +309,6 @@ begin
end;
}
{ stupid solution, could be done with public,name in later versions }
{$ASMMODE DIRECT}
procedure dummy;assembler;
asm
.globl FPC_EMPTYCHAR
FPC_EMPTYCHAR:
.byte 0
end;
{$ASMMODE ATT}
Function AnsiCompare(S1,S2 : Pointer): Longint;[Public,Alias : 'FPC_ANSISTR_COMPARE'];
{
@ -439,7 +429,7 @@ begin
Temp:=Pointer(NewAnsiString(L));
if Length(S)>0 then
Move (Pointer(S)^,Temp^,Length(S)+1);
Decr_Ansi_ref (Pointer(S));
ansistr_decr_ref (Pointer(S));
Pointer(S):=Temp;
end
else
@ -450,7 +440,7 @@ begin
else
{ Length=0 }
begin
Decr_Ansi_Ref (Pointer(S));
ansistr_decr_ref (Pointer(S));
Pointer(S):=Nil;
end;
end;
@ -741,7 +731,11 @@ end;
{
$Log$
Revision 1.11 1999-02-04 14:55:42 michael
Revision 1.12 1999-03-01 15:41:02 peter
* use external names
* removed all direct assembler modes
Revision 1.11 1999/02/04 14:55:42 michael
* Fixed pos
Revision 1.10 1999/02/04 10:49:21 florian

View File

@ -42,6 +42,11 @@ const
{ For Error Handling.}
ErrorBase : Longint = 0;
{ Used by the ansistrings and maybe also other things in the future }
var
emptychar : char;public name 'FPC_EMPTYCHAR';
{****************************************************************************
Routines which have compiler magic
****************************************************************************}
@ -480,7 +485,11 @@ end;
{
$Log$
Revision 1.54 1999-02-01 00:05:14 florian
Revision 1.55 1999-03-01 15:41:03 peter
* use external names
* removed all direct assembler modes
Revision 1.54 1999/02/01 00:05:14 florian
+ functions lo/hi for DWord type implemented
Revision 1.53 1999/01/29 09:23:09 pierre

View File

@ -913,7 +913,7 @@ var
maxlen,spos,len : longint;
Begin
{ Delete the string }
Decr_ansi_ref (Pointer(S));
AnsiStr_Decr_ref (Pointer(S));
{ We assign room for 1024 characters totally at random.... }
Pointer(s):=Pointer(NewAnsiString(1024));
MaxLen:=1024;
@ -1201,7 +1201,11 @@ end;
{
$Log$
Revision 1.39 1999-02-17 10:13:29 peter
Revision 1.40 1999-03-01 15:41:04 peter
* use external names
* removed all direct assembler modes
Revision 1.39 1999/02/17 10:13:29 peter
* when error when opening a file, then reset the mode to fmclosed
Revision 1.38 1999/01/28 19:38:19 peter