Changeset 3664 for trunk


Ignore:
Timestamp:
Sep 17, 2010, 2:49:06 AM (15 years ago)
Author:
bird
Message:

emx: converted ldstub to nasm.

Location:
trunk/emx
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/emx/Makefile.kmk

    r3658 r3664  
    236236#
    237237# ldstub
    238 #       
     238#
     239if 0   
    239240ldstub_TEMPLATE = usr.bin.alp
    240241ldstub_SOURCES = \
    241242        src/ld/ldstub.asm \
    242243        src/ld/ldstub.def
    243 ldstub_LDFLAGS = -nostdlib -s -Wl,-O,Option,-O,alignment=1
     244ldstub_LDFLAGS = -nostdlib -s #-Wl,-O,Option,-O,alignment=1
    244245ldstub_LIBS = os2 end
     246else
     247ldstub_TEMPLATE = usr.bin.nasm
     248ldstub_SOURCES = \
     249        src/ld/ldstub-nasm.asm \
     250        src/ld/ldstub.def
     251ldstub_LDFLAGS = -nostdlib -s
     252ldstub_LIBS = os2
     253endif
    245254ldstub_EXESUFF =
    246255
  • trunk/emx/src/ld/ldstub-nasm.asm

    r3660 r3664  
    11; $Id$
    22;
    3 ; Micro stub for <app> -> <app>.exe forwarding
     3; Micro stub for <app> -> <app>.exe forwarding, nasm version.
    44;
    55; Build Instructions:
    66;   Stantard version:
    7 ;       alp ldstub.asm
    8 ;       ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib
    9 ;
    10 ;   Microversion:
    11 ;       alp -D:MICRO=1 ldstub.asm
    12 ;       ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib
     7;       nasm -f obj -o ldstub-nasm.o ldstub-nasm.asm
     8;       ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub-nasm.obj ldstub.def os2386.lib
    139;
    1410; OVERLAY may be defined for execv()/spawnv(OVERLAY,..) is to be emulated.
     
    2319;
    2420
    25     .486
     21
     22;*******************************************************************************
     23;* Global Variables                                                            *
     24;*******************************************************************************
     25extern DosExecPgm
     26extern DosQueryModuleName
     27
     28
     29;*******************************************************************************
     30;* Segment definitions                                                         *
     31;*******************************************************************************
     32segment TEXT32 public align=1 use32 FLAT class=CODE FLAT
     33segment STACK32 stack align=16 use32 class=STACK FLAT
     34
    2635
    2736;*******************************************************************************
    2837;* Structures and Typedefs                                                     *
    2938;*******************************************************************************
    30 RESULTCODES     STRUC
    31 resc_codeTerminate      DD      ?
    32 resc_codeResult DD      ?
    33 RESULTCODES     ENDS
     39segment TEXT32  ; works around warning and dummy 'text' segment.
     40struc RESC
     41    .codeTerminate      resd 1
     42    .codeResult     resd 1
     43endstruc
    3444
    35 extrn DosExecPgm:near
    36 extrn DosQueryModuleName:near
    37 
    38 
    39 DATA32 segment use32 para public 'DATA'
    40 DATA32 ends
    41 
    42 BSS32   segment use32 para public 'BSS'
    43 ; buffer for modifying the executable name
    44 achNewExeName   db 260 dup(?)
    45 padding         db   8 dup(?)           ; safety precaution.
    46 
    47 ; DosExecPgm result buffer.
    48 res             RESULTCODES <?,?>
    49 BSS32   ends
    50 
    51 STACK32 segment use32 para stack 'STACK'
    52     dd  1800h dup(?)                    ; size doesn't matter as DosExecPgm uses thunk stack in any case. :/
    53 STACK32 ends
    54 
    55 ifndef MICRO
    56 DGROUP group DATA32, BSS32, STACK32
    57 else
    58 DGROUP group TEXT32, DATA32, BSS32, STACK32
    59 endif
    60 
    61 
    62 ifndef MICRO
    63 TEXT32 segment use32 para public 'CODE'
    64 else
    65 TEXT32 segment use32 para public 'DATA'
    66 endif
    6745
    6846; Program startup registers are defined as follows.
     
    8563; @remark   I don't care about cleaning up arguments as the leave does so.
    8664;
     65segment TEXT32
    8766start:
    88     ASSUME ss:FLAT, ds:FLAT, es:FLAT, fs:nothing, gs:nothing
    89     push    ebp       
    90     mov     ebp, esp
     67..start:
     68    BITS 32
     69    enter 260 + 4 + RESC_size, 0
     70%define achNewExeName   ebp - 260 - RESC_size - 4 
     71%define res             ebp - RESC_size   
    9172   
    9273    ;
     
    9576    ; ULONG DosQueryModuleName(HMODULE hmod, ULONG ulNameLength, PCHAR pNameBuf);
    9677    ;   
    97     push    offset FLAT:achNewExeName   ; pNameBuf
    98     push    size achNewExeName          ; ulNameLength
    99     push    dword ptr [ebp+8]           ; hmod
     78    lea     ebx, [achNewExeName]
     79    push    ebx                         ; pNameBuf
     80    push    260                         ; ulNameLength
     81    push    dword [ebp+8]               ; hmod
    10082    call    DosQueryModuleName
    10183    or      eax, eax
    102     jz      modname_ok
    103    
    104     ; this ain't supposed to happen
    105     mov     edx, [ebp+4]
    106     int     3   
     84    jnz     .exec_failed                ; this ain't supposed to happen
    10785
    108 modname_ok:
    10986    ;
    11087    ; Append .EXE to the module name.
     
    11289    xor     ecx, ecx
    11390    dec     ecx
    114     mov     edi, offset FLAT:achNewExeName
     91    mov     edi, ebx                    ; achNewExeName
    11592    repne scasb
    116     mov     dword ptr [edi-1], 'EXE.'
    117     mov     dword ptr [edi+3], 0
     93    mov     dword [edi-1], 'EXE.'
     94    mov     dword [edi+3], esi          ; esi = 0 at this point.
    11895
    11996    ;
     
    128105    ;                            PCSZ  pName);
    129106    ;
    130     xor     ecx, ecx
    131     push    offset FLAT:achNewExeName   ; pName
    132     push    offset FLAT:res             ; pRes
    133     push    dword ptr [ebp + 10h]       ; pEnv
    134     push    dword ptr [ebp + 14h]       ; pArg
    135 ifdef OVERLAY
     107    push    ebx                         ; pName (achNewExeName)
     108    lea     edi, [res]
     109    push    edi                         ; pRes
     110    push    dword [ebp + 10h]           ; pEnv
     111    push    dword [ebp + 14h]           ; pArg
     112%ifdef OVERLAY
    136113    push    1                           ; execFlag = EXEC_ASYNC
    137 else
    138     push    ecx                         ; execFlag = EXEC_SYNC = 0
    139 endif   
    140     push    ecx                         ; cbObjname
    141     push    ecx                         ; pObjname
     114%else
     115    push    esi                         ; execFlag = EXEC_SYNC = 0
     116%endif   
     117    push    esi                         ; cbObjname
     118    push    esi                         ; pObjname
    142119    call    DosExecPgm
    143120    or      eax, eax
    144     jz      exec_success
     121    jz      .exec_success
    145122   
    146 exec_failed:
    147     mov     eax, 07fh
    148     jmp     done
     123.exec_failed:
     124    mov     eax, byte 07fh
     125    jmp     .done
    149126   
    150 exec_success:       
    151 ifndef OVERLAY
     127.exec_success:       
     128%ifndef OVERLAY
    152129    ;
    153130    ; Retrieve the result code.
    154131    ;
    155     mov     eax, res.resc_codeResult
    156     mov     edx, res.resc_codeTerminate
    157     or      edx, edx
    158     jz      done
     132    mov     eax, [res + RESC.codeResult]
     133    cmp     [res + RESC.codeTerminate], esi
     134    jz      .done
    159135   
    160136    ;
     
    162138    ; We shouldn't return 0 when we trap, crash or is killed.
    163139    ;
    164     mov     eax, 0ffh
    165 endif           
     140    mov     eax, byte 0ffh
     141%endif           
    166142
    167143
    168 done:
     144.done:
    169145    leave   
    170     ret     
    171 TEXT32 ends
     146    ret   
    172147
    173 end start
    174148
     149; for emxomfld
     150ABSOLUTE 0
     151global WEAK$ZERO
     152WEAK$ZERO:
     153     
Note: See TracChangeset for help on using the changeset viewer.