 |
Changeset 2778
- Timestamp:
- 11/05/07 14:51:31
(1 year ago)
- Author:
- sean
- Message:
Merged in changes from DMD 1.023.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r454 |
r2778 |
|
| 1 | 1 | ;_ minit.asm |
|---|
| 2 | | ; Copyright (C) 2001 by Digital Mars |
|---|
| 3 | | ; All rights reserved |
|---|
| 4 | | ; www.digitalmars.com |
|---|
| 5 | | |
|---|
| 6 | | ; Converts array of ModuleInfo pointers to a D dynamic array of them, |
|---|
| 7 | | ; so they can be accessed via D. |
|---|
| | 2 | ; Written by Walter Bright |
|---|
| | 3 | ; Digital Mars |
|---|
| | 4 | ; http://www.digitalmars.com/d/ |
|---|
| | 5 | ; Placed into the Public Domain |
|---|
| 8 | 6 | |
|---|
| 9 | 7 | include macros.asm |
|---|
| … | … | |
| 15 | 13 | endif |
|---|
| 16 | 14 | |
|---|
| | 15 | ; Provide a default resolution for weak extern records, no way in C |
|---|
| | 16 | ; to define an omf symbol with a specific value |
|---|
| 17 | 17 | public __nullext |
|---|
| 18 | | __nullext equ 0 |
|---|
| | 18 | __nullext equ 0 |
|---|
| 19 | 19 | |
|---|
| 20 | | extrn __moduleinfo_array:near |
|---|
| | 20 | extrn __moduleinfo_array:near |
|---|
| | 21 | |
|---|
| | 22 | ; This bit of assembler is needed because, from C or D, one cannot |
|---|
| | 23 | ; specify the names of data segments. Why does this matter? |
|---|
| | 24 | ; All the ModuleInfo pointers are placed into a segment named 'FM'. |
|---|
| | 25 | ; The order in which they are placed in 'FM' is arbitrarily up to the linker. |
|---|
| | 26 | ; In order to walk all the pointers, we need to be able to find the |
|---|
| | 27 | ; beginning and the end of the 'FM' segment. |
|---|
| | 28 | ; This is done by bracketing the 'FM' segment with two other, empty, |
|---|
| | 29 | ; segments named 'FMB' and 'FME'. Since this module is the only one that |
|---|
| | 30 | ; ever refers to 'FMB' and 'FME', we get to control the order in which |
|---|
| | 31 | ; these segments appear relative to 'FM' by using a GROUP statement. |
|---|
| | 32 | ; So, we have in memory: |
|---|
| | 33 | ; FMB empty segment |
|---|
| | 34 | ; FM contains all the pointers |
|---|
| | 35 | ; FME empty segment |
|---|
| | 36 | ; and finding the limits of FM is as easy as taking the address of FMB |
|---|
| | 37 | ; and the address of FME. |
|---|
| 21 | 38 | |
|---|
| 22 | 39 | ; These segments bracket FM, which contains the list of ModuleInfo pointers |
|---|
| … | … | |
| 32 | 49 | XOB ends |
|---|
| 33 | 50 | XO segment dword use32 public 'BSS' |
|---|
| 34 | | dd ? |
|---|
| | 51 | dd ? |
|---|
| 35 | 52 | XO ends |
|---|
| 36 | 53 | XOE segment dword use32 public 'BSS' |
|---|
| … | … | |
| 39 | 56 | DGROUP group FMB,FM,FME |
|---|
| 40 | 57 | |
|---|
| 41 | | begcode minit |
|---|
| | 58 | begcode minit |
|---|
| 42 | 59 | |
|---|
| 43 | | public __minit |
|---|
| 44 | | __minit proc near |
|---|
| 45 | | mov EDX,offset DATAGRP:FMB |
|---|
| 46 | | mov EAX,offset DATAGRP:FME |
|---|
| 47 | | mov dword ptr __moduleinfo_array+4,EDX |
|---|
| 48 | | sub EAX,EDX ; size in bytes of FM segment |
|---|
| 49 | | shr EAX,2 ; convert to array length |
|---|
| 50 | | mov dword ptr __moduleinfo_array,EAX |
|---|
| 51 | | ret |
|---|
| | 60 | ; extern (C) void _minit(); |
|---|
| | 61 | ; Converts array of ModuleInfo pointers to a D dynamic array of them, |
|---|
| | 62 | ; so they can be accessed via D. |
|---|
| | 63 | ; Result is written to: |
|---|
| | 64 | ; extern (C) ModuleInfo[] _moduleinfo_array; |
|---|
| | 65 | |
|---|
| | 66 | public __minit |
|---|
| | 67 | __minit proc near |
|---|
| | 68 | mov EDX,offset DATAGRP:FMB |
|---|
| | 69 | mov EAX,offset DATAGRP:FME |
|---|
| | 70 | mov dword ptr __moduleinfo_array+4,EDX |
|---|
| | 71 | sub EAX,EDX ; size in bytes of FM segment |
|---|
| | 72 | shr EAX,2 ; convert to array length |
|---|
| | 73 | mov dword ptr __moduleinfo_array,EAX |
|---|
| | 74 | ret |
|---|
| 52 | 75 | __minit endp |
|---|
| 53 | 76 | |
|---|
| 54 | | endcode minit |
|---|
| | 77 | endcode minit |
|---|
| 55 | 78 | |
|---|
| 56 | | end |
|---|
| | 79 | end |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic