VirtualBox

Ignore:
Timestamp:
Nov 16, 2015 4:21:44 PM (9 years ago)
Author:
vboxsync
Message:

asm-amd64-x86-watcom-32.h: Initial pragma aux implementation for 32-bit Watcom C/C++ code.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm-amd64-x86-watcom-32.h

    r58699 r58701  
    11/** @file
    2  * IPRT - AMD64 and x86 Specific Assembly Functions, 16-bit Watcom C pragma aux.
     2 * IPRT - AMD64 and x86 Specific Assembly Functions, 32-bit Watcom C pragma aux.
    33 */
    44
     
    2727# error "Don't include this header directly."
    2828#endif
    29 #ifndef ___iprt_asm_amd64_x86_watcom_16_h
    30 #define ___iprt_asm_amd64_x86_watcom_16_h
    31 
    32 #if !RT_FAR_DATA
    33 # error "Only works with far data pointers!"
     29#ifndef ___iprt_asm_amd64_x86_watcom_32_h
     30#define ___iprt_asm_amd64_x86_watcom_32_h
     31
     32#ifndef __FLAT__
     33# error "Only works with flat pointers! (-mf)"
    3434#endif
    3535
    36 /*
    37  * Turns out we cannot use 'ds' for segment stuff here because the compiler
    38  * seems to insists on loading the DGROUP segment into 'ds' before calling
    39  * stuff when using -ecc.  Using 'es' instead as this seems to work fine.
    40  */
    4136
    4237#pragma aux ASMGetIDTR = \
    43     "sidt fword ptr es:[bx]" \
    44     parm [es bx] \
     38    "sidt fword ptr [ecx]" \
     39    parm [ecx] \
    4540    modify exact [];
    4641
    4742#pragma aux ASMGetIdtrLimit = \
    48     "sub  sp, 8" \
    49     "mov  bx, sp" \
    50     "sidt fword ptr ss:[bx]" \
    51     "mov  bx, ss:[bx]" \
    52     "add  sp, 8" \
     43    "sub  esp, 8" \
     44    "sidt fword ptr [esp]" \
     45    "mov  cx, [esp]" \
     46    "add  esp, 8" \
    5347    parm [] \
    54     value [bx] \
    55     modify exact [bx];
     48    value [cx] \
     49    modify exact [ecx];
    5650
    5751#pragma aux ASMSetIDTR = \
    58     "lidt fword ptr es:[bx]" \
    59     parm [es bx] nomemory \
     52    "lidt fword ptr [ecx]" \
     53    parm [ecx] nomemory \
    6054    modify nomemory;
    6155
    6256#pragma aux ASMGetGDTR = \
    63     "sgdt fword ptr es:[bx]" \
    64     parm [es bx] \
     57    "sgdt fword ptr [ecx]" \
     58    parm [ecx] \
    6559    modify exact [];
    6660
    6761#pragma aux ASMSetGDTR = \
    68     "lgdt fword ptr es:[bx]" \
    69     parm [es bx] nomemory \
     62    "lgdt fword ptr [ecx]" \
     63    parm [ecx] nomemory \
    7064    modify exact [] nomemory;
    7165
     
    7468    parm [] nomemory \
    7569    value [ax] \
    76     modify exact [ax] nomemory;
     70    modify exact [eax] nomemory;
    7771
    7872#pragma aux ASMGetDS = \
     
    8074    parm [] nomemory \
    8175    value [ax] \
    82     modify exact [ax] nomemory;
     76    modify exact [eax] nomemory;
    8377
    8478#pragma aux ASMGetES = \
     
    8680    parm [] nomemory \
    8781    value [ax] \
    88     modify exact [ax] nomemory;
     82    modify exact [eax] nomemory;
    8983
    9084#pragma aux ASMGetFS = \
     
    9286    parm [] nomemory \
    9387    value [ax] \
    94     modify exact [ax] nomemory;
     88    modify exact [eax] nomemory;
    9589
    9690#pragma aux ASMGetGS = \
     
    9892    parm [] nomemory \
    9993    value [ax] \
    100     modify exact [ax] nomemory;
     94    modify exact [eax] nomemory;
    10195
    10296#pragma aux ASMGetSS = \
     
    10498    parm [] nomemory \
    10599    value [ax] \
    106     modify exact [ax] nomemory;
     100    modify exact [eax] nomemory;
    107101
    108102#pragma aux ASMGetTR = \
     
    110104    parm [] nomemory \
    111105    value [ax] \
    112     modify exact [ax] nomemory;
     106    modify exact [eax] nomemory;
    113107
    114108#pragma aux ASMGetLDTR = \
     
    116110    parm [] nomemory \
    117111    value [ax] \
    118     modify exact [ax] nomemory;
    119 
    120 #pragma aux ASMGetGS = \
    121     "mov ax, gs" \
    122     parm [] nomemory \
    123     value [ax] \
    124     modify exact [ax] nomemory;
     112    modify exact [eax] nomemory;
    125113
    126114/** @todo ASMGetSegAttr   */
    127115
    128116#pragma aux ASMGetFlags = \
    129     "pushf" \
    130     "pop ax" \
    131     parm [] nomemory \
    132     value [ax] \
    133     modify exact [ax] nomemory;
     117    "pushfd" \
     118    "pop eax" \
     119    parm [] nomemory \
     120    value [eax] \
     121    modify exact [eax] nomemory;
    134122
    135123#pragma aux ASMSetFlags = \
    136     "push ax" \
    137     "popf" \
    138     parm [ax] nomemory \
     124    "push eax" \
     125    "popfd" \
     126    parm [eax] nomemory \
    139127    modify exact [] nomemory;
    140128
    141129#pragma aux ASMChangeFlags = \
    142     "pushf" \
    143     "pop ax" \
    144     "and dx, ax" \
    145     "or  dx, cx" \
    146     "push dx" \
    147     "popf" \
    148     parm [dx] [cx] nomemory \
    149     value [ax] \
    150     modify exact [dx] nomemory;
     130    "pushfd" \
     131    "pop eax" \
     132    "and edx, eax" \
     133    "or  edx, ecx" \
     134    "push edx" \
     135    "popfd" \
     136    parm [edx] [ecx] nomemory \
     137    value [eax] \
     138    modify exact [edx] nomemory;
    151139
    152140#pragma aux ASMAddFlags = \
    153     "pushf" \
    154     "pop ax" \
    155     "or  dx, ax" \
    156     "push dx" \
    157     "popf" \
    158     parm [dx] nomemory \
    159     value [ax] \
    160     modify exact [dx] nomemory;
     141    "pushfd" \
     142    "pop eax" \
     143    "or  edx, eax" \
     144    "push edx" \
     145    "popfd" \
     146    parm [edx] nomemory \
     147    value [eax] \
     148    modify exact [edx] nomemory;
    161149
    162150#pragma aux ASMClearFlags = \
    163     "pushf" \
    164     "pop ax" \
    165     "and dx, ax" \
    166     "push dx" \
    167     "popf" \
    168     parm [dx] nomemory \
    169     value [ax] \
    170     modify exact [dx] nomemory;
     151    "pushfd" \
     152    "pop eax" \
     153    "and edx, eax" \
     154    "push edx" \
     155    "popfd" \
     156    parm [edx] nomemory \
     157    value [eax] \
     158    modify exact [edx] nomemory;
    171159
    172160/* Note! Must use the 64-bit integer return value convension.
     
    175163    ".586" \
    176164    "rdtsc" \
    177     "mov ebx, edx" \
    178     "mov ecx, eax" \
    179     "shr ecx, 16" \
    180     "xchg eax, edx" \
    181     "shr eax, 16" \
    182     parm [] nomemory \
    183     value [dx cx bx ax] \
    184     modify exact [ax bx cx dx] nomemory;
    185 
    186 /** @todo ASMReadTscWithAux if needed (rdtscp not recognized by compiler)   */
    187 
     165    parm [] nomemory \
     166    value [eax edx] \
     167    modify exact [edx eax] nomemory;
     168
     169#pragma aux ASMReadTscWithAux = \
     170    0x0f 0x01 0xf9 \
     171    parm [ecx] \
     172    value [eax edx] \
     173    modify exact [eax edx];
    188174
    189175/* ASMCpuId: Implemented externally, too many parameters. */
    190176/* ASMCpuId_Idx_ECX: Implemented externally, too many parameters. */
    191177/* ASMCpuIdExSlow: Always implemented externally. */
    192 /* ASMCpuId_ECX_EDX: Implemented externally, too many parameters. */
    193 /* ASMCpuId_EAX: Implemented externally, lazy bird. */
    194 /* ASMCpuId_EBX: Implemented externally, lazy bird. */
    195 /* ASMCpuId_ECX: Implemented externally, lazy bird. */
    196 /* ASMCpuId_EDX: Implemented externally, lazy bird. */
     178
     179#pragma aux ASMCpuId_ECX_EDX = \
     180    "cpuid" \
     181    "mov [edi], ecx" \
     182    "mov [esi], edx" \
     183    parm [ecx] [edi] [esi] \
     184    modify exact [eax ebx ecx edx];
     185
     186#pragma aux ASMCpuId_EAX = \
     187    "cpuid" \
     188    parm [ecx] \
     189    value [eax] \
     190    modify exact [eax ebx ecx edx];
     191
     192#pragma aux ASMCpuId_EBX = \
     193    "cpuid" \
     194    parm [ecx] \
     195    value [ebx] \
     196    modify exact [eax ebx ecx edx];
     197
     198#pragma aux ASMCpuId_ECX = \
     199    "cpuid" \
     200    parm [ecx] \
     201    value [ecx] \
     202    modify exact [eax ebx ecx edx];
     203
     204#pragma aux ASMCpuId_EDX = \
     205    "cpuid" \
     206    parm [ecx] \
     207    value [edx] \
     208    modify exact [eax ebx ecx edx];
     209
    197210/* ASMHasCpuId: MSC inline in main source file. */
    198211/* ASMGetApicId: Implemented externally, lazy bird. */
    199212
    200 /* Note! Again, when returning two registers, watcom have certain fixed ordering rules (low:high):
    201             ax:bx, ax:cx, ax:dx, ax:si, ax:di
    202             bx:cx, bx:dx, bx:si, bx:di
    203             dx:cx, si:cx, di:cx
    204             si:dx, di:dx
    205             si:di
    206          This ordering seems to apply to parameter values too. */
    207213#pragma aux ASMGetCR0 = \
    208214    "mov eax, cr0" \
    209     "mov edx, eax" \
    210     "shr edx, 16" \
    211     parm [] nomemory \
    212     value [ax dx] \
    213     modify exact [ax dx] nomemory;
     215    parm [] nomemory \
     216    value [eax] \
     217    modify exact [eax] nomemory;
    214218
    215219#pragma aux ASMSetCR0 = \
    216     "shl edx, 16" \
    217     "mov dx, ax" \
    218     "mov cr0, edx" \
    219     parm [ax dx] nomemory \
    220     modify exact [dx] nomemory;
     220    "mov cr0, eax" \
     221    parm [eax] nomemory \
     222    modify exact [] nomemory;
    221223
    222224#pragma aux ASMGetCR2 = \
    223225    "mov eax, cr2" \
    224     "mov edx, eax" \
    225     "shr edx, 16" \
    226     parm [] nomemory \
    227     value [ax dx] \
    228     modify exact [ax dx] nomemory;
     226    parm [] nomemory \
     227    value [eax] \
     228    modify exact [eax] nomemory;
    229229
    230230#pragma aux ASMSetCR2 = \
    231     "shl edx, 16" \
    232     "mov dx, ax" \
    233     "mov cr2, edx" \
    234     parm [ax dx] nomemory \
    235     modify exact [dx] nomemory;
     231    "mov cr2, eax" \
     232    parm [eax] nomemory \
     233    modify exact [] nomemory;
    236234
    237235#pragma aux ASMGetCR3 = \
    238236    "mov eax, cr3" \
    239     "mov edx, eax" \
    240     "shr edx, 16" \
    241     parm [] nomemory \
    242     value [ax dx] \
    243     modify exact [ax dx] nomemory;
     237    parm [] nomemory \
     238    value [eax] \
     239    modify exact [eax] nomemory;
    244240
    245241#pragma aux ASMSetCR3 = \
    246     "shl edx, 16" \
    247     "mov dx, ax" \
    248     "mov cr3, edx" \
    249     parm [ax dx] nomemory \
    250     modify exact [dx] nomemory;
     242    "mov cr3, eax" \
     243    parm [eax] nomemory \
     244    modify exact [] nomemory;
    251245
    252246#pragma aux ASMReloadCR3 = \
     
    254248    "mov cr3, eax" \
    255249    parm [] nomemory \
    256     modify exact [ax] nomemory;
     250    modify exact [eax] nomemory;
    257251
    258252#pragma aux ASMGetCR4 = \
    259253    "mov eax, cr4" \
    260     "mov edx, eax" \
    261     "shr edx, 16" \
    262     parm [] nomemory \
    263     value [ax dx] \
    264     modify exact [ax dx] nomemory;
     254    parm [] nomemory \
     255    value [eax] \
     256    modify exact [eax] nomemory;
    265257
    266258#pragma aux ASMSetCR4 = \
    267     "shl edx, 16" \
    268     "mov dx, ax" \
    269     "mov cr4, edx" \
    270     parm [ax dx] nomemory \
    271     modify exact [dx] nomemory;
    272 
    273 /* ASMGetCR8: Don't bother for 16-bit. */
    274 /* ASMSetCR8: Don't bother for 16-bit. */
     259    "mov cr4, eax" \
     260    parm [eax] nomemory \
     261    modify exact [] nomemory;
     262
     263/* ASMGetCR8: Don't bother for 32-bit. */
     264/* ASMSetCR8: Don't bother for 32-bit. */
    275265
    276266#pragma aux ASMIntEnable = \
     
    285275
    286276#pragma aux ASMIntDisableFlags = \
    287     "pushf" \
     277    "pushfd" \
    288278    "cli" \
    289     "pop ax" \
    290     parm [] nomemory \
    291     value [ax] \
     279    "pop eax" \
     280    parm [] nomemory \
     281    value [eax] \
    292282    modify exact [] nomemory;
    293283
     
    299289#pragma aux ASMRdMsr = \
    300290    ".586" \
    301     "shl ecx, 16" \
    302     "mov cx, ax" \
    303291    "rdmsr" \
    304     "mov ebx, edx" \
    305     "mov ecx, eax" \
    306     "shr ecx, 16" \
    307     "xchg eax, edx" \
    308     "shr eax, 16" \
    309     parm [ax cx] nomemory \
    310     value [dx cx bx ax] \
    311     modify exact [ax bx cx dx] nomemory;
    312 
    313 /* ASMWrMsr: Implemented externally, lazy bird. */
    314 /* ASMRdMsrEx: Implemented externally, lazy bird. */
    315 /* ASMWrMsrEx: Implemented externally, lazy bird. */
     292    parm [ecx] nomemory \
     293    value [eax edx] \
     294    modify exact [eax edx] nomemory;
     295
     296#pragma aux ASMWrMsr = \
     297    ".586" \
     298    "wrmsr" \
     299    parm [ecx] [eax edx] nomemory \
     300    modify exact [] nomemory;
     301
     302#pragma aux ASMRdMsrEx = \
     303    ".586" \
     304    "rdmsr" \
     305    parm [ecx] [edi] nomemory \
     306    value [eax edx] \
     307    modify exact [eax edx] nomemory;
     308
     309#pragma aux ASMWrMsrEx = \
     310    ".586" \
     311    "wrmsr" \
     312    parm [ecx] [edi] [eax edx] nomemory \
     313    modify exact [] nomemory;
    316314
    317315#pragma aux ASMRdMsr_Low = \
    318316    ".586" \
    319     "shl ecx, 16" \
    320     "mov cx, ax" \
    321317    "rdmsr" \
    322     "mov edx, eax" \
    323     "shr edx, 16" \
    324     parm [ax cx] nomemory \
    325     value [ax dx] \
    326     modify exact [ax bx cx dx] nomemory;
     318    parm [ecx] nomemory \
     319    value [eax] \
     320    modify exact [eax edx] nomemory;
    327321
    328322#pragma aux ASMRdMsr_High = \
    329323    ".586" \
    330     "shl ecx, 16" \
    331     "mov cx, ax" \
    332324    "rdmsr" \
    333     "mov eax, edx" \
    334     "shr edx, 16" \
    335     parm [ax cx] nomemory \
    336     value [ax dx] \
    337     modify exact [ax bx cx dx] nomemory;
     325    parm [ecx] nomemory \
     326    value [edx] \
     327    modify exact [eax edx] nomemory;
    338328
    339329
    340330#pragma aux ASMGetDR0 = \
    341331    "mov eax, dr0" \
    342     "mov edx, eax" \
    343     "shr edx, 16" \
    344     parm [] nomemory \
    345     value [ax dx] \
    346     modify exact [ax dx] nomemory;
     332    parm [] nomemory \
     333    value [eax] \
     334    modify exact [eax] nomemory;
    347335
    348336#pragma aux ASMGetDR1 = \
    349337    "mov eax, dr1" \
    350     "mov edx, eax" \
    351     "shr edx, 16" \
    352     parm [] nomemory \
    353     value [ax dx] \
    354     modify exact [ax dx] nomemory;
     338    parm [] nomemory \
     339    value [eax] \
     340    modify exact [eax] nomemory;
    355341
    356342#pragma aux ASMGetDR2 = \
    357343    "mov eax, dr2" \
    358     "mov edx, eax" \
    359     "shr edx, 16" \
    360     parm [] nomemory \
    361     value [ax dx] \
    362     modify exact [ax dx] nomemory;
     344    parm [] nomemory \
     345    value [eax] \
     346    modify exact [eax] nomemory;
    363347
    364348#pragma aux ASMGetDR3 = \
    365349    "mov eax, dr3" \
    366     "mov edx, eax" \
    367     "shr edx, 16" \
    368     parm [] nomemory \
    369     value [ax dx] \
    370     modify exact [ax dx] nomemory;
     350    parm [] nomemory \
     351    value [eax] \
     352    modify exact [eax] nomemory;
    371353
    372354#pragma aux ASMGetDR6 = \
    373355    "mov eax, dr6" \
    374     "mov edx, eax" \
    375     "shr edx, 16" \
    376     parm [] nomemory \
    377     value [ax dx] \
    378     modify exact [ax dx] nomemory;
     356    parm [] nomemory \
     357    value [eax] \
     358    modify exact [eax] nomemory;
    379359
    380360#pragma aux ASMGetAndClearDR6 = \
     
    382362    "mov eax, dr6" \
    383363    "mov dr6, edx" \
    384     "mov edx, eax" \
    385     "shr edx, 16" \
    386     parm [] nomemory \
    387     value [ax dx] \
    388     modify exact [ax dx] nomemory;
     364    parm [] nomemory \
     365    value [eax] \
     366    modify exact [eax edx] nomemory;
    389367
    390368#pragma aux ASMGetDR7 = \
    391369    "mov eax, dr7" \
    392     "mov edx, eax" \
    393     "shr edx, 16" \
    394     parm [] nomemory \
    395     value [ax dx] \
    396     modify exact [ax dx] nomemory;
     370    parm [] nomemory \
     371    value [eax] \
     372    modify exact [eax] nomemory;
    397373
    398374#pragma aux ASMSetDR0 = \
    399     "shl edx, 16" \
    400     "mov dx, ax" \
    401     "mov dr0, edx" \
    402     parm [ax dx] nomemory \
    403     modify exact [dx] nomemory;
     375    "mov dr0, eax" \
     376    parm [eax] nomemory \
     377    modify exact [] nomemory;
    404378
    405379#pragma aux ASMSetDR1 = \
    406     "shl edx, 16" \
    407     "mov dx, ax" \
    408     "mov dr1, edx" \
    409     parm [ax dx] nomemory \
    410     modify exact [dx] nomemory;
     380    "mov dr1, eax" \
     381    parm [eax] nomemory \
     382    modify exact [] nomemory;
    411383
    412384#pragma aux ASMSetDR2 = \
    413     "shl edx, 16" \
    414     "mov dx, ax" \
    415     "mov dr2, edx" \
    416     parm [ax dx] nomemory \
    417     modify exact [dx] nomemory;
     385    "mov dr2, eax" \
     386    parm [eax] nomemory \
     387    modify exact [] nomemory;
    418388
    419389#pragma aux ASMSetDR3 = \
    420     "shl edx, 16" \
    421     "mov dx, ax" \
    422     "mov dr3, edx" \
    423     parm [ax dx] nomemory \
    424     modify exact [dx] nomemory;
     390    "mov dr3, eax" \
     391    parm [eax] nomemory \
     392    modify exact [] nomemory;
    425393
    426394#pragma aux ASMSetDR6 = \
    427     "shl edx, 16" \
    428     "mov dx, ax" \
    429     "mov dr6, edx" \
    430     parm [ax dx] nomemory \
    431     modify exact [dx] nomemory;
     395    "mov dr6, eax" \
     396    parm [eax] nomemory \
     397    modify exact [] nomemory;
    432398
    433399#pragma aux ASMSetDR7 = \
    434     "shl edx, 16" \
    435     "mov dx, ax" \
    436     "mov dr7, edx" \
    437     parm [ax dx] nomemory \
    438     modify exact [dx] nomemory;
     400    "mov dr7, eax" \
     401    parm [eax] nomemory \
     402    modify exact [] nomemory;
    439403
    440404/* Yeah, could've used outp here, but this keeps the main file simpler. */
     
    462426
    463427#pragma aux ASMOutU32 = \
    464     "shl ecx, 16" \
    465     "mov cx, ax" \
    466     "mov eax, ecx" \
    467428    "out dx, eax" \
    468     parm [dx] [ax cx] nomemory \
     429    parm [dx] [eax] nomemory \
    469430    modify exact [] nomemory;
    470431
    471432#pragma aux ASMInU32 = \
    472433    "in eax, dx" \
    473     "mov ecx, eax" \
    474     "shr ecx, 16" \
    475434    parm [dx] nomemory \
    476     value [ax cx] \
     435    value [eax] \
    477436    modify exact [] nomemory;
    478437
    479438#pragma aux ASMOutStrU8 = \
    480     "mov ds, bx" \
    481439    "rep outsb" \
    482     parm [dx] [bx si] [cx] nomemory \
    483     modify exact [si cx ds] nomemory;
     440    parm [dx] [esi] [ecx] nomemory \
     441    modify exact [esi ecx] nomemory;
    484442
    485443#pragma aux ASMInStrU8 = \
    486444    "rep insb" \
    487     parm [dx] [es di] [cx] \
    488     modify exact [di cx];
     445    parm [dx] [edi] [ecx] \
     446    modify exact [edi ecx];
    489447
    490448#pragma aux ASMOutStrU16 = \
    491     "mov ds, bx" \
    492449    "rep outsw" \
    493     parm [dx] [bx si] [cx] nomemory \
    494     modify exact [si cx ds] nomemory;
     450    parm [dx] [esi] [ecx] nomemory \
     451    modify exact [esi ecx] nomemory;
    495452
    496453#pragma aux ASMInStrU16 = \
    497454    "rep insw" \
    498     parm [dx] [es di] [cx] \
    499     modify exact [di cx];
     455    parm [dx] [edi] [ecx] \
     456    modify exact [edi ecx];
    500457
    501458#pragma aux ASMOutStrU32 = \
    502     "mov ds, bx" \
    503459    "rep outsd" \
    504     parm [dx] [bx si] [cx] nomemory \
    505     modify exact [si cx ds] nomemory;
     460    parm [dx] [esi] [ecx] nomemory \
     461    modify exact [esi ecx] nomemory;
    506462
    507463#pragma aux ASMInStrU32 = \
    508464    "rep insd" \
    509     parm [dx] [es di] [cx] \
    510     modify exact [di cx];
    511 
    512 /* ASMInvalidatePage: When needed. */
     465    parm [dx] [edi] [ecx] \
     466    modify exact [edi ecx];
     467
     468#pragma aux ASMInvalidatePage = \
     469    "invlpg [eax]" \
     470    parm [eax] \
     471    modify exact [];
    513472
    514473#pragma aux ASMWriteBackAndInvalidateCaches = \
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette