123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- {
- $Id$
- This file is part of the Free Pascal run time library.
- Copyright (c) 1998 by Michael Van Canneyt
- member of the Free Pascal development team
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- { Run-Time type information routines - processor dependent part }
- {$ASMMODE DIRECT}
- Procedure Initialize (Data,TypeInfo : pointer);[Public,Alias : 'FPC_INITIALIZE'];assembler;
- asm
- # Save registers
- push %eax
- push %ebx
- push %ecx
- push %edx
- # decide what type it is
- movl 12(%ebp),%ebx
- movb (%ebx),%al
- subb $10,%al
- jz .DoAnsiStringInit
- decb %al
- jz .DoAnsiStringInit
- subb $2,%al
- jz .DoArrayInit
- decb %al
- jz .DoRecordInit
- decb %al
- decb %al
- jz .DoObjectInit
- decb %al
- jz .DoClassInit
- jmp .ExitInitialize
- .DoObjectInit:
- .DoClassInit:
- .DoRecordInit:
- incl %ebx
- movzbl (%ebx),%eax
- # Skip also recordsize.
- addl $5,%eax
- addl %eax,%ebx
- # %ebx points to element count. Set in %edx
- movl (%ebx),%edx
- addl $4,%ebx
- # %ebx points to First element in record
- .MyRecordInitLoop:
- decl %edx
- jl .ExitInitialize
- # %ebx points to typeinfo pointer
- # Push type
- pushl (%ebx)
- addl $4,%ebx
- # %ebx points to offset in record.
- # Us it to calculate data
- movl 8(%ebp),%eax
- addl (%ebx),%eax
- addl $4,%ebx
- # push data
- pushl %eax
- call FPC_INITIALIZE
- jmp .MyRecordInitLoop
- # Array handling
- .DoArrayInit:
- # Skip array name !!
- incl %ebx
- movzbl (%ebx),%eax
- incl %eax
- addl %eax,%ebx
- # %ebx points to size. Put size in ecx
- movl (%ebx),%ecx
- addl $4, %ebx
- # %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:
- decl %edx
- jl .ExitInitialize
- # push type
- pushl (%ebx)
- # calculate data
- movl %ecx,%eax
- imull %edx,%eax
- addl 8(%ebp),%eax
- # push data
- pushl %eax
- call FPC_INITIALIZE
- jmp .MyArrayInitLoop
- # AnsiString handling :
- .DoAnsiStringInit:
- movl 8(%ebp), %eax
- movl $0,(%eax)
- .ExitInitialize:
- pop %edx
- pop %ecx
- pop %ebx
- pop %eax
- end;
- Procedure Finalize (Data,TypeInfo: Pointer);[Public,Alias : 'FPC_FINALIZE']; assembler;
- asm
- push %eax
- push %ebx
- push %ecx
- push %edx
- # decide what type it is
- movl 12(%ebp),%ebx
- movb (%ebx),%al
- subb $10,%al
- jz .DoAnsiStringFinal
- decb %al
- jz .DoAnsiStringFinal
- subb $2,%al
- jz .DoArrayFinal
- decb %al
- jz .DoRecordFinal
- decb %al
- decb %al
- jz .DoObjectFinal
- decb %al
- jz .DoClassFinal
- jmp .ExitFinalize
- .DoClassFinal:
- .DoObjectFinal:
- .DoRecordFinal:
- incl %ebx
- movzbl (%ebx),%eax
- # Skip also recordsize.
- addl $5,%eax
- addl %eax,%ebx
- # %ebx points to element count. Set in %edx
- movl (%ebx),%edx
- addl $4,%ebx
- # %ebx points to First element in record
- .MyRecordFinalLoop:
- decl %edx
- jl .ExitFinalize
- # %ebx points to typeinfo pointer
- # Push type
- pushl (%ebx)
- addl $4,%ebx
- # %ebx points to offset.
- # Use to calculate data
- movl 8(%ebp),%eax
- addl (%ebx),%eax
- addl $4,%ebx
- # push data
- pushl %eax
- call FPC_FINALIZE
- jmp .MyRecordFinalLoop
- # Array handling
- .DoArrayFinal:
- # Skip array name !!
- incl %ebx
- movzbl (%ebx),%eax
- incl %eax
- addl %eax,%ebx
- # %ebx points to size. Put size in ecx
- movl (%ebx),%ecx
- addl $4, %ebx
- # %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:
- decl %edx
- jl .ExitFinalize
- # push type
- pushl (%ebx)
- # calculate data
- movl %ecx,%eax
- imull %edx,%eax
- addl 8(%ebp),%eax
- # push data
- pushl %eax
- call FPC_FINALIZE
- jmp .MyArrayFinalLoop
- # AnsiString handling :
- .DoAnsiStringFinal:
- pushl 8(%ebp)
- call FPC_DECR_ANSI_REF
- .ExitFinalize:
- pop %edx
- pop %ecx
- pop %ebx
- pop %eax
- end;
- Procedure Addref (Data,TypeInfo : Pointer); [Public,alias : 'FPC_ADDREF'];Assembler;
- asm
- # Save registers
- push %eax
- push %ebx
- push %ecx
- push %edx
- # decide what type it is
- movl 12(%ebp),%ebx
- movb (%ebx),%al
- subb $10,%al
- jz .DoAnsiStringAddRef
- decb %al
- jz .DoAnsiStringAddRef
- subb $2,%al
- jz .DoArrayAddRef
- decb %al
- jz .DoRecordAddRef
- decb %al
- decb %al
- jz .DoObjectAddRef
- decb %al
- jz .DoClassAddRef
- jmp .ExitAddRef
- .DoClassAddRef:
- .DoObjectAddRef:
- .DoRecordAddRef:
- incl %ebx
- movzbl (%ebx),%eax
- # Skip also recordsize.
- addl $5,%eax
- addl %eax,%ebx
- # %ebx points to element count. Set in %edx
- movl (%ebx),%edx
- addl $4,%ebx
- # %ebx points to First element in record
- .MyRecordAddRefLoop:
- decl %edx
- jl .ExitAddRef
- # Calculate data
- movl 8(%ebp),%eax
- addl (%ebx),%eax
- addl $4,%ebx
- # Push type
- pushl (%ebx)
- addl $4,%ebx
- # push data
- pushl %eax
- call FPC_ADDREF
- jmp .MyRecordAddRefLoop
- # Array handling
- .DoArrayAddRef:
- # %ebx points to size. Put size in ecx
- movl (%ebx),%ecx
- addl $4, %ebx
- # %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:
- decl %edx
- jl .ExitAddRef
- # push type
- pushl (%ebx)
- # calculate data
- movl %ecx,%eax
- imull %edx,%eax
- addl 8(%ebp),%eax
- # push data
- pushl %eax
- call FPC_ADDREF
- jmp .MyArrayAddRefLoop
- # AnsiString handling :
- .DoAnsiStringAddRef:
- pushl 8(%ebp)
- call FPC_INCR_ANSI_REF
- .ExitAddRef:
- pop %edx
- pop %ecx
- pop %ebx
- pop %eax
- end;
- Procedure DecRef (Data,TypeInfo : Pointer); [Public,alias : 'FPC_DECREF'];Assembler;
- asm
- # Save registers
- push %eax
- push %ebx
- push %ecx
- push %edx
- # decide what type it is
- movl 12(%ebp),%ebx
- movb (%ebx),%al
- subb $10,%al
- jz .DoAnsiStringDecRef
- decb %al
- jz .DoAnsiStringDecRef
- subb $2,%al
- jz .DoArrayDecRef
- decb %al
- jz .DoRecordDecRef
- decb %al
- decb %al
- jz .DoObjectDecRef
- decb %al
- jz .DoClassDecRef
- jmp .ExitDecRef
- .DoClassDecRef:
- .DoObjectDecRef:
- .DoRecordDecRef:
- incl %ebx
- movzbl (%ebx),%eax
- # Skip also recordsize.
- addl $5,%eax
- addl %eax,%ebx
- # %ebx points to element count. Set in %edx
- movl (%ebx),%edx
- addl $4,%ebx
- # %ebx points to First element in record
- .MyRecordDecRefLoop:
- decl %edx
- jl .ExitDecRef
- # Calculate data
- movl 8(%ebp),%eax
- addl (%ebx),%eax
- addl $4,%ebx
- # Push type
- pushl (%ebx)
- addl $4,%ebx
- # push data
- pushl %eax
- call FPC_DECREF
- jmp .MyRecordDecRefLoop
- # Array handling
- .DoArrayDecRef:
- # %ebx points to size. Put size in ecx
- movl (%ebx),%ecx
- addl $4, %ebx
- # %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:
- decl %edx
- jl .ExitDecRef
- # push type
- pushl (%ebx)
- # calculate data
- movl %ecx,%eax
- imull %edx,%eax
- addl 8(%ebp),%eax
- # push data
- pushl %eax
- call FPC_DECREF
- jmp .MyArrayDecRefLoop
- # AnsiString handling :
- .DoAnsiStringDecRef:
- movl 8(%ebp),%eax
- pushl %eax
- call FPC_DECR_ANSI_REF
- .ExitDecRef:
- pop %edx
- pop %ecx
- pop %ebx
- pop %eax
- end;
- {$ASMMODE DEFAULT}
- {
- $Log$
- Revision 1.9 1998-09-29 08:38:25 michael
- + Corrections in record and array handling.
- Revision 1.8 1998/09/20 17:49:07 florian
- * some ansistring fixes
- Revision 1.7 1998/09/14 10:48:11 peter
- * FPC_ names
- * Heap manager is now system independent
- Revision 1.6 1998/08/23 20:58:50 florian
- + rtti for objects and classes
- + TObject.GetClassName implemented
- Revision 1.5 1998/06/25 08:41:43 florian
- * better rtti
- Revision 1.4 1998/06/17 11:50:43 michael
- + Small patch: forgot to make alias public
- Revision 1.3 1998/06/10 07:46:49 michael
- + Forgot to commit some changes
- Revision 1.2 1998/06/08 19:31:03 michael
- + Implemented DecRef
- Revision 1.1 1998/06/08 15:32:12 michael
- + Split rtti according to processor. Implemented optimized i386 code.
- }
|