123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566 |
- #if defined(__APPLE__)
- #define SAVE_STACK "pushl %ebp\nmovl %esp, %ebp\nandl $-16, %esp\n"
- #define RESTORE_STACK "leave\n"
- #else
- #define SAVE_STACK
- #define RESTORE_STACK
- #endif
- /* note: only EEL_F_SIZE=8 is now supported (no float EEL_F's) */
- void nseel_asm_1pdd(void)
- {
- __asm__(
- SAVE_STACK
- #ifdef TARGET_X64
- "movq (%eax), %xmm0\n"
- "subl $128, %rsp\n"
- "movl $0xffffffff, %edi\n"
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "call *%edi\n"
- "movl %r15, %rsi\n"
- "movq xmm0, (%r15)\n"
- #else
- "call *%edi\n"
- "movq xmm0, (%esi)\n"
- #endif
- "addl $128, %rsp\n"
- #else
- "subl $8, %esp\n" /* keep stack aligned */
- "pushl 4(%eax)\n" /* push parameter */
- "pushl (%eax)\n" /* push the rest of the parameter */
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "fstpl (%esi)\n" /* store result */
- "addl $16, %esp\n"
- #endif
- "movl %esi, %eax\n" /* set return value */
- "addl $8, %esi\n" /* advance worktab ptr */
- RESTORE_STACK
- );
- }
- void nseel_asm_1pdd_end(void){}
- void nseel_asm_2pdd(void)
- {
- __asm__(
- SAVE_STACK
- #ifdef TARGET_X64
- "movq (%eax), xmm1\n"
- "movq (%edi), xmm0\n"
- "subl $128, %rsp\n"
- "movl $0xffffffff, %edi\n"
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "call *%edi\n"
- "movl %r15, %rsi\n"
- "movq xmm0, (%r15)\n"
- #else
- "call *%edi\n"
- "movq xmm0, (%esi)\n"
- #endif
- "addl $128, %rsp\n"
- #else
- "pushl 4(%eax)\n" /* push parameter */
- "pushl (%eax)\n" /* push the rest of the parameter */
- "pushl 4(%edi)\n" /* push parameter */
- "pushl (%edi)\n" /* push the rest of the parameter */
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "fstpl (%esi)\n" /* store result */
- "addl $16, %esp\n"
- #endif
- "movl %esi, %eax\n" /* set return value */
- "addl $8, %esi\n" /* advance worktab ptr */
- RESTORE_STACK
- );
- }
- void nseel_asm_2pdd_end(void){}
- void nseel_asm_2pdds(void)
- {
- __asm__(
- SAVE_STACK
- #ifdef TARGET_X64
- "movq (%eax), xmm1\n"
- "movq (%edi), xmm0\n"
- "subl $128, %rsp\n"
- "movl $0xffffffff, %eax\n"
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl %rdi, %r14\n"
- "call *%eax\n"
- "movl %r15, %rsi\n"
- "movq xmm0, (%r14)\n"
- "movl %r14, %rax\n" /* set return value */
- #else
- "call *%eax\n"
- "movq xmm0, (%edi)\n"
- "movl %edi, %eax\n" /* set return value */
- #endif
- "subl $128, %rsp\n"
- #else
- "pushl 4(%eax)\n" /* push parameter */
- "pushl (%eax)\n" /* push the rest of the parameter */
- "pushl 4(%edi)\n" /* push parameter */
- "pushl (%edi)\n" /* push the rest of the parameter */
- "movl $0xffffffff, %eax\n"
- "call *%eax\n"
- "fstpl (%edi)\n" /* store result */
- "addl $16, %esp\n"
- "movl %edi, %eax\n" /* set return value */
- #endif
- RESTORE_STACK
- );
- }
- void nseel_asm_2pdds_end(void){}
- void nseel_asm_2pp(void)
- {
- __asm__(
- SAVE_STACK
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- /* rdi is first parameter */
- "movl %rax, %rsi\n"
- "subl $128, %rsp\n"
- "movl $0xffffffff, %eax\n"
- "call *%eax\n"
- "movl %r15, %rsi\n"
- "movq xmm0, (%r15)\n"
- #else
- "movl %edi, %ecx\n"
- "movl %eax, %edx\n"
- "subl $128, %rsp\n"
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "movq xmm0, (%esi)\n"
- #endif
- "addl $128, %rsp\n"
- #else
- "subl $8, %esp\n" /* keep stack aligned */
- "pushl %eax\n" /* push parameter */
- "pushl %edi\n" /* push second parameter */
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n" /* store result */
- "addl $16, %esp\n"
- #endif
- "movl %esi, %eax\n" /* set return value */
- "addl $" EEL_F_SSTR ", %esi\n" /* advance worktab ptr */
- RESTORE_STACK
- );
- }
- void nseel_asm_2pp_end(void) {}
-
- void nseel_asm_1pp(void)
- {
- __asm__(
- SAVE_STACK
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl %eax, %edi\n"
- "subl $128, %rsp\n"
- "movl $0xffffffff, %rax\n"
- "call *%rax\n"
- "movl %r15, %rsi\n"
- "movq xmm0, (%r15)\n"
- #else
- "movl %eax, %ecx\n"
- "subl $128, %rsp\n"
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "movq xmm0, (%esi)\n"
- #endif
- "addl $128, %rsp\n"
- #else
- "subl $12, %esp\n" /* keep stack aligned */
- "pushl %eax\n" /* push parameter */
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n" /* store result */
- "addl $16, %esp\n"
- #endif
- "movl %esi, %eax\n" /* set return value */
- "addl $" EEL_F_SSTR ", %esi\n" /* advance worktab ptr */
- RESTORE_STACK
- );
- }
- void nseel_asm_1pp_end(void){}
- //---------------------------------------------------------------------------------------------------------------
- // do nothing, eh
- void nseel_asm_exec2(void)
- {
- __asm__(
- ""
- );
- }
- void nseel_asm_exec2_end(void) { }
- void nseel_asm_invsqrt(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "movl $0x5f3759df, %edx\n"
- "fsts (%esi)\n"
- #ifdef TARGET_X64
- "movl 0xffffffff, %rax\n"
- "subl %ecx, %ecx\n"
- "fmul" EEL_F_SUFFIX " (%rax)\n"
- #else
- "fmul" EEL_F_SUFFIX " (0xffffffff)\n"
- #endif
- "movl (%esi), %ecx\n"
- "sarl $1, %ecx\n"
- "subl %ecx, %edx\n"
- "movl %edx, (%esi)\n"
- "fmuls (%esi)\n"
- "fmuls (%esi)\n"
- #ifdef TARGET_X64
- "movl 0xffffffff, %rax\n"
- "fadd" EEL_F_SUFFIX " (%rax)\n"
- #else
- "fadd" EEL_F_SUFFIX " (0xffffffff)\n"
- #endif
- "fmuls (%esi)\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_invsqrt_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_sin(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fsin\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_sin_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_cos(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fcos\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_cos_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_tan(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fptan\n"
- "movl %esi, %eax\n"
- "fstp %st(0)\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_tan_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_sqr(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fmul %st(0), %st(0)\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_sqr_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_sqrt(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- "fsqrt\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_sqrt_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_log(void)
- {
- __asm__(
- "fldln2\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "movl %esi, %eax\n"
- "fyl2x\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_log_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_log10(void)
- {
- __asm__(
- "fldlg2\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "movl %esi, %eax\n"
- "fyl2x\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
-
- );
- }
- void nseel_asm_log10_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_abs(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_abs_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_assign(void)
- {
- #ifdef TARGET_X64
- __asm__(
- "movll (%rax), %rdx\n"
- "movll %rdx, %rcx\n"
- "shrl $32, %rdx\n"
- "andl $0x7FF00000, %edx\n"
- "jz 1f\n"
- "cmpl $0x7FF00000, %edx\n"
- "je 1f\n"
- "jmp 0f\n"
- "1:\n"
- "subl %rcx, %rcx\n"
- "0:\n"
- "movll %rcx, (%edi)\n"
- );
- #else
- #if EEL_F_SIZE == 8
- __asm__(
- "movl 4(%eax), %edx\n"
- "movl (%eax), %ecx\n"
- "andl $0x7ff00000, %edx\n"
- "jz 1f\n" // if exponent=zero, zero
- "cmpl $0x7ff00000, %edx\n"
- "je 1f\n" // if exponent=all 1s, zero
- "movl 4(%eax), %edx\n" // reread
- "jmp 0f\n"
- "1:\n"
- "subl %ecx, %ecx\n"
- "subl %edx, %edx\n"
- "0:\n"
- "movl %ecx, (%edi)\n"
- "movl %edx, 4(%edi)\n"
- );
- #else
- __asm__(
- "movl (%eax), %ecx\n"
- "movl %ecx, (%edi)\n"
- );
- #endif
- #endif
- }
- void nseel_asm_assign_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_add(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fadd" EEL_F_SUFFIX " (%edi)\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_add_end(void) {}
- void nseel_asm_add_op(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fadd" EEL_F_SUFFIX " (%edi)\n"
- "movl %edi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%edi)\n"
- );
- }
- void nseel_asm_add_op_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_sub(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fsub" EEL_F_SUFFIX " (%eax)\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_sub_end(void) {}
- void nseel_asm_sub_op(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fsub" EEL_F_SUFFIX " (%eax)\n"
- "movl %edi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%edi)\n"
- );
- }
- void nseel_asm_sub_op_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_mul(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fmul" EEL_F_SUFFIX " (%eax)\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_mul_end(void) {}
- void nseel_asm_mul_op(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fmul" EEL_F_SUFFIX " (%edi)\n"
- "movl %edi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%edi)\n"
- );
- }
- void nseel_asm_mul_op_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_div(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fdiv" EEL_F_SUFFIX " (%eax)\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_div_end(void) {}
- void nseel_asm_div_op(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fdiv" EEL_F_SUFFIX " (%eax)\n"
- "movl %edi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%edi)\n"
- );
- }
- void nseel_asm_div_op_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_mod(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- "fistpl (%esi)\n"
- "fabs\n"
- "fistpl 4(%esi)\n"
- "xorl %edx, %edx\n"
- #ifdef TARGET_X64
- "subl %eax, %eax\n"
- #endif
- "cmpl $0, (%esi)\n"
- "je 0f\n" // skip devide, set return to 0
- "movl 4(%esi), %eax\n"
- "divl (%esi)\n"
- "0:\n"
- "movl %edx, (%esi)\n"
- "fildl (%esi)\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_mod_end(void) {}
- void nseel_asm_mod_op(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- "fistpl (%edi)\n"
- "fabs\n"
- "fistpl (%esi)\n"
- #ifdef TARGET_X64
- "subl %eax, %eax\n"
- #endif
- "xorl %edx, %edx\n"
- "cmpl $0, (%edi)\n"
- "je 0f\n" // skip devide, set return to 0
- "movl (%esi), %eax\n"
- "divl (%edi)\n"
- "0:\n"
- "movl %edx, (%edi)\n"
- "fildl (%edi)\n"
- "movl %edi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%edi)\n"
- );
- }
- void nseel_asm_mod_op_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_or(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "movl %esi, %eax\n"
- "fistpll (%esi)\n"
- "fistpll 8(%esi)\n"
- #ifdef TARGET_X64
- "movll 8(%rsi), %rdi\n"
- "orll %rdi, (%rsi)\n"
- #else
- "movl 8(%esi), %edi\n"
- "movl 12(%esi), %ecx\n"
- "orl %edi, (%esi)\n"
- "orl %ecx, 4(%esi)\n"
- #endif
- "fildll (%esi)\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_or_end(void) {}
- void nseel_asm_or_op(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fistpll (%edi)\n"
- "fistpll (%esi)\n"
- #ifdef TARGET_X64
- "movll (%rsi), %rax\n"
- "orll %rax, (%rdi)\n"
- #else
- "movl (%esi), %eax\n"
- "movl 4(%esi), %ecx\n"
- "orl %eax, (%edi)\n"
- "orl %ecx, 4(%edi)\n"
- #endif
- "fildll (%edi)\n"
- "movl %edi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%edi)\n"
- );
- }
- void nseel_asm_or_op_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_and(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "movl %esi, %eax\n"
- "fistpll (%esi)\n"
- "fistpll 8(%esi)\n"
- #ifdef TARGET_X64
- "movll 8(%rsi), %rdi\n"
- "andll %rdi, (%rsi)\n"
- #else
- "movl 8(%esi), %edi\n"
- "movl 12(%esi), %ecx\n"
- "andl %edi, (%esi)\n"
- "andl %ecx, 4(%esi)\n"
- #endif
- "fildll (%esi)\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_and_end(void) {}
- void nseel_asm_and_op(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fistpll (%edi)\n"
- "fistpll (%esi)\n"
- #ifdef TARGET_X64
- "movll (%rsi), %rax\n"
- "andll %rax, (%rdi)\n"
- #else
- "movl (%esi), %eax\n"
- "movl 4(%esi), %ecx\n"
- "andl %eax, (%edi)\n"
- "andl %ecx, 4(%edi)\n"
- #endif
- "fildll (%edi)\n"
- "movl %edi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%edi)\n"
- );
- }
- void nseel_asm_and_op_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_uplus(void) // this is the same as doing nothing, it seems
- {
- __asm__(
- ""
- );
- }
- void nseel_asm_uplus_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_uminus(void)
- {
- __asm__(
- #if EEL_F_SIZE == 8
- "movl (%eax), %ecx\n"
- "movl 4(%eax), %edi\n"
- "movl %ecx, (%esi)\n"
- "xorl $0x80000000, %edi\n"
- "movl %esi, %eax\n"
- "movl %edi, 4(%esi)\n"
- "addl $8, %esi\n"
- #else
- "movl (%eax), %ecx\n"
- "xorl $0x80000000, %ecx\n"
- "movl %esi, %eax\n"
- "movl %ecx, (%esi)\n"
- "addl $4, %esi\n"
- #endif
- );
- }
- void nseel_asm_uminus_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_sign(void)
- {
- __asm__(
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rdi\n"
- "movll (%rax), %rcx\n"
- "movll $0x7FFFFFFFFFFFFFFF, %rdx\n"
- "testl %rdx, %rcx\n"
- "jz 1f\n"
- "shr $60, %rcx\n"
- "andl $8, %rcx\n"
- "addll %rdi, %rcx\n"
- "movl %rsi, %rax\n"
- "addl $8, %rsi\n"
- "movll (%rcx), %rdi\n"
- "movll %rdi, (%rax)\n"
- "1:\n"
-
- #else
- "movl $0xFFFFFFFF, %edi\n"
- #if EEL_F_SIZE == 8
- "movl 4(%eax), %ecx\n"
- "movl (%eax), %edx\n"
- "testl $0xFFFFFFFF, %edx\n"
- "jnz 0f\n"
- #else
- "movl (%eax), %ecx\n"
- #endif
- // high dword (minus sign bit) is zero
- "test $0x7FFFFFFF, %ecx\n"
- "jz 1f\n" // zero zero, return the value passed directly
- "0:\n"
- #if EEL_F_SIZE == 8
- "shrl $28, %ecx\n"
- #else
- "shrl $29, %ecx\n"
- #endif
- "andl $" EEL_F_SSTR ", %ecx\n"
- "addl %edi, %ecx\n"
- "movl %esi, %eax\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- "movl (%ecx), %edi\n"
- #if EEL_F_SIZE == 8
- "movl 4(%ecx), %edx\n"
- #endif
- "movl %edi, (%eax)\n"
- #if EEL_F_SIZE == 8
- "movl %edx, 4(%eax)\n"
- #endif
- "1:\n"
-
- #endif
- );
- }
- void nseel_asm_sign_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_bnot(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "test $256, %eax\n"
- "movl %esi, %eax\n"
- "jz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_bnot_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_if(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- "movll $0xFFFFFFFF, %rax\n"
- "movll %rax, (%esi)\n" // conversion script will extend these out to full len
- "movll $0xFFFFFFFF, %rax\n"
- "movll %rax, 8(%esi)\n"
- "fstsw %ax\n"
- "shrl $5, %rax\n"
- "andl $8, %rax\n"
- "movll (%rax, %rsi), %rax\n"
- "subl $8, %rsp\n"
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- "movl $0xFFFFFFFF, (%esi)\n"
- "movl $0xFFFFFFFF, 4(%esi)\n"
- "fstsw %ax\n"
- "shrl $6, %eax\n"
- "andl $4, %eax\n"
- "movl (%eax, %esi), %eax\n"
- #endif
- "call *%eax\n"
- #ifdef TARGET_X64
- "addl $8, %rsp\n"
- #endif
- );
- }
- void nseel_asm_if_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_repeat(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fistpl (%esi)\n"
- #ifdef TARGET_X64 // safe not sure if movl ecx will zero the high word
- "xorl %ecx, %ecx\n"
- #endif
- "movl (%esi), %ecx\n"
- "cmpl $1, %ecx\n"
- "jl 1f\n"
- "cmpl $" NSEEL_LOOPFUNC_SUPPORT_MAXLEN_STR ", %ecx\n"
- "jl 0f\n"
- "movl $" NSEEL_LOOPFUNC_SUPPORT_MAXLEN_STR ", %ecx\n"
- "0:\n"
- "movl $0xFFFFFFFF, %edx\n"
- "subl $8, %esp\n" /* keep stack aligned -- note this is required on x64 too!*/
- "pushl %esi\n" // revert back to last temp workspace
- "pushl %ecx\n"
- "call *%edx\n"
- "popl %ecx\n"
- "popl %esi\n"
- "addl $8, %esp\n" /* keep stack aligned -- also required on x64*/
- "decl %ecx\n"
- "jnz 0b\n"
- "1:\n"
- );
- }
- void nseel_asm_repeat_end(void) {}
- void nseel_asm_repeatwhile(void)
- {
- __asm__(
- "movl $" NSEEL_LOOPFUNC_SUPPORT_MAXLEN_STR ", %ecx\n"
- "0:\n"
- "movl $0xFFFFFFFF, %edx\n"
- "subl $8, %esp\n" /* keep stack aligned -- required on x86 and x64*/
- "pushl %esi\n" // revert back to last temp workspace
- "pushl %ecx\n"
- "call *%edx\n"
- "popl %ecx\n"
- "popl %esi\n"
- "addl $8, %esp\n" /* keep stack aligned -- required on x86 and x64 */
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "jnz 0f\n"
- "decl %ecx\n"
- "jnz 0b\n"
- "0:\n"
- "movl %esi, %eax\n"
- );
- }
- void nseel_asm_repeatwhile_end(void) {}
- void nseel_asm_band(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "jnz 0f\n" // if Z, then we are nonzero
- "movl $0xFFFFFFFF, %ecx\n"
- #ifdef TARGET_X64
- "subl $8, %rsp\n"
- #endif
- "call *%ecx\n"
- #ifdef TARGET_X64
- "addl $8, %rsp\n"
- #endif
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "jnz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_band_end(void) {}
- void nseel_asm_bor(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "jz 0f\n" // if Z, then we are nonzero
- "movl $0xFFFFFFFF, %ecx\n"
- #ifdef TARGET_X64
- "subl $8, %rsp\n"
- #endif
- "call *%ecx\n"
- #ifdef TARGET_X64
- "addl $8, %rsp\n"
- #endif
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "jz 0f\n"
- "fldz\n"
- "jmp 1f\n"
- "0:\n"
- "fld1\n"
- "1:\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_bor_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_equal(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fsub" EEL_F_SUFFIX " (%edi)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "movl %esi, %eax\n"
- "jz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_equal_end(void) {}
- //
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_notequal(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fsub" EEL_F_SUFFIX " (%edi)\n"
- "fabs\n"
- #ifdef TARGET_X64
- "movl $0xFFFFFFFF, %rax\n"
- "fcomp" EEL_F_SUFFIX " (%rax)\n" //[g_closefact]
- #else
- "fcomp" EEL_F_SUFFIX " (0xFFFFFFFF)\n" //[g_closefact]
- #endif
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "movl %esi, %eax\n"
- "jnz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_notequal_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_below(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fcomp" EEL_F_SUFFIX " (%eax)\n"
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "movl %esi, %eax\n"
- "jz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_below_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_beloweq(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fcomp" EEL_F_SUFFIX " (%edi)\n"
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "movl %esi, %eax\n"
- "jnz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_beloweq_end(void) {}
- //---------------------------------------------------------------------------------------------------------------
- void nseel_asm_above(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fcomp" EEL_F_SUFFIX " (%edi)\n"
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "movl %esi, %eax\n"
- "jz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_above_end(void) {}
- void nseel_asm_aboveeq(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fcomp" EEL_F_SUFFIX " (%eax)\n"
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "movl %esi, %eax\n"
- "jnz 0f\n"
- "fld1\n"
- "jmp 1f\n"
- "0:\n"
- "fldz\n"
- "1:\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- );
- }
- void nseel_asm_aboveeq_end(void) {}
- void nseel_asm_min(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fcomp" EEL_F_SUFFIX " (%eax)\n"
- "pushl %eax\n"
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "popl %eax\n"
- "jz 0f\n"
- "movl %edi, %eax\n"
- "0:\n"
- );
- }
- void nseel_asm_min_end(void) {}
- void nseel_asm_max(void)
- {
- __asm__(
- "fld" EEL_F_SUFFIX " (%edi)\n"
- "fcomp" EEL_F_SUFFIX " (%eax)\n"
- "pushl %eax\n"
- "fstsw %ax\n"
- "testl $256, %eax\n"
- "popl %eax\n"
- "jnz 0f\n"
- "movl %edi, %eax\n"
- "0:\n"
- );
- }
- void nseel_asm_max_end(void) {}
- // just generic functions left, yay
- void _asm_generic3parm(void)
- {
- __asm__(
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl %rdi, %rdx\n" // third parameter = parm
- "movl $0xFFFFFFFF, %rdi\n" // first parameter= context
- "movl %ecx, %rsi\n" // second parameter = parm
- "movl %rax, %rcx\n" // fourth parameter = parm
- "movl $0xffffffff, %rax\n" // call function
- "subl $128, %rsp\n"
- "call *%rax\n"
- "movl %r15, %rsi\n"
- "addl $128, %rsp\n"
- #else
- "movl %ecx, %edx\n" // second parameter = parm
- "movl $0xFFFFFFFF, %ecx\n" // first parameter= context
- "movl %rdi, %r8\n" // third parameter = parm
- "movl %rax, %r9\n" // fourth parameter = parm
- "movl $0xffffffff, %edi\n" // call function
- "subl $128, %rsp\n"
- "call *%edi\n"
- "addl $128, %rsp\n"
- #endif
- #else
- SAVE_STACK
- "movl $0xFFFFFFFF, %edx\n"
- "pushl %eax\n" // push parameter
- "pushl %edi\n" // push parameter
- "pushl %ecx\n" // push parameter
- "pushl %edx\n" // push context pointer
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "addl $16, %esp\n"
- RESTORE_STACK
- #endif
- );
- }
- void _asm_generic3parm_end(void) {}
- void _asm_generic3parm_retd(void)
- {
- __asm__(
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl %rdi, %rdx\n" // third parameter = parm
- "movl $0xFFFFFFFF, %rdi\n" // first parameter= context
- "movl %ecx, %rsi\n" // second parameter = parm
- "movl %rax, %rcx\n" // fourth parameter = parm
- "movl $0xffffffff, %rax\n" // call function
- "subl $128, %rsp\n"
- "call *%rax\n"
- "addl $128, %rsp\n"
- "movl %r15, %rsi\n"
- "movl %r15, %rax\n"
- "movq xmm0, (%r15)\n"
- "addl $8, %rsi\n"
- #else
- "movl %ecx, %edx\n" // second parameter = parm
- "movl $0xFFFFFFFF, %ecx\n" // first parameter= context
- "movl %rdi, %r8\n" // third parameter = parm
- "movl %rax, %r9\n" // fourth parameter = parm
- "movl $0xffffffff, %edi\n" // call function
- "subl $128, %rsp\n"
- "call *%edi\n"
- "addl $128, %rsp\n"
- "movq xmm0, (%rsi)\n"
- "movl %rsi, %rax\n"
- "addl $8, %rsi\n"
- #endif
- #else
- SAVE_STACK
- "movl $0xFFFFFFFF, %edx\n"
- "pushl %eax\n" // push parameter
- "pushl %edi\n" // push parameter
- "pushl %ecx\n" // push parameter
- "pushl %edx\n" // push context pointer
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- "addl $16, %esp\n"
- RESTORE_STACK
- #endif
- );
- }
- void _asm_generic3parm_retd_end(void) {}
- void _asm_generic2parm(void) // this prob neds to be fixed for ppc
- {
- __asm__(
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl %edi, %esi\n" // second parameter = parm
- "movl $0xFFFFFFFF, %edi\n" // first parameter= context
- "movl %rax, %rdx\n" // third parameter = parm
- "movl $0xffffffff, %rcx\n" // call function
- "subl $128, %rsp\n"
- "call *%rcx\n"
- "movl %r15, %rsi\n"
- "addl $128, %rsp\n"
- #else
- "movl $0xFFFFFFFF, %ecx\n" // first parameter= context
- "movl %edi, %edx\n" // second parameter = parm
- "movl %rax, %r8\n" // third parameter = parm
- "movl $0xffffffff, %edi\n" // call function
- "subl $128, %rsp\n"
- "call *%edi\n"
- "addl $128, %rsp\n"
- #endif
- #else
- SAVE_STACK
- "movl $0xFFFFFFFF, %edx\n"
- "subl $4, %esp\n" // keep stack aligned
- "pushl %eax\n" // push parameter
- "pushl %edi\n" // push parameter
- "pushl %edx\n" // push context pointer
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "addl $16, %esp\n"
- RESTORE_STACK
- #endif
- );
- }
- void _asm_generic2parm_end(void) {}
- void _asm_generic2parm_retd(void)
- {
- __asm__(
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl %rdi, %rsi\n" // second parameter = parm
- "movl $0xFFFFFFFF, %rdi\n" // first parameter= context
- "movl %rax, %rdx\n" // third parameter = parm
- "movl $0xffffffff, %rcx\n" // call function
- "subl $128, %rsp\n"
- "call *%rcx\n"
- "movl %r15, %rsi\n"
- "addl $128, %rsp\n"
- "movq xmm0, (%r15)\n"
- "movl %r15, %rax\n"
- "addl $8, %rsi\n"
- #else
- "movl $0xFFFFFFFF, %ecx\n" // first parameter= context
- "movl %edi, %edx\n" // second parameter = parm
- "movl %rax, %r8\n" // third parameter = parm
- "movl $0xffffffff, %edi\n" // call function
- "subl $128, %rsp\n"
- "call *%edi\n"
- "addl $128, %rsp\n"
- "movq xmm0, (%rsi)\n"
- "movl %rsi, %rax\n"
- "addl $8, %rsi\n"
- #endif
- #else
- SAVE_STACK
- "movl $0xFFFFFFFF, %edx\n"
- "pushl %eax\n" // push parameter
- "pushl %edi\n" // push parameter
- "pushl %ecx\n" // push parameter
- "pushl %edx\n" // push context pointer
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- "addl $16, %esp\n"
- RESTORE_STACK
- #endif
- );
- }
- void _asm_generic2parm_retd_end(void) {}
- void _asm_generic1parm(void) // this prob neds to be fixed for ppc
- {
- __asm__(
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl $0xFFFFFFFF, %rdi\n" // first parameter= context
- "movl %rsi, %r15\n"
- "movl %eax, %rsi\n" // second parameter = parm
- "subl $128, %rsp\n"
- "movl $0xffffffff, %rcx\n" // call function
- "call *%rcx\n"
- "movl %r15, %rsi\n"
- "addl $128, %rsp\n"
- #else
- "movl $0xFFFFFFFF, %ecx\n" // first parameter= context
- "movl %eax, %edx\n" // second parameter = parm
- "movl $0xffffffff, %edi\n" // call function
- "subl $128, %rsp\n"
- "call *%edi\n"
- "addl $128, %rsp\n"
- #endif
- #else
- SAVE_STACK
- "movl $0xFFFFFFFF, %edx\n"
- "subl $8, %esp\n" // keep stack aligned
- "pushl %eax\n" // push parameter
- "pushl %edx\n" // push context pointer
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "addl $16, %esp\n"
- RESTORE_STACK
- #endif
- );
- }
- void _asm_generic1parm_end(void) {}
- void _asm_generic1parm_retd(void) // 1 parameter returning double
- {
- __asm__(
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl $0xFFFFFFFF, %rdi\n" // first parameter= context
- "movl %rax, %rsi\n" // second parameter = parm
- "movl $0xffffffff, %rcx\n" // call function
- "subl $128, %rsp\n"
- "call *%rcx\n"
- "movl %r15, %rsi\n"
- "addl $128, %rsp\n"
- "movq xmm0, (%r15)\n"
- "movl %r15, %rax\n"
- "addl $8, %rsi\n"
- #else
- "movl $0xFFFFFFFF, %ecx\n" // first parameter= context
- "movl %eax, %edx\n" // second parameter = parm
- "movl $0xffffffff, %edi\n" // call function
- "subl $128, %rsp\n"
- "call *%edi\n"
- "addl $128, %rsp\n"
- "movq xmm0, (%rsi)\n"
- "movl %rsi, %rax\n"
- "addl $8, %rsi\n"
- #endif
- #else
- SAVE_STACK
- "movl $0xFFFFFFFF, %edx\n"
- "subl $8, %esp\n" // keep stack aligned
- "pushl %eax\n" // push parameter
- "pushl %edx\n" // push context pointer
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "movl %esi, %eax\n"
- "fstp" EEL_F_SUFFIX " (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- "addl $16, %esp\n"
- RESTORE_STACK
- #endif
- );
- }
- void _asm_generic1parm_retd_end(void) {}
- // this gets its own stub because it's pretty crucial for performance :/
- void _asm_megabuf(void)
- {
- __asm__(
- SAVE_STACK
- #ifdef TARGET_X64
- #ifdef AMD64ABI
- "movl %rsi, %r15\n"
- "movl $0xFFFFFFFF, %rdi\n" // first parameter = context pointer
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "movl $0xFFFFFFFF, %rdx\n"
- "fadd" EEL_F_SUFFIX " (%rdx)\n"
- "fistpl (%r15)\n"
- "xorl %rsi, %rsi\n"
- "movl (%r15), %esi\n" // r15 = esi (from above)
- "movl $0xffffffff, %edx\n"
- "subl $128, %rsp\n"
- "call *%edx\n"
- "movl %r15, %rsi\n"
- "addl $128, %rsp\n"
- "and %rax, %rax\n"
- "jnz 0f\n"
- "movl %r15, %rax\n"
- "movll $0, (%esi)\n"
- "addl $" EEL_F_SSTR ", %rsi\n"
- "0:"
- #else
- "movl $0xFFFFFFFF, %ecx\n" // first parameter = context pointer
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "movl $0xFFFFFFFF, %edx\n"
- "fadd" EEL_F_SUFFIX " (%rdx)\n"
- "fistpl (%esi)\n"
- "xorl %rdx, %rdx\n"
- "movl (%esi), %edx\n"
- "movl $0xffffffff, %edi\n"
- "subl $128, %rsp\n"
- "call *%edi\n"
- "addl $128, %rsp\n"
- "and %rax, %rax\n"
- "jnz 0f\n"
- "movl %rsi, %rax\n"
- "movll $0, (%esi)\n"
- "addl $" EEL_F_SSTR ", %esi\n"
- "0:"
- #endif
- #else
- "movl $0xFFFFFFFF, %edx\n"
- "fld" EEL_F_SUFFIX " (%eax)\n"
- "fadd" EEL_F_SUFFIX " (0xFFFFFFFF)\n"
- "fistpl (%esi)\n"
- "subl $8, %esp\n" // keep stack aligned
- "pushl (%esi)\n" // parameter
- "pushl %edx\n" // push context pointer
- "movl $0xffffffff, %edi\n"
- "call *%edi\n"
- "addl $16, %esp\n"
- "and %eax, %eax\n"
- "jnz 0f\n"
- "movl %esi, %eax\n"
- "movl $0, (%esi)\n"
- #if EEL_F_SIZE == 8
- "movl $0, 4(%esi)\n"
- #endif
- "addl $" EEL_F_SSTR ", %esi\n"
- "0:"
- #endif
- RESTORE_STACK
- );
- }
- void _asm_megabuf_end(void) {}
- #ifdef TARGET_X64
- void win64_callcode()
- {
- __asm__(
- #ifdef AMD64ABI
- "movll %edi, %eax\n"
- #else
- "movll %ecx, %eax\n"
- #endif
- "push %rbx\n"
- "push %rbp\n"
- #ifndef AMD64ABI
- "push %rdi\n"
- "push %rsi\n"
- "push %r12\n"
- "push %r13\n"
- #endif
- "push %r14\n" // on AMD64ABI, we'll use r14/r15 to save edi/esi
- "push %r15\n"
- "call %eax\n"
- "pop %r15\n"
- "pop %r14\n"
- #ifndef AMD64ABI
- "pop %r13\n"
- "pop %r12\n"
- "pop %rsi\n"
- "pop %rdi\n"
- "fclex\n"
- #endif
- "pop %rbp\n"
- "pop %rbx\n"
- "ret\n"
- );
- }
- #endif
|