diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6554e1f4e8..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,26 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 - -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/2.0/configuration-reference/#jobs -jobs: - say-hello: - # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor - docker: - - image: cimg/base:stable - # Add steps to the job - # See: https://circleci.com/docs/2.0/configuration-reference/#steps - steps: - - checkout - - run: - name: "Say hello" - command: "echo Hello, World!" - -# Invoke jobs via workflows -# See: https://circleci.com/docs/2.0/configuration-reference/#workflows -workflows: - say-hello-workflow: - jobs: - - say-hello diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 2acdd4e6c4..e7f354031f 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -20,6 +20,8 @@ env: # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix BUILD_CONFIGURATION: Release + BUILD_TAG: 6.0.9 + permissions: contents: read @@ -38,8 +40,28 @@ jobs: - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v1.0.2 + - name: Setup Nuget + uses: Nuget/setup-nuget@v1.0.5 + + - name: Restore nuget packages + run: nuget restore ${{env.SOLUTION_FILE_PATH}} + - name: Build working-directory: ${{env.GITHUB_WORKSPACE}} # Add additional options to the MSBuild command line here (like platform or verbosity level). # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} /p:platform=${{ matrix.platform }} /m:2 + + - name: Compile Lib + shell: cmd + run: build\rebuild_lib60_${{matrix.platform}}.bat + + - name: Prepare Artifact + shell: cmd + run: build\create_package_${{matrix.platform}}.bat + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: elena-lang-${{matrix.platform}}-${{ env.BUILD_TAG }} + path: build\${{matrix.platform}} diff --git a/CHANGELOG.md b/CHANGELOG.md index 843bc1f6a0..cdbebb0c05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,46 @@ +## ELENA 6.0.9 +*19.04.2024* + +- ELENA + - [ADDED] new opcode - parent + - [ADDED] meta expression: nested singletons + - [ADDED] new class flag - elPacked + - [ADDED] new attribute - packed + +- ELC + - [ADDED] #637 - unit tests for byRefOp optimization + - [ADDED] #637 - unit tests for intCopying optimization + - [ADDED] #610 - struct redesign + - [FIXED] optimization : copy 8 / copydpn 8 + - [FIXED] #615 : The field is not property incremented by an addition assignment + - [FIXED] x64 : fround opcode + - [FIXED] x64 : fabs opcode + - [FIXED] x86 : xdispatchmr opcode + +- API + - [ADDED] system'dynamic'expressions'LazySymbolExpression + - [FIXED] ushort - native comparison operations + - [ADDED] system'net + - [ADDED] ltests + - [ADDED] net + - [ADDED] win64 gui + - [FIXED] realOp.RoundedInt extension + +- SAMPLES + - [FIXED] interpreter sample for x86-64 + +- Tools + - [FIXED] #618 : template class descriptions + +- IDE + - [ADDED] include / exclude file + - [FIXED] ctrl+w hides the frame + - [ADDED] ins / over modes + - [ADDED] dark color scheme + +- Misc + - [ADDED] GitHub Action - MSBuild nightly build + ## ELENA 6.0.8 *21.03.2024* diff --git a/README.md b/README.md index 5a81ba7416..0c0780f7bb 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@
-[![Build status](https://ci.appveyor.com/api/projects/status/qc5dvs5lueubivuo?svg=true)](https://ci.appveyor.com/project/arakov/elena-lang) +[![MSBuild](https://github.com/ELENA-LANG/elena-lang/actions/workflows/msbuild.yml/badge.svg?branch=master)](https://github.com/ELENA-LANG/elena-lang/actions/workflows/msbuild.yml) [![Sponsor](https://img.shields.io/badge/patreon-donate-green.svg)](https://www.patreon.com/elena_lang) [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/arakov)](https://github.com/sponsors/arakov) diff --git a/VERSION b/VERSION index a0c2cf5cd7..fb06ed73fa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.0.8 \ No newline at end of file +6.0.9 \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5f2f8996b6..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: 6.0.7.{build} -branches: - only: - - master - - /^v\d+\.\d+\.\d+$/ -image: Visual Studio 2022 -configuration: Release -platform: -- x86 -- x64 - -after_build: - - cmd: call install\build_package_%PLATFORM%.bat elena-lang.%APPVEYOR_BUILD_VERSION%-%PLATFORM% - -build: - verbosity: minimal - project: elenasrc3\elenasrc3.sln - -artifacts: - # archive the generated packages in the ci.appveyor.com build report - - path: install\output%PLATFORM%\*.zip - name: nightly-build - -deploy: - appveyor_repo_tag: true - tag: $(APPVEYOR_REPO_TAG_NAME) - release: $(APPVEYOR_REPO_TAG_NAME) - description: 'ELENA Nightly Build' - provider: GitHub - auth_token: - secure: znFqEeEkeb1s0OK4PAPT4KrYnCJowIxxWzRq3apGne3bSH1XFsz9U+E1JAgpCwwF - artifact: nightly-build - draft: false - prerelease: true - on: - appveyor_repo_tag: true diff --git a/asm/aarch64/core60.asm b/asm/aarch64/core60.asm index 9c24094687..d86e77a39b 100644 --- a/asm/aarch64/core60.asm +++ b/asm/aarch64/core60.asm @@ -869,6 +869,14 @@ inline %02Ch end +// ; parent +inline %02Dh + + sub x14, x10, elPackageOffset + ldr x10, [x14] //; edi + +end + // ; xget inline %02Eh @@ -3472,16 +3480,53 @@ labEnd: end -// ; openin 0, 0 +// ; openin 0, n inline %1F0h + stp x29, x30, [sp, #-16]! + mov x29, sp + + sub sp, sp, __n12_2 // ; allocate raw stack + + mov x11, #0 + stp x11, x29, [sp, #-16]! + + mov x29, sp // ; set frame pointer + +end + +// ; openin i, 0 +inline %6F0h + + stp x29, x30, [sp, #-16]! + mov x29, sp + + sub sp, sp, __arg12_1 // ; allocate stack + mov x11, __arg16_1 + mov x12, #0 + mov x13, sp + +labLoop: + cmp x11, #0 + beq labEnd + sub x11, x11, #8 + str x12, [x13], #8 + b labLoop + +labEnd: + +end + +// ; openin 0, 0 +inline %7F0h + stp x29, x30, [sp, #-16]! mov x29, sp // ; set frame pointer end // ; openin 1, 0 -inline %2F0h +inline %8F0h mov x11, 0 stp x29, x30, [sp, #-16]! @@ -3491,7 +3536,7 @@ inline %2F0h end // ; openin 2, 0 -inline %3F0h +inline %9F0h mov x11, 0 stp x29, x30, [sp, #-16]! @@ -3501,7 +3546,7 @@ inline %3F0h end // ; openin 3, 0 -inline %4F0h +inline %0AF0h mov x11, 0 stp x29, x30, [sp, #-16]! @@ -3511,40 +3556,14 @@ inline %4F0h end -// ; openin 0, n -inline %5F0h +// ; openin 4, 0 +inline %0BF0h + mov x11, 0 stp x29, x30, [sp, #-16]! - mov x29, sp - - sub sp, sp, __n12_2 // ; allocate raw stack - - mov x11, #0 - stp x11, x29, [sp, #-16]! - mov x29, sp // ; set frame pointer - -end - -// ; openin i, 0 -inline %6F0h - - stp x29, x30, [sp, #-16]! - mov x29, sp - - sub sp, sp, __arg12_1 // ; allocate stack - mov x11, __arg16_1 - mov x12, #0 - mov x13, sp - -labLoop: - cmp x11, #0 - beq labEnd - sub x11, x11, #8 - str x12, [x13], #8 - b labLoop - -labEnd: + stp x11, x11, [sp, #-16]! + stp x11, x11, [sp, #-16]! end @@ -3652,16 +3671,53 @@ labEnd: end -// ; extopenin 0, 0 +// ; extopenin 0, n inline %1F2h + stp x29, x30, [sp, #-16]! + mov x29, sp + + sub sp, sp, __n12_2 // ; allocate raw stack + + mov x11, #0 + stp x11, x29, [sp, #-16]! + + mov x29, sp // ; set frame pointer + +end + +// ; extopenin i, 0 +inline %6F2h + + stp x29, x30, [sp, #-16]! + mov x29, sp + + sub sp, sp, __arg12_1 // ; allocate stack + mov x11, __arg16_1 + mov x12, #0 + mov x13, sp + +labLoop: + cmp x11, #0 + beq labEnd + sub x11, x11, #8 + str x12, [x13], #8 + b labLoop + +labEnd: + +end + +// ; extopenin 0, 0 +inline %7F2h + stp x29, x30, [sp, #-16]! mov x29, sp // ; set frame pointer end // ; extopenin 1, 0 -inline %2F2h +inline %8F2h mov x11, #0 stp x29, x30, [sp, #-16]! @@ -3671,7 +3727,7 @@ inline %2F2h end // ; extopenin 2, 0 -inline %3F2h +inline %9F2h mov x11, #0 stp x29, x30, [sp, #-16]! @@ -3681,7 +3737,7 @@ inline %3F2h end // ; extopenin 3, 0 -inline %4F2h +inline %0AF2h mov x11, #0 stp x29, x30, [sp, #-16]! @@ -3691,40 +3747,14 @@ inline %4F2h end -// ; extopenin 0, n -inline %5F2h - - stp x29, x30, [sp, #-16]! - mov x29, sp - - sub sp, sp, __n12_2 // ; allocate raw stack - - mov x11, #0 - stp x11, x29, [sp, #-16]! - - mov x29, sp // ; set frame pointer - -end - -// ; extopenin i, 0 -inline %6F2h - - stp x29, x30, [sp, #-16]! - mov x29, sp - - sub sp, sp, __arg12_1 // ; allocate stack - mov x11, __arg16_1 - mov x12, #0 - mov x13, sp +// ; extopenin 4, 0 +inline %0BF2h -labLoop: - cmp x11, #0 - beq labEnd - sub x11, x11, #8 - str x12, [x13], #8 - b labLoop - -labEnd: + mov x11, #0 + stp x29, x30, [sp, #-16]! + mov x29, sp // ; set frame pointer + stp x11, x11, [sp, #-16]! + stp x11, x11, [sp, #-16]! end @@ -3951,6 +3981,78 @@ labEnd: end +// ; fill i,0 +inline %3F8h + + mov x11, __arg12_1 + mov x12, 0 + mov x13, x10 + +labLoop: + cmp x11, 0 + beq labEnd + sub x11, x11, 1 + str x12, [x13], #8 + b labLoop + +labEnd: + +end + +// ; fill i,0 +inline %5F8h + + mov x11, __arg12_1 + mov x12, 0 + mov x13, x10 + +labLoop: + cmp x11, 0 + beq labEnd + sub x11, x11, 1 + str x12, [x13], #8 + b labLoop + +labEnd: + +end + +// ; fill i,0 +inline %7F8h + + mov x11, __arg12_1 + mov x12, 0 + mov x13, x10 + +labLoop: + cmp x11, 0 + beq labEnd + sub x11, x11, 1 + str x12, [x13], #8 + b labLoop + +labEnd: + +end + +// ; fill i,0 +inline %9F8h + + mov x11, __arg12_1 + mov x12, 0 + mov x13, x10 + +labLoop: + cmp x11, 0 + beq labEnd + sub x11, x11, 1 + str x12, [x13], #8 + b labLoop + +labEnd: + +end + // ; xstorefir inline %0F9h diff --git a/asm/amd64/core.asm b/asm/amd64/core.asm deleted file mode 100644 index 8134d3aa3e..0000000000 --- a/asm/amd64/core.asm +++ /dev/null @@ -1,3237 +0,0 @@ - -// !! NOTE : R15 register must be preserved - -// --- Predefined References -- -define GC_ALLOC 10001h -define HOOK 10010h -define INVOKER 10011h -define INIT_RND 10012h -define CALC_SIZE 1001Fh -define GET_COUNT 10020h -define THREAD_WAIT 10021h -define GC_ALLOCPERM 10031h - -define CORE_GC_TABLE 20002h -define CORE_STATICROOT 20005h -define CORE_TLS_INDEX 20007h -define THREAD_TABLE 20008h -define CORE_MESSAGE_TABLE 2000Ah -define CORE_ET_TABLE 2000Bh -define SYSTEM_ENV 2000Ch -define VOID 2000Dh -define VOIDPTR 2000Eh - -// Object header fields -define elSizeOffset 0004h -define elVMTOffset 0010h -define elObjectOffset 0010h - -// VMT header fields -define elVMTSizeOffset 0008h -define elVMTFlagOffset 0018h -define elPackageOffset 0020h - -define gc_header 0000h -define gc_start 0008h -define gc_end 0048h - -define gc_yg_current 0018h -define gc_yg_end 0020h -define gc_mg_start 0038h -define gc_mg_current 0040h -define gc_mg_wbar 0050h -define gc_et_current 0058h -define gc_stack_frame 0060h -define gc_rootcount 0088h -define gc_perm_start 0090h -define gc_perm_end 0098h -define gc_perm_current 00A0h - -define page_size 20h -define page_ceil 2Fh -define page_size_order 5h -define page_mask 0FFFFFFE0h -define struct_mask_inv 3FFFFFFFh -define stuct_mask 40000000h - -define ACTION_ORDER 9 -define ARG_ACTION_MASK 1DFh -define ACTION_MASK 1E0h -define ARG_MASK 01Fh - -// --- System Core Preloaded Routines -- - -structure % CORE_ET_TABLE - - dq 0 // ; critical_exception ; +x00 - pointer to critical exception handler - -end - -structure %CORE_GC_TABLE - - dq 0 // ; gc_header : +00h - dq 0 // ; gc_start : +08h - dq 0 // ; gc_yg_start : +10h - dq 0 // ; gc_yg_current : +18h - dq 0 // ; gc_yg_end : +20h - dq 0 // ; gc_shadow : +28h - dq 0 // ; gc_shadow_end : +30h - dq 0 // ; gc_mg_start : +38h - dq 0 // ; gc_mg_current : +40h - dq 0 // ; gc_end : +48h - dq 0 // ; gc_mg_wbar : +50h - dq 0 // ; gc_et_current : +58h - dq 0 // ; gc_stack_frame : +60h - dd 0 // ; gc_lock : +68h - dd 0 // ; gc_signal : +6Ch - dd 0 // ; tt_ptr : +70h - dd 0 // ; tt_lock : +74h - dq 0 // ; dbg_ptr : +78h - dq 0 // ; gc_roots : +80h - dq 0 // ; gc_rootcount : +88h - dq 0 // ; gc_perm_start : +90h - dq 0 // ; gc_perm_end : +98h - dq 0 // ; gc_perm_current : +A0h - -end - -// ; NOTE : the table is tailed with GCMGSize,GCYGSize,GCPERMSize and MaxThread fields -rstructure %SYSTEM_ENV - - dd 0 - dq data : %CORE_STATICROOT - dq data : %CORE_GC_TABLE - dq data : %CORE_TLS_INDEX - dq data : %THREAD_TABLE - dq code : %INVOKER - -end - -rstructure %VOID - - dq 0 - dq 0 // ; a reference to the super class class - dq 0 - dq 0 - dq 0 - -end - -rstructure %VOIDPTR - - dq rdata : %VOID + elPackageOffset - dq 0 - dq 0 - -end - -// --- GC_ALLOC --- -// in: ecx - size ; out: ebx - created object -procedure %GC_ALLOC - - mov rax, [data : %CORE_GC_TABLE + gc_yg_current] - mov rdx, [data : %CORE_GC_TABLE + gc_yg_end] - add rcx, rax - cmp rcx, rdx - jae short labYGCollect - mov [data : %CORE_GC_TABLE + gc_yg_current], rcx - lea rbx, [rax + elObjectOffset] - ret - -labYGCollect: - // ; restore ecx - sub rcx, rax - - // ; save registers - push rbp - - // ; lock frame - mov [data : %CORE_GC_TABLE + gc_stack_frame], rsp - - push rcx - - // ; create set of roots - mov rbp, rsp - xor ecx, ecx - push rcx // ; reserve place - push rcx - push rcx - - // ; save static roots - mov rsi, data : %CORE_STATICROOT - mov rcx, [data : %CORE_GC_TABLE + gc_rootcount] - push rsi - push rcx - - // ; collect frames - mov rax, [data : %CORE_GC_TABLE + gc_stack_frame] - mov rcx, rax - -labYGNextFrame: - mov rsi, rax - mov rax, [rsi] - test rax, rax - jnz short labYGNextFrame - - push rcx - sub rcx, rsi - neg rcx - push rcx - - mov rax, [rsi + 8] - test rax, rax - mov rcx, rax - jnz short labYGNextFrame - - mov [rbp-8], rsp // ; save position for roots - - mov rdx, [rbp] - mov rcx, rsp - - // ; restore rbp - mov rax, rbp - mov rbp, [rax+8] - - push rax - sub rsp, 20h - call extern 'rt_dlls.GCCollect - add rsp, 20h - - mov rbx, rax - pop rbp - - mov rsp, rbp - pop rcx - pop rbp - - ret - -end - -// --- GC_ALLOCPERM --- -// in: ecx - size ; out: ebx - created object -procedure %GC_ALLOCPERM - - mov rax, [data : %CORE_GC_TABLE + gc_perm_current] - mov rdx, [data : %CORE_GC_TABLE + gc_perm_end] - add rcx, rax - cmp rcx, rdx - jae short labPERMCollect - mov [data : %CORE_GC_TABLE + gc_perm_current], rcx - lea rbx, [rax + elObjectOffset] - ret - -labPERMCollect: - // ; restore ecx - sub rcx, rax - - // ; lock frame - mov [data : %CORE_GC_TABLE + gc_stack_frame], rsp - - push rcx - - sub rsp, 18h - call extern 'rt_dlls.GCCollectPerm - add rsp, 20h - - mov rbx, rax - - ret - -end - -// ; --- HOOK --- -// ; in: ecx - catch offset -procedure %HOOK - - mov rax, [rsp] - lea rcx, [rax + rcx - 5] - ret - -end - -// --- System Core Functions -- - -procedure % THREAD_WAIT - - ret - -end - -procedure % CALC_SIZE - - mov ecx, edx - add ecx, page_ceil - and ecx, page_mask - - ret - -end - -procedure % GET_COUNT - - mov edx, dword ptr [rbx - elSizeOffset] - test edx, stuct_mask - jnz short labErr - and edx, struct_mask_inv - shr edx, 3 - ret - -labErr: - xor edx, edx - ret - -end - -// ; ==== Command Set == - -// ; coalesce -inline % 2 - - mov rax, [rsp] - test rbx, rbx - cmovz rbx, rax - -end - -// ; peek -inline % 3 - - mov rax, [rsp] - mov rbx, [rax+rdx*8] - -end - -// ; snop -inline % 4 - - nop - -end - -// ; pushverb -inline % 5 - - mov rax, rdx - mov rcx, rdx - shr eax, ACTION_ORDER - mov rdi, rdata : % CORE_MESSAGE_TABLE - test rcx, rcx - cmovs rax, [rdi + rdx] - push rax - -end - -// ; loadverb -inline % 6 - - mov rcx, rdx - shr rdx, ACTION_ORDER - mov rax, rdata : % CORE_MESSAGE_TABLE - test rcx, rcx - cmovs rdx, [rax + rdx] - -end - -// ; throw -inline % 7 - - mov rax, [data : %CORE_GC_TABLE + gc_et_current] - jmp [rax] - -end - -// ; push -inline % 09h - - mov rax, [rbx + rdx * 8] - push rax - -end - -// ; xnew -inline % 0Ch - - mov rax, [rsp] - mov ecx, page_ceil - push rbx - mov rdx, [rax] - lea rcx, [rcx + rdx*8] - and ecx, page_mask - - call code : %GC_ALLOC - - pop rdi - xor edx, edx - mov rax, [rsp] - mov [rbx-elVMTOffset], rdi - mov rcx, [rax] - mov esi, stuct_mask - test ecx, ecx - cmovz rdx, rsi - shl ecx, 3 - or ecx, edx - mov dword ptr[rbx-elSizeOffset], ecx - -end - -// ; storev -inline % 0Dh - - mov eax, edx - and eax, ACTION_MASK - mov ecx, dword ptr [rsp] - and ecx, ARG_MASK - or ecx, edx - mov dword ptr [rsp], ecx - -end - -// ; bsredirect -inline % 0Eh // (rbx - object, rdx - message) - - mov rdi, [rbx - elVMTOffset] - xor ecx, ecx - mov esi, dword ptr[rdi - elVMTSizeOffset] - -labSplit: - test esi, esi - jz short labEnd - -labStart: - shr esi, 1 - lea rax, [rsi*2] - setnc cl - cmp rdx, [rdi+rax*8] - je short labFound - lea r8, [rdi+rax*8] - jb short labSplit - lea rdi, [r8+16] - sub esi, ecx - jmp labSplit - nop - nop -labFound: - jmp [rdi+rax*8+8] - -labEnd: - -end - -// ; setv -inline % 0Fh - - mov eax, dword ptr [rbx] - and eax, ARG_ACTION_MASK - mov ecx, edx - shl ecx, ACTION_ORDER - or eax, ecx - mov dword ptr [rbx], eax - -end - -// ; open -inline % 11h - - push rbp - mov rbp, rsp - -end - -// ; sub -inline % 13h - - sub edx, dword ptr [rbx] - -end - -// ; swapd -inline % 14h - - mov rax, [rsp] - mov [rsp], rdx - mov rdx, rax - -end - -// ; close -inline % 15h - - mov rsp, rbp - pop rbp - -end - -// ; rexp -inline % 16h - - mov rax, [rsp] - mov rdx, 0 - fld qword ptr [rax] // ; Src - - fldl2e // ; ->log2(e) - fmulp // ; ->log2(e)*Src - - // ; the FPU can compute the antilog only with the mantissa - // ; the characteristic of the logarithm must thus be removed - - fld st(0) // ; copy the logarithm - frndint // ; keep only the characteristic - fsub st(1),st(0) // ; keeps only the mantissa - fxch // ; get the mantissa on top - - f2xm1 // ; ->2^(mantissa)-1 - fld1 - faddp // ; add 1 back - - //; the number must now be readjusted for the characteristic of the logarithm - - fscale // ;, scale it with the characteristic - - fstsw ax // ; retrieve exception flags from FPU - shr al,1 // ; test for invalid operation - jc short lErr // ; clean-up and return if error - - // ; the characteristic is still on the FPU and must be removed - - fstp st(1) // ; get rid of the characteristic - - fstp qword ptr [rbx] // ; store result - mov rdx, 1 - jmp short labEnd - -lErr: - ffree st(1) - -labEnd: - -end - -// ; get -inline % 18h - - mov rbx, [rbx + rdx * 8] - -end - -// ; set -inline % 19h - - // ; calculate write-barrier address - mov rcx, rbx - mov rsi, [data : %CORE_GC_TABLE + gc_header] - sub rcx, [data : %CORE_GC_TABLE + gc_start] - mov rax, [rsp] - shr ecx, page_size_order - mov [rbx + rdx*8], rax - mov byte ptr [rcx + rsi], 1 - -end - -// ; swap -inline % 1Ah - - mov rax, [rsp] - mov [rsp], rbx - mov rbx, rax - -end - -// ; mquit -inline % 1Bh - - mov rcx, rdx - pop rsi - and ecx, ARG_MASK - lea rsp, [rsp + rcx * 8] - jmp rsi - -end - -// ; count -inline % 1Ch - - mov ecx, struct_mask_inv - mov rdx, [rbx-elSizeOffset] - and rdx, rcx - shr rdx, 3 - -end - -// ; unhook -inline % 1Dh - - mov rsi, [data : %CORE_GC_TABLE + gc_et_current] - mov rsp, [rsi + 8] - mov rbp, [rsi + 16] - pop rcx - mov [data : %CORE_GC_TABLE + gc_et_current], rcx - -end - -// ; rsin -inline % 1Eh - - mov rax, [rsp] - fld qword ptr [rax] - fldpi - fadd st(0),st(0) // ; ->2pi - fxch - -lReduce: - fprem // ; reduce the angle - fsin - fstsw ax // ; retrieve exception flags from FPU - shr al,1 // ; test for invalid operation - // ; jc short lErr // ; clean-up and return error - sahf // ; transfer to the CPU flags - jpe short lReduce // ; reduce angle again if necessary - fstp st(1) // ; get rid of the 2pi - - fstp qword ptr [rbx] // ; store result - -end - -// ; allocd -inline % 1Fh - - mov ecx, edx - add ecx, 1 - and ecx, 0FFFFFFFEh - mov rdi, rcx - shl rdi, 3 - sub rsp, rdi - xor rax, rax - mov rdi, rsp - rep stos - -end - -// ; rcos -inline % 20h - - mov rax, [rsp] - fld qword ptr [rax] - fcos - fstp qword ptr [rbx] // store result - -end - -// ; rarctan -inline % 21h - - mov rax, [rsp] - fld qword ptr [rax] - fld1 - fpatan // i.e. arctan(Src/1) - fstp qword ptr [rbx] // store result - -end - -// ; xtrans -inline % 24h - - mov rax, [rsp] - mov rcx, [rax+rdx*8] - mov [rbx+rdx*8], rcx - -end - -// ; include -inline % 25h - - add rsp, 16 - -end - -// ; exclude -inline % 26h - - push 0 - push rbp - mov [data : %CORE_GC_TABLE + gc_stack_frame], rsp - -end - -// ; trylock -inline % 27h - - xor edx, edx - -end - -// ; freelock -inline % 28h - - nop - -end - - -// ; freed -inline % 29h - - mov rdi, rdx - shl rdi, 3 - add rsp, rdi - -end - -// ; loadenv -inline % 2Ah - - mov rdx, rdata : %SYSTEM_ENV - -end - -// ; store -inline % 2Bh - - mov rax, [rsp] - mov [rax+rdx*8], rbx - -end - -// ; rln -inline % 2Ch - - mov rax, [rsp] - mov rdx, 0 - fld qword ptr [rax] - - fldln2 - fxch - fyl2x // ->[log2(Src)]*ln(2) = ln(Src) - - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc short lErr // clean-up and return error - - fstp qword ptr [rbx] // store result - mov rdx, 1 - jmp short labEnd - -lErr: - ffree st(0) - -labEnd: - -end - -// ; read -inline % 2Dh - - mov rdx, [rbx + rdx] - -end - -// ; clone -inline % 02Eh - - mov ecx, dword ptr [rbx - elSizeOffset] - mov rsi, [rsp] - and ecx, struct_mask_inv - mov rdi, rbx - add ecx, 3 - shr ecx, 2 - rep movsd - -end - -// ; xset -inline % 2Fh - - mov rax, [rsp] - mov [rbx + rdx * 8], rax - -end - -// ; rabs -inline %30h - - mov rax, [rsp] - fld qword ptr [rax] - fabs - fstp qword ptr [rbx] // ; store result - -end - -// ; len -inline % 31h - - mov edx, struct_mask_inv - mov rcx, [rbx-elSizeOffset] - and rdx, rcx - -end - -// ; rload -inline %32h - - fld qword ptr [rbx] - -end - -// ; flag -inline % 33h - - mov rax, [rbx - elVMTOffset] - mov edx, dword ptr [rax - elVMTFlagOffset] - -end - -// ; parent -inline % 35h - - mov rbx, [rbx - elPackageOffset] - -end - -// ; class -inline % 36h - - mov rbx, [rbx - elVMTOffset] - -end - -// ; mindex -inline % 37h - - mov rcx, rdx - mov rdi, [rbx - elVMTOffset] - xor rdx, rdx - mov esi, dword ptr [rdi - elVMTSizeOffset] - -labSplit: - test esi, esi - jz short labEnd - -labStart: - mov r9, rdi - lea r8, [rsi*8] - shr esi, 1 - setnc dl - cmp rdx, [r9+r8*2] - jb short labSplit - nop - nop - jz short labFound - lea rdi, [rdi+r8+16] - lea rdi, [r9+r8*2] - sub rsi, rdx - jnz short labStart - nop - nop -labEnd: - mov rdx, 0FFFFFFFFh -labFound: - -end - -// ; rround -inline %3Dh - - mov rax, [rsp] - mov edx, 0 - fld qword ptr [rax] - - push rax // ; reserve space on CPU stack - - fstcw word ptr [rsp] // ;get current control word - mov rax, [rsp] - and ax,0F3FFh // ; code it for rounding - push rax - fldcw word ptr [rsp] // ; change rounding code of FPU to round - - frndint // ; round the number - pop rax // ; get rid of last push - fldcw word ptr [rsp] // ; load back the former control word - - fstsw ax // ; retrieve exception flags from FPU - shr al,1 // ; test for invalid operation - pop rcx // ; clean CPU stack - jc short lErr // ; clean-up and return error - - fstp qword ptr [rbx] // ; store result - mov edx, 1 - jmp short labEnd - -lErr: - ffree st(0) - -labEnd: - -end - -// ; equal -inline % 3Eh - - mov rax, [rsp] - xor rdx, rdx - cmp rax, rbx - setz dl - -end - -// ; nequal -inline % 40h - - mov rax, [rsp] - xor edx, edx - mov ecx, dword ptr [rbx] - cmp ecx, dword ptr [rax] - setz dl - -end - -// ; nless -inline % 41h - - mov rax, [rsp] - xor edx, edx - mov ecx, dword ptr [rbx] - cmp ecx, dword ptr [rax] - setl dl - -end - -// ; lequal - -inline % 43h - - mov rax, [rsp] - xor edx, edx - mov rcx, [rbx] - cmp rcx, [rax] - setz dl - -end - -// ; lless(lo, ro, tr, fr) -inline % 44h - - mov rax, [rsp] - xor rdx, rdx - mov rcx, [rbx] - cmp rcx, [rax] - setl dl - -end - -// ; rset (src, tgt) -inline % 45h - - push rdx - fild dword ptr [rsp] - pop rdx - -end - -// ; rsave -inline % 46h - - fstp qword ptr [rbx] - -end - -// ; save -inline % 47h - - mov dword ptr [rbx], edx - -end - -// ; load -inline % 48h - - mov edx, dword ptr [rbx] - -end - -// ; rsaven -inline % 49h - - fistp dword ptr [rbx] - -end - -// ; rsavel -inline % 4Ah - - fistp qword ptr [rbx] - -end - -// ; lsave -inline % 4Bh - - mov [rbx], rdx - -end - -// ; lload -inline % 4Ch - - mov eax, edx - cdq - mov dword ptr [rbx+4], edx - mov dword ptr [rbx], eax - mov edx, eax - -end - -// ; rint -inline % 4Fh - - mov rax, [rsp] - mov ecx, 0 - fld qword ptr [rax] - - push rcx // reserve space on stack - fstcw word ptr [rsp] // get current control word - mov dx, word ptr [rsp] - or dx,0c00h // code it for truncating - push rdx - fldcw word ptr [rsp] // change rounding code of FPU to truncate - - frndint // truncate the number - pop rdx // remove modified CW from CPU stack - fldcw word ptr [rsp] // load back the former control word - pop rdx // clean CPU stack - - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc short labErr // clean-up and return error - -labSave: - fstp qword ptr [rbx] // store result - mov ecx, 1 - jmp short labEnd - -labErr: - ffree st(1) - -labEnd: - mov edx, ecx - -end - -// ; addf -inline % 050h - - lea rsi, [rbp+__arg1] - add dword ptr [rsi], edx - -end - -// ; subf -inline % 051h - - lea rsi, [rbp+__arg1] - sub dword ptr [rsi], edx - -end - -// ; nxorf -inline % 52h - - mov ecx, dword ptr [rbx] - xor dword ptr [rbp+__arg1], ecx - -end - -// ; norf -inline % 53h - - mov ecx, dword ptr [rbx] - or dword ptr [rbp+__arg1], ecx - -end - -// ; nandf -inline % 54h - - mov ecx, dword ptr [rbx] - and dword ptr [rbp+__arg1], ecx - -end - -// ; movfipd -inline % 55h - - lea rcx, [rdx*8] - lea rbx, [rbp+__arg1] - sub rbx, rcx - -end - -// ; xsave -inline % 5Ah - - lea rax, [rbx+__arg1] - mov dword ptr [rax], edx - -end - -// ; div -inline %05Bh - - mov eax, edx - mov ecx, __arg1 - cdq - idiv ecx - mov edx, eax - -end - -// ; xwrite -inline % 5Ch - - mov rsi, [rsp] - mov ecx, __arg1 - lea rdi, [rbx+rdx] - rep movsb - -end - -// ; xwrite -inline % 15Ch - - mov rcx, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rcx] - mov byte ptr [rdi], al - -end - -// ; xwrite -inline % 25Ch - - mov rcx, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rcx] - mov word ptr [rdi], ax - -end - -// ; xwrite -inline % 35Ch - - mov rcx, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rcx] - mov dword ptr [rdi], eax - -end - -// ; xwrite -inline % 45Ch - - mov rcx, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rcx] - mov [rdi], rax - -end - -// ; copyto -inline % 5Dh - - lea rdi, [rbx+rdx] - mov ecx, __arg1 - mov rsi, [rsp] - rep movsd - -end - -// ; copyto -inline % 15Dh - - mov rsi, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rsi] - mov dword ptr [rdi], eax - -end - -// ; copyto -inline % 25Dh - - mov rsi, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rsi] - mov [rdi], rax - -end - -// ; copyto -inline % 35Dh - - mov rsi, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rsi] - mov [rdi], rax - mov rcx, [rsi+8] - mov dword ptr [rdi+8], ecx - -end - -// ; copyto -inline % 45Dh - - mov rsi, [rsp] - lea rdi, [rbx+rdx] - mov rax, [rsi] - mov [rdi], rax - mov rcx, [rsi+8] - mov [rdi+8], rcx - -end - -// ; nshlf -inline % 5Eh - - mov eax, dword ptr [rbp+__arg1] - mov ecx, dword ptr [rbx] - shl eax, cl - mov dword ptr [rbp+__arg1], eax - -end - -// ; nshrf -inline % 5Fh - - mov eax, dword ptr [rbp+__arg1] - mov ecx, dword ptr [rbx] - shr eax, cl - mov dword ptr [rbp+__arg1], eax - -end - -// ; mul -inline %060h - - mov rax, rdx - mov ecx, __arg1 - imul ecx - mov rdx, rax - -end - -// ; checksi -inline % 061h - - mov rdi, [rsp+__arg1] - xor rdx, rdx - mov rsi, [rbx-elVMTOffset] -labNext: - mov rax, 0 - cmp rsi, rdi - mov rsi, [rsi - elPackageOffset] - setz dl - cmovnz rax, rsi - and rax, rax - jnz short labNext - -end - -// ; xredirect -inline % 062h - - lea rbx, [rbx + __arg2] // ; NOTE use __arg2 due to current implementation - push rbx - push rdx - - mov rsi, [rbx] // ; get next overload list - test rsi, rsi - jz labEnd - -labNextList: - xor edx, edx - mov ebx, dword ptr[rsi] // ; message from overload list - -labNextOverloadlist: - shr ebx, ACTION_ORDER - mov rdi, rdata : % CORE_MESSAGE_TABLE - mov rcx, [rsp] - mov rbx, [rdi + rbx * 8 + 4] - and ecx, ARG_MASK - lea rbx, [rdi + rbx - 4] - inc ecx - -labNextParam: - sub ecx, 1 - jnz short labMatching - - pop rax - pop rsi - mov rcx, rdx - mov rsi, [rsi] - mov rbx, [rsp] - mov rdx, [rsi + rcx * 8] - jmp [rsi + rcx * 8 + 4] - -labMatching: - mov rdi, [rax + rcx * 4] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi - elVMTOffset] - mov rsi, [rbx + rcx * 4] - -labNextBaseClass: - cmp rsi, rdi - jz labNextParam - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - mov rsi, [rsp+4] - add rdx, 1 - mov rsi, [rsi] - mov rbx, [rsi + rdx * 8] // ; message from overload list - and rbx, rbx - jnz labNextOverloadlist - add [rsp+4], 4 - mov rsi, [rsp+4] - mov rdx, [rsi] - test rdx, rdx - jnz labNextList - -labEnd: - pop rdx - pop rbx - -end - -// ; xvredirect -inline % 063h - - lea rbx, [rbx + __arg2] // ; NOTE use __arg2 due to current implementation - push rbx - push rdx - - mov rsi, [rbx] // ; get next overload list - test rsi, rsi - jz labEnd - -labNextList: - xor rdx, rdx - mov rbx, rax - xor rcx, rcx - -labCountParam: - lea rbx, [rbx+4] - cmp [rbx], -1 - lea rcx, [rcx+1] - jnz short labCountParam - - push rcx - mov rbx, [rsi] // ; message from overload list - -labNextOverloadlist: - mov rdi, rdata : % CORE_MESSAGE_TABLE - shr ebx, ACTION_ORDER - mov rcx, [rsp] // ; param count - mov rbx, [rdi + rbx * 8 + 4] - lea rbx, [rdi + rbx - 4] - -labNextParam: - // ; check if signature contains the next class ptr - lea rsi, [rbx + 4] - cmp [rsi], 0 - cmovnz rbx, rsi - - sub ecx, 1 - jnz short labMatching - - lea rsp, [rsp + 8] - pop rax - pop rsi - mov rcx, rdx - mov rsi, [rsi] - mov rbx, [rsp] - mov rdx, [rsi + rcx * 8] - jmp [rsi + rcx * 8 + 4] - -labMatching: - mov rsi, [rsp] - sub rsi, rcx - mov rdi, [rax + rsi * 4] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi - elVMTOffset] - mov rsi, [rbx] - -labNextBaseClass: - cmp rsi, rdi - jz labNextParam - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - mov rsi, [rsp+8] - add rdx, 1 - mov rsi, [rsi] - mov rbx, [rsi + rdx * 8] // ; message from overload list - and rbx, rbx - jnz labNextOverloadlist - - add [rsp+8], 4 - mov rsi, [rsp+8] - mov rdx, [rsi] - test rdx, rdx - jnz labNextList - -labEnd: - lea rsp, [rsp + 8] - pop rdx - pop rbx - -end - -// ; laddf -inline % 074h - - mov rcx, [rbx] - add [rbp+__arg1], rcx - -end - -// ; lsubf -inline % 075h - - mov rcx, [rbx] - sub [rbp+__arg1], rcx - -end - -// ; lmulf -inline % 076h - - mov rax, qword ptr [rbp+__arg1] - imul qword ptr [rbx] - mov qword ptr [rbp+__arg1], rax - -end - -// ; ldivf -inline % 077h - - mov rax, qword ptr [rbp+__arg1] - cqo - idiv qword ptr [rbx] - mov [rbp+__arg1], rax - -end - -// ; landf -inline % 078h - - mov rcx, qword ptr [rbx] - and qword ptr [rbp+__arg1], rcx - -end - -// ; lorf -inline % 079h - - mov rcx, qword ptr [rbx] - or qword ptr [rbp+__arg1], rcx - -end - -// ; lxorf -inline % 07Ah - - mov rcx, qword ptr [rbx] - xor qword ptr [rbp+__arg1], rcx - -end - -// ; lshlf -inline % 7Bh - - mov rax, [rbp+__arg1] - mov ecx, dword ptr [rbx] - shl rax, cl - mov qword ptr [rbp+__arg1], rax - -end - -// ; lshrf -inline % 7Dh - - mov rax, [rbp+__arg1] - mov ecx, dword ptr [rbx] - shr rax, cl - mov qword ptr [rbp+__arg1], rax - -end - -// ; raddnf -inline % 80h - - lea rdi, [rbp+__arg1] - fild dword ptr [rbx] - fadd qword ptr [rdi] - fstp qword ptr [rdi] - -end - -// ; rsubnf -inline % 81h - - lea rdi, [rbp+__arg1] - fld qword ptr [rdi] - fisub dword ptr [rbx] - fstp qword ptr [rdi] - -end - -// ; rmulnf -inline % 82h - - lea rdi, [rbp+__arg1] - fld qword ptr [rdi] - fimul dword ptr [rbx] - fstp qword ptr [rdi] - -end - -// ; requal -inline % 83h - - mov rdi, [rsp] - fld qword ptr [rdi] - fld qword ptr [rbx] - xor edx, edx - fcomip st, st(1) - sete dl - fstp st(0) - -end - -// ; rless(lo, ro, tr, fr) -inline % 84h - - mov rdi, [rsp] - fld qword ptr [rdi] - fld qword ptr [rbx] - xor edx, edx - fcomip st, st(1) - setb dl - fstp st(0) - -end - -// ; raddf -inline % 85h - - lea rdi, [rbp+__arg1] - fld qword ptr [rbx] - fadd qword ptr [rdi] - fstp qword ptr [rdi] - -end - -// ; rsubf -inline % 86h - - lea rdi, [rbp+__arg1] - fld qword ptr [rdi] - fsub qword ptr [rbx] - fstp qword ptr [rdi] - -end - -// ; rmulf -inline % 87h - - lea rdi, [rbp+__arg1] - fld qword ptr [rdi] - fmul qword ptr [rbx] - fstp qword ptr [rdi] - -end - -// ; rdivf -inline % 88h - - lea rdi, [rbp+__arg1] - fld qword ptr [rdi] - fdiv qword ptr [rbx] - fstp qword ptr [rdi] - -end - -// ; rdivnf -inline % 89h - - lea rdi, [rbp+__arg1] - fld qword ptr [rdi] - fidiv dword ptr [rbx] - fstp qword ptr [rdi] - -end - -// ; rintf -inline % 8Eh - - lea rdi, [rbp+__arg1] - mov rcx, 0 - fld qword ptr [rbx] - - push rcx // reserve space on stack - fstcw word ptr [rsp] // get current control word - mov dx, word ptr [rsp] - or dx,0c00h // code it for truncating - push rdx - fldcw word ptr [rsp] // change rounding code of FPU to truncate - - frndint // truncate the number - pop rdx // remove modified CW from CPU stack - fldcw word ptr [rsp] // load back the former control word - pop rdx // clean CPU stack - - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc short labErr // clean-up and return error - -labSave: - fstp qword ptr [rdi] // store result - mov rdx, 1 - jmp short labEnd - -labErr: - ffree st(1) - -labEnd: - -end - -// ; geti -inline % 91h - - mov rbx, [rbx+__arg1] - -end - -// ; restore -inline % 92h - - add rbp, __arg1 - -end - -// ; peekfi -inline % 94h - - mov rbx, [rbp+__arg1] - -end - -// ; peeksi -inline % 95h - - mov rbx, [rsp+__arg1] - -end - -// ; ifheap - part of the command -inline % 96h - - xor edx, edx - mov rax,[data : %CORE_GC_TABLE + gc_start] - mov esi, 1 - mov rcx,[data : %CORE_GC_TABLE + gc_end] - cmp rbx, rax - cmovl rdx, rsi - cmp rbx, rcx - cmovg rdx, rsi - and rdx, rdx - -end - -// ; xseti -inline %97h - - mov rax, [rsp] - mov [rbx + __arg1], rax - -end - -// ; create -inline % 9Ah - - mov rax, [rsp] - mov ecx, page_ceil - mov rdx, [rax] - lea rcx, [rcx + rdx*8] - and ecx, page_mask - - call code : %GC_ALLOC - - mov rax, [rsp] - xor edx, edx - mov [rbx-elVMTOffset], __arg1 - mov rcx, [rax] - mov esi, stuct_mask - test ecx, ecx - cmovz rdx, rsi - shl ecx, 3 - or ecx, edx - mov dword ptr[rbx-elSizeOffset], ecx - -end - -// ; ajumpvi -inline % 0A1h - - mov rax, [rbx - elVMTOffset] - jmp [rax + __arg1] - -end - -// ; callvi (ecx - offset to VMT entry) -inline % 0A2h - - mov rax, [rbx - elVMTOffset] - call [rax + __arg1] - -end - -// ; hook label (ecx - offset) -// ; NOTE : hook calling should be the first opcode -inline % 0A6h - - call code : %HOOK - - push [data : %CORE_GC_TABLE + gc_et_current] - - mov rdx, rsp - push rbp - push rdx - push rcx - - mov [data : %CORE_GC_TABLE + gc_et_current], rsp - -end - -// ; address label (ecx - offset) -inline % 0A7h - - call code : %HOOK - mov rdx, rcx - -end - -// ; calli -inline % 0A8h - - mov rsi, [rbx + __arg1] - call rsi - -end - -// ; ifcount -// ; - partial opcode -inline % 0AFh - - mov ecx, struct_mask_inv - mov eax, dword ptr [rbx-elSizeOffset] - and rax, rcx - shr rax, 3 - cmp rax, rdx - -end - -// ; movn -inline % 0B1h - - mov edx, __arg1 - -end - -// ; equalfi -inline % 0B3h - - mov rax, [rbp+__arg1] - xor rdx, rdx - cmp rax, rbx - setz dl - -end - -// ; pushai -inline % 0B4h - - push [rbx+__arg1] - -end - -// ; loadf -inline % 0B5h - - movsxd rdx, dword ptr [rbp + __arg1] - -end - -// ; loadfi -inline % 0B7h - - movsxd rdx, dword ptr [rbp + __arg1] - -end - -// ; dloadsi -inline % 0B8h - - movsxd rdx, dword ptr[rsp + __arg1] - -end - -// ; savef -inline % 0B9h - - mov dword ptr [rbp + __arg1], edx - -end - -// ; savesi -inline % 0BBh - - mov dword ptr [rsp + __arg1], edx - -end - -// ; savefi -inline % 0BCh - - mov rax, [rbp + __arg1] - mov dword ptr[rax], edx - -end - -// ; pushf -inline % 0BDh - - lea rax, [rbp + __arg1] - push rax - -end - -// ; pushsip -inline % 0BEh - - lea rax, [rsp + __arg1] - push rax - -end - -// ; reserve -inline % 0BFh - - sub rsp, __arg1 - push rbp - push 0 - mov rbp, rsp - -end - -// ; seti -inline %0C0h - - mov rsi, rbx - mov rax, [rsp] - // calculate write-barrier address - sub rsi, [data : %CORE_GC_TABLE + gc_start] - mov rcx, [data : %CORE_GC_TABLE + gc_header] - shr rsi, page_size_order - mov byte ptr [rsi + rcx], 1 - - mov [rbx + __arg1], rax - -end - -// ; storesi -inline % 0C3h - - mov [rsp+__arg1], rbx - -end - -// ; storefi -inline % 0C4h - - mov [rbp+__arg1], rbx - -end - -// ; naddf -inline % 0C5h - - mov ecx, dword ptr [rbx] - add dword ptr [rbp+__arg1], ecx - -end - -// ; nmulf -inline % 0C6h - - mov eax, dword ptr [rbp+__arg1] - imul dword ptr [rbx] - mov dword ptr [rbp+__arg1], eax - -end - -// ; xsetr -inline % 0C7h - - mov ecx, __arg1 - movsxd rax, ecx - mov [rbx + rdx * 8], rax - -end - -// ; nsubf -inline % 0C8h - - mov ecx, dword ptr [rbx] - sub dword ptr [rbp+__arg1], ecx - -end - -// ; ndivf -inline % 0C9h - - mov eax, dword ptr [rbp+__arg1] - cdq - idiv dword ptr [rbx] - mov dword ptr [rbp+__arg1], eax - -end - -// ; loadi -inline % 0CAh - - mov rdx, [rbx + __arg1] - -end - -// ; savei -inline % 0CBh - - mov [rbx + __arg1], rdx - -end - -// ; xor -inline % 0CDh - - xor edx, __arg1 - -end - -// ; clonef -inline % 0CEh - - mov rcx, [rbx - elSizeOffset] - and ecx, struct_mask_inv - lea rsi, [rbp+__arg1] - shr rcx, 2 - mov rdi, rbx - rep movsd - -end - -// ; xload -inline % 0CFh - - mov edx, dword ptr [rbx + __arg1] - -end - -// ; alloci -inline %0D1h - - // ; generated in jit : sub esp, __arg1*4 - mov ecx, __arg1 - xor eax, eax - mov rdi, rsp - rep stos - -end - -// ; xcreate -inline % 0D2h - - mov rax, [rsp] - mov edx, struct_mask_inv - mov ecx, dword ptr[rax-elSizeOffset] - and edx, ecx - mov ecx, page_ceil - add ecx, edx - and ecx, page_mask - - call code : %GC_ALLOC - - mov rax, [rsp] - mov [rbx-elVMTOffset], __arg1 - mov edx, struct_mask_inv - mov ecx, dword ptr[rax-elSizeOffset] - and edx, ecx - mov dword ptr[rbx-elSizeOffset], edx - -end - -// ; inc -inline %0D6h - - add rdx, __arg1 - -end - -// ; coalescer -inline % 0D8h - - mov rax, __arg1 - test rbx, rbx - cmovz rbx, rax - -end - -// ; vjumprm -inline % 0DBh - - mov ecx, __arg1 - shl ecx, 4 - mov rax, [rbx - elVMTOffset] - jmp [rax + rcx + 8] - -end - -// ; xsaveai (__arg1 - index, __arg2 - n) -inline % 0DCh - - mov rax, __arg2 - mov [rbx + __arg1], rax - -end - -// ; copyai (__arg1 - index, __arg2 - n) -inline % 0DDh - - mov ecx, __arg2 - lea rsi, [rbx + __arg1] - mov rdi, [rsp] - rep movsd - -end - -inline % 01DDh - - lea rsi, [rbx + __arg1] - mov rdi, [rsp] - mov eax, dword ptr [rsi] - mov dword ptr [rdi], eax - -end - -inline % 02DDh - - lea rsi, [rbx + __arg1] - mov rdi, [rsp] - mov rax, [rsi] - mov [rdi], rax - -end - -inline % 03DDh - - lea rsi, [rbx + __arg1] - mov rdi, [rsp] - mov rax, [rsi] - mov [rdi], rax - mov ecx, dword ptr [rsi+8] - mov dword ptr [rdi+8], ecx - -end - -inline % 04DDh - - lea rsi, [rbx + __arg1] - mov rdi, [rsp] - mov rax, [rsi] - mov [rdi], rax - mov rcx, [rsi+8] - mov [rdi+8], rcx - -end - -// ; move -inline % 0DEh - - lea rsi, [rbx+__arg1] - mov ecx, __arg2 - mov rdi, [rsp] - rep movsb - -end - -// ; move -inline % 01DEh - - lea rsi, [rbx+__arg1] - mov rdi, [rsp] - mov rax, [rsi] - mov byte ptr [rdi], al - -end - -inline % 02DEh - - lea rsi, [rbx+__arg1] - mov rdi, [rsp] - mov rax, [rsi] - mov word ptr [rdi], ax - -end - -inline % 03DEh - - lea rsi, [rbx+__arg1] - mov rdi, [rsp] - mov rax, [rsi] - mov dword ptr [rdi], eax - -end - -inline % 04DEh - - lea rsi, [rbx+__arg1] - mov rdi, [rsp] - mov rax, [rsi] - mov [rdi], rax - -end - -// ; moveto -inline % 0DFh - - lea rdi, [rbx+__arg1] - mov ecx, __arg2 - mov rsi, [rsp] - rep movsb - -end - -inline % 01DFh - - mov rsi, [rsp] - lea rdi, [rbx+__arg1] - mov rax, [rsi] - mov byte ptr [rdi], al - -end - -inline % 02DFh - - mov rsi, [rsp] - lea rdi, [rbx+__arg1] - mov rax, [rsi] - mov word ptr [rdi], ax - -end - -inline % 03DFh - - mov rsi, [rsp] - lea rdi, [rbx+__arg1] - mov rax, [rsi] - mov dword ptr[rdi], eax - -end - -inline % 04DFh - - mov rsi, [rsp] - lea rdi, [rbx+__arg1] - mov rax, [rsi] - mov [rdi], rax - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 0E0h - - mov ecx, __arg2 - lea rdi, [rbp + __arg1] - lea rsi, [rbx+rdx] - rep movsd - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 1E0h - - mov rcx, [rbx+rdx] - lea rdi, [rbp + __arg1] - mov dword ptr [rdi], ecx -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 2E0h - - mov rcx, [rbx+rdx] - lea rdi, [rbp + __arg1] - mov [rdi], rcx - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 3E0h - - mov rcx, [rbx+rdx] - lea rdi, [rbp + __arg1] - mov [rdi], rcx - mov rax, [rbx+rdx+8] - mov dword ptr [rdi+8], eax - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 4E0h - - mov rcx, [rbx+rdx] - lea rdi, [rbp + __arg1] - mov [rdi], rcx - mov rax, [rbx+rdx+8] - mov [rdi+8], rax - -end - -// ; createn (__arg1 - item size) -inline % 0E1h - - mov rax, [rsp] - mov ecx, page_ceil - mov rax, [rax] - mov ebx, __arg1 - imul ebx - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov rax, [rsp] - mov ecx, stuct_mask - mov rax, [rax] - mov esi, __arg1 - imul esi - or ecx, eax - mov dword ptr [rbx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 1) -inline % 1E1h - - mov rax, [rsp] - mov ecx, page_ceil - add ecx, dword ptr[rax] - and ecx, page_mask - - call code : %GC_ALLOC - - mov rax, [rsp] - mov ecx, stuct_mask - or ecx, dword ptr[rax] - mov dword ptr[rbx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 2) -inline % 2E1h - - mov rax, [rsp] - mov ecx, page_ceil - mov eax, dword ptr [rax] - shl eax, 1 - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov rax, [rsp] - mov ecx, stuct_mask - mov rax, [rax] - shl eax, 1 - or ecx, eax - mov dword ptr[rbx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 4) -inline % 3E1h - - mov rax, [rsp] - mov ecx, page_ceil - mov eax, dword ptr [rax] - shl eax, 2 - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov rax, [rsp] - mov ecx, stuct_mask - mov rax, [rax] - shl eax, 2 - or ecx, eax - mov dword ptr[rbx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 8) -inline % 4E1h - - mov rax, [rsp] - mov rcx, page_ceil - mov eax, dword ptr [rax] - shl eax, 3 - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov rax, [rsp] - mov rcx, stuct_mask - mov rax, [rax] - shl eax, 3 - or ecx, eax - mov dword ptr[rbx-elSizeOffset], ecx - -end - -// ; xsetfi (__arg1 - index, __arg2 - index) -inline % 0E2h - - mov rax, [rbp + __arg1] - mov [rbx + __arg2], rax - -end - -// ; copytoai (__arg1 - index, __arg2 - n) -inline % 0E3h - - mov ecx, __arg2 - lea rdi, [rbx + __arg1] - mov rsi, [rsp] - rep movsd - -end - -inline % 01E3h - - mov rsi, [rsp] - lea rdi, [rbx + __arg1] - mov rax, [rsi] - mov dword ptr[rdi], eax - -end - -inline % 02E3h - - mov rsi, [rsp] - lea rdi, [rbx + __arg1] - mov rax, [rsi] - mov [rdi], rax - -end - -inline % 03E3h - - mov rsi, [rsp] - lea rdi, [rbx + __arg1] - mov rax, [rsi] - mov [rdi], rax - mov rcx, [rsi+8] - mov dword ptr[rdi+8], ecx - -end - -inline % 04E3h - - mov rsi, [rsp] - lea rdi, [rbx + __arg1] - mov rax, [rsi] - mov [rdi], rax - mov rcx, [rsi+8] - mov [rdi+8], rcx - -end - -// ; copytofi (__arg1 - index, __arg2 - n) -inline % 0E4h - - mov ecx, __arg2 - mov rdi, [rbp + __arg1] - mov rsi, rbx - rep movsd - -end - -inline % 1E4h - - mov rdi, [rbp + __arg1] - mov rax, [rbx] - mov dword ptr[rdi], eax - -end - -inline % 2E4h - - mov rdi, [rbp + __arg1] - mov rax, [rbx] - mov [rdi], rax - -end - -inline % 3E4h - - mov rdi, [rbp + __arg1] - mov rax, [rbx] - mov rcx, [rbx+8] - mov [rdi], rax - mov dword ptr[rdi+8], ecx - -end - -inline % 4E4h - - mov rdi, [rbp + __arg1] - mov rax, [rbx] - mov rcx, [rbx+8] - mov [rdi], rax - mov [rdi+8], rsi - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 0E5h - - mov ecx, __arg2 - lea rdi, [rbp + __arg1] - mov rsi, rbx - rep movsd - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 1E5h - - lea rdi, [rbp + __arg1] - mov rax, [rbx] - mov dword ptr[rdi], eax - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 2E5h - - lea rdi, [rbp + __arg1] - mov rax, [rbx] - mov [rdi], rax - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 3E5h - - lea rdi, [rbp + __arg1] - mov rax, [rbx] - mov [rdi], rax - mov rcx, [rbx+8] - mov dword ptr[rdi+8], ecx - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 4E5h - - lea rdi, [rbp + __arg1] - mov rax, [rbx] - mov [rdi], rax - mov rcx, [rbx+8] - mov [rdi+8], rcx - -end - -// ; copyfi (__arg1 - index, __arg2 - n) -inline % 0E6h - - mov ecx, __arg2 - mov rsi, [rbp + __arg1] - mov rdi, rbx - rep movsd - -end - -inline % 01E6h - - mov rsi, [rbp + __arg1] - mov rax, [rsi] - mov dword ptr[rbx], eax - -end - -inline % 02E6h - - mov rsi, [rbp + __arg1] - mov rax, [rsi] - mov [rbx], rax - -end - -inline % 03E6h - - mov rsi, [rbp + __arg1] - mov rax, [rsi] - mov [rbx], rax - mov rcx, [rsi+8] - mov dword ptr [rbx+8], ecx - -end - -inline % 04E6h - - mov rsi, [rbp + __arg1] - mov rax, [rsi] - mov [rbx], rax - mov rcx, [rsi+8] - mov [rbx+8], rcx - -end - -// ; copyf (__arg1 - index, __arg2 - n) -inline % 0E7h - - mov ecx, __arg2 - lea rsi, [rbp + __arg1] - mov rdi, rbx - rep movsd - -end - -inline % 01E7h - - lea rsi, [rbp + __arg1] - mov rax, [rsi] - mov dword ptr[rbx], eax - -end - -inline % 02E7h - - lea rsi, [rbp + __arg1] - mov rax, [rsi] - mov [rbx], rax - -end - -inline % 03E7h - - lea rsi, [rbp + __arg1] - mov rax, [rsi] - mov [rbx], rax - mov rcx, [rsi+8] - mov dword ptr[rbx+8], ecx - -end - -inline % 04E7h - - lea rsi, [rbp + __arg1] - mov rax, [rsi] - mov [rbx], rax - mov rcx, [rsi+8] - mov [rbx+8], rcx - -end - -// ; mtredirect (__arg3 - number of parameters, eax - points to the stack arg list) -inline % 0E8h - - mov rsi, __arg1 - mov r8, rbx - xor edx, edx - mov rbx, [rsi] // ; message from overload list - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr ebx, ACTION_ORDER - lea r10, [rbx*8] - mov r10, [r9 + r10 * 2 + 8] - mov ecx, __arg3 - lea rbx, [r9 + r10 - 8] - -labNextParam: - sub ecx, 1 - jnz short labMatching - - mov r9, __arg1 - lea r10, [rdx * 8] - mov rbx, r8 - mov r10, [r9 + r10 * 2 + 8] - mov rcx, [rbx - elVMTOffset] - lea rax, [r10 * 8] - mov rdx, [r9 + r10 * 2] - jmp [rcx + rax * 2 + 8] - -labMatching: - mov rdi, [rax + rcx * 8] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi - elVMTOffset] - mov rsi, [rbx + rcx * 8] - -labNextBaseClass: - cmp rsi, rdi - jz labNextParam - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rbx, [r10 + r9 * 2] // ; message from overload list - and rbx, rbx - jnz labNextOverloadlist - -end - -// ; xmtredirect (__arg3 - number of parameters, eax - points to the stack arg list) -inline % 0E9h - - mov rsi, __arg1 - mov r8, rbx - xor edx, edx - mov rbx, [rsi] // ; message from overload list - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr ebx, ACTION_ORDER - lea r10, [rbx*8] - mov r10, [r9 + r10 * 2 + 8] - mov ecx, __arg3 - lea rbx, [r9 + r10 - 8] - -labNextParam: - sub ecx, 1 - jnz short labMatching - - mov r9, __arg1 - lea r10, [rdx * 8] - mov rbx, r8 - mov rdx, [r9 + r10 * 2] - jmp [r9 + r10 * 2 + 8] - -labMatching: - mov rdi, [rax + rcx * 8] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi - elVMTOffset] - mov rsi, [rbx + rcx * 8] - -labNextBaseClass: - cmp rsi, rdi - jz labNextParam - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rbx, [r10 + r9 * 2] // ; message from overload list - and rbx, rbx - jnz labNextOverloadlist - -end - -// ; mtredirect<1> -inline % 1E8h - - mov rcx, __arg1 - xor edx, edx - mov rax, [rax + 8] - mov rcx, [rcx] // ; message from overload list - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rax, rax - cmovz rax, rsi - - mov rax, [rax - elVMTOffset] - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr ecx, ACTION_ORDER - lea r10, [rcx*8] - mov r10, [r9 + r10 * 2 + 8] - lea rcx, [r9 + r10] - -labMatching: - mov rdi, rax - mov rsi, [rcx] - -labNextBaseClass: - cmp rsi, rdi - jnz short labContinue - - lea r9, [rdx*8] - mov r10, __arg1 - mov rax, [r10 + r9 * 2 + 8] - mov rcx, [rbx - elVMTOffset] - shl rax, 1 - mov rdx, [r10 + r9 * 2] - jmp [rcx + rax * 8 + 8] - -labContinue: - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rcx, [r10 + r9 * 2] // ; message from overload list - and rcx, rcx - jnz labNextOverloadlist - -labEnd: - -end - -// ; xmtredirect<1> -inline % 1E9h - - mov rcx, __arg1 - xor edx, edx - mov rax, [rax + 8] - mov rcx, [rcx] // ; message from overload list - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rax, rax - cmovz rax, rsi - - mov rax, [rax - elVMTOffset] - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr ecx, ACTION_ORDER - lea r10, [rcx*8] - mov r10, [r9 + r10 * 2 + 8] - lea rcx, [r9 + r10] - -labMatching: - mov rdi, rax - mov rsi, [rcx] - -labNextBaseClass: - cmp rsi, rdi - jnz short labContinue - - lea r9, [rdx*8] - mov r10, __arg1 - mov rdx, [r10 + r9 * 2] - jmp [r10 + r9 * 2 + 8] - -labContinue: - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rcx, [r10 + r9 * 2] // ; message from overload list - and rcx, rcx - jnz labNextOverloadlist - -labEnd: - -end - -// ; mtredirect<2> (eax - refer to the stack) -inline % 2E8h - - mov rcx, __arg1 - xor rdx, rdx - mov rcx, [rcx] // ; message from overload list - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr ecx, ACTION_ORDER - lea r10, [rcx*8] - mov r10, [r9 + r10 * 2 + 8] - lea rcx, [r9 + r10] - -labMatching: - mov rdi, [rax+8] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi-elVMTOffset] - mov rsi, [rcx] - -labNextBaseClass: - cmp rsi, rdi - jnz labContinue - - mov rdi, [rax+16] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi-elVMTOffset] - mov rsi, [rcx + 8] - -labNextBaseClass2: - cmp rsi, rdi - jnz short labContinue2 - - lea r9, [rdx*8] - mov r10, __arg1 - mov rax, [r10 + r9 * 2 + 8] - mov rcx, [rbx - elVMTOffset] - lea rax, [rax * 8] - mov rdx, [r10 + r9 * 2] - jmp [rcx + rax * 2 + 8] - -labContinue2: - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass2 - nop - nop - jmp short labNext - -labContinue: - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - -labNext: - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rcx, [r10 + r9 * 2] // ; message from overload list - and rcx, rcx - jnz labNextOverloadlist - -end - -// ; xmtredirect<2> (eax - refer to the stack) -inline % 2E9h - - mov rcx, __arg1 - xor rdx, rdx - mov rcx, [rcx] // ; message from overload list - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr ecx, ACTION_ORDER - lea r10, [rcx*8] - mov r10, [r9 + r10 * 2 + 8] - lea rcx, [r9 + r10] - -labMatching: - mov rdi, [rax+8] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi-elVMTOffset] - mov rsi, [rcx] - -labNextBaseClass: - cmp rsi, rdi - jnz labContinue - - mov rdi, [rax+16] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi-elVMTOffset] - mov rsi, [rcx + 8] - -labNextBaseClass2: - cmp rsi, rdi - jnz short labContinue2 - - lea r9, [rdx*8] - mov r10, __arg1 - mov rdx, [r10 + r9 * 2] - jmp [r10 + r9 * 2 + 8] - -labContinue2: - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass2 - nop - nop - jmp short labNext - -labContinue: - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - -labNext: - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rcx, [r10 + r9 * 2] // ; message from overload list - and rcx, rcx - jnz labNextOverloadlist - -end - -// ; mtredirect<12> (__arg3 - number of parameters, eax - points to the stack arg list) -inline % 0CE8h - - mov r8, rbx - xor rdx, rdx - mov rbx, rax - xor rcx, rcx - -labCountParam: - lea rbx, [rbx+8] - cmp qword ptr [rbx], -1 - lea rcx, [rcx+1] - jnz short labCountParam - - mov rsi, __arg1 - mov r11, rcx - mov rbx, [rsi] // ; message from overload list - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr rbx, ACTION_ORDER - mov rcx, r11 // ; param count - lea r10, [rbx*8] - mov r10, [r9 + r10 * 2 + 8] - lea rbx, [r9 + r10 - 8] - -labNextParam: - // ; check if signature contains the next class ptr - lea rsi, [rbx + 8] - cmp [rsi], 0 - cmovnz rbx, rsi - - sub rcx, 1 - jnz short labMatching - - mov r9, __arg1 - lea r10, [rdx * 8] - mov rbx, r8 - mov r10, [r9 + r10 * 2 + 8] - mov rcx, [rbx - elVMTOffset] - lea rax, [r10 * 8] - mov rdx, [r9 + r10 * 2] - jmp [rcx + rax * 2 + 8] - -labMatching: - mov rsi, r11 - sub rsi, rcx - mov rdi, [rax + rsi * 8] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi - elVMTOffset] - mov rsi, [rbx] - -labNextBaseClass: - cmp rsi, rdi - jz labNextParam - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rbx, [r10 + r9 * 2] // ; message from overload list - and rbx, rbx - jnz labNextOverloadlist - mov rbx, r8 - -end - -// ; xmtredirect<12> -inline % 0CE9h - - mov r8, rbx - xor rdx, rdx - mov rbx, rax - xor rcx, rcx - -labCountParam: - lea rbx, [rbx+8] - cmp qword ptr [rbx], -1 - lea rcx, [rcx+1] - jnz short labCountParam - - mov rsi, __arg1 - mov r11, rcx - mov rbx, [rsi] // ; message from overload list - -labNextOverloadlist: - mov r9, rdata : % CORE_MESSAGE_TABLE - shr rbx, ACTION_ORDER - mov rcx, r11 // ; param count - lea r10, [rbx*8] - mov r10, [r9 + r10 * 2 + 8] - lea rbx, [r9 + r10 - 8] - -labNextParam: - // ; check if signature contains the next class ptr - lea rsi, [rbx + 8] - cmp [rsi], 0 - cmovnz rbx, rsi - - sub rcx, 1 - jnz short labMatching - - mov r9, __arg1 - lea r10, [rdx * 8] - mov rbx, r8 - mov rdx, [r9 + r10 * 2] - jmp [r9 + r10 * 2 + 8] - -labMatching: - mov rsi, r11 - sub rsi, rcx - mov rdi, [rax + rsi * 8] - - //; check nil - mov rsi, rdata : %VOIDPTR + elObjectOffset - test rdi, rdi - cmovz rdi, rsi - - mov rdi, [rdi - elVMTOffset] - mov rsi, [rbx] - -labNextBaseClass: - cmp rsi, rdi - jz labNextParam - mov rdi, [rdi - elPackageOffset] - and rdi, rdi - jnz short labNextBaseClass - - add rdx, 1 - mov r10, __arg1 - lea r9, [rdx * 8] - mov rbx, [r10 + r9 * 2] // ; message from overload list - and rbx, rbx - jnz labNextOverloadlist - mov rbx, r8 - -end - -// ; xrsavef (__arg1 - index, __arg2 - n) -inline % 0EDh - - push __arg2 - fild dword ptr [rsp] - lea rdi, [rbp+__arg1] - fstp qword ptr [rdi] - lea rsp, [rsp+8] - -end - -// ; xaddf (__arg1 - index, __arg2 - n) -inline % 0EEh - - add dword ptr [rbp + __arg1], __arg2 - -end - -// ; xsavef (__arg1 - index, __arg2 - n) -inline % 0EFh - - mov dword ptr [rbp + __arg1], __arg2 - -end - -// ; new (__arg1 - size) -inline % 0F0h - - mov ecx, __arg1 - call code : %GC_ALLOC - -end - -// ; fillr (__arg1 - r) -inline % 09Bh - mov rsi, [rsp] - mov rax, __arg1 - mov rdi, rbx - mov ecx, dword ptr[rsi] - rep stos - -end - -// ; fillri (__arg1 - count) -inline % 0F2h - - mov rdi, rbx - mov ecx, __arg1 - rep stos - -end - -// ; xselectr (eax - r1, __arg1 - r2) -inline % 0F3h - - test rbx, rbx - mov rbx, __arg1 - cmovnz rbx, rax - -end - -// ; vcallrm -inline % 0F4h - - mov ecx, __arg1 - mov rax, [rbx - elVMTOffset] - shl ecx, 4 - call [rax + rcx + 8] - -end - -// ; jumprm -inline % 0F5h - - cmp [rbx], rbx - jmp __arg1 - -end - -// ; selectr (ebx - r1, __arg1 - r2) -inline % 0F6h - - mov rcx, __arg1 - test rdx, rdx - cmovnz rbx, rcx - -end - -// ; allocn (__arg1 - size) -inline % 0F8h - - mov ecx, __arg1 - call code : %GC_ALLOCPERM - -end - -// ; xsavesi (__arg1 - index, __arg2 - n) -inline % 0F9h - - mov eax, __arg2 - mov [rsp + __arg1], rax - -end - -// ; xsavesi (__arg1 - index, __arg2 - n) -inline % 01F9h - - mov eax, __arg2 - movsxd rax, eax - mov [rsp + __arg1], rax - -end - -// callrm (edx contains message, __arg1 contains vmtentry) -inline % 0FEh - - call code : __arg1 - -end - -// ; callextr -inline % 0FFh - - mov rcx, [rsp] - mov rdx, [rsp+8] - mov r8, [rsp+16] - mov r9, [rsp+24] - call extern __arg1 - mov rdx, rax - -end - -// ; callextr -inline % 1FFh - - mov rcx, [rsp] - sub rsp, 20h - call extern __arg1 - mov rdx, rax - -end - -// ; callextr -inline % 2FFh - - mov rcx, [rsp] - mov rdx, [rsp+8] - sub rsp, 10h - call extern __arg1 - mov rdx, rax - -end - -// ; callextr -inline % 3FFh - - mov rcx, [rsp] - mov rdx, [rsp+8] - mov r8, [rsp+16] - sub rsp, 10h - call extern __arg1 - mov rdx, rax - -end diff --git a/asm/amd64/core60.asm b/asm/amd64/core60.asm index 8ea49150db..62fc16f5cc 100644 --- a/asm/amd64/core60.asm +++ b/asm/amd64/core60.asm @@ -184,6 +184,13 @@ labYGCollect: push rsi push rcx + // ; save perm roots + mov rsi, [data : %CORE_GC_TABLE + gc_perm_start] + mov rcx, [data : %CORE_GC_TABLE + gc_perm_current] + sub rcx, rsi + push rsi + push rcx + // ; collect frames mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] mov rcx, rax @@ -338,6 +345,7 @@ labPERMCollect: call extern "$rt.CollectPermGCLA" add rsp, 30h + mov rbx, rax pop r11 pop r10 @@ -411,7 +419,7 @@ end // ; load inline %6 - mov edx, dword ptr [rbx] + movsxd rdx, dword ptr [rbx] end @@ -535,10 +543,14 @@ end // ; loads inline % 14h - mov edx, dword ptr [rbx] - shr edx, ACTION_ORDER - mov rax, mdata : %0 - mov edx, dword ptr [rax + rdx] + mov edx, dword ptr [rbx] + shr edx, ACTION_ORDER + mov rax, mdata : %0 + lea rsi, [rdx*8] + mov ecx, dword ptr [rax + rsi * 2] + test ecx, ecx + cmovnz edx, ecx + shl edx, ACTION_ORDER end @@ -745,6 +757,13 @@ inline %02Ch end +// ; parent +inline %02Dh + + mov rbx, [rbx - elPackageOffset] + +end + // ; xget inline %02Eh @@ -894,8 +913,9 @@ end // ; fabsdp inline %078h + mov rax, r10 lea rdi, [rbp + __arg32_1] - fld qword ptr [rsi] + fld qword ptr [rax] fabs fstp qword ptr [rdi] // ; store result @@ -904,8 +924,9 @@ end // ; fsqrtdp inline %079h + mov rax, r10 lea rdi, [rbp + __arg32_1] - fld qword ptr [rsi] + fld qword ptr [rax] fsqrt fstp qword ptr [rdi] // ; store result @@ -914,8 +935,9 @@ end // ; fexpdp inline %07Ah + mov rax, r10 lea rdi, [rbp + __arg32_1] - fld qword ptr [rsi] + fld qword ptr [rax] xor edx, edx fldl2e // ; ->log2(e) @@ -959,8 +981,9 @@ end // ; flndp inline %07Bh + mov rax, r10 lea rdi, [rbp + __arg32_1] - fld qword ptr [rsi] + fld qword ptr [rax] fldln2 fxch @@ -984,8 +1007,9 @@ end // ; fsindp inline %07Ch + mov rax, r10 lea rdi, [rbp + __arg32_1] - fld qword ptr [rsi] + fld qword ptr [rax] fldpi fadd st(0),st(0) // ; ->2pi fxch @@ -1007,8 +1031,9 @@ end // ; fcosdp inline %07Dh + mov rax, r10 lea rdi, [rbp + __arg32_1] - fld qword ptr [rsi] + fld qword ptr [rax] fcos fstp qword ptr [rdi] // ; store result @@ -1017,8 +1042,9 @@ end // ; farctandp inline %07Eh + mov rax, r10 lea rdi, [rbp + __arg32_1] - fld qword ptr [rsi] + fld qword ptr [rax] fld1 fpatan // i.e. arctan(Src/1) fstp qword ptr [rdi] // ; store result @@ -1204,7 +1230,7 @@ end // ; loaddp inline %8Ah - mov edx, dword ptr [rbp + __arg32_1] + movsxd rdx, dword ptr [rbp + __arg32_1] end @@ -1219,14 +1245,14 @@ end // ; subn inline %8Ch - sub edx, __n_1 + sub rdx, __n_1 end // ; addn inline %8Dh - add edx, __n_1 + add rdx, __n_1 end @@ -1504,9 +1530,10 @@ end inline %09Fh lea rdi, [rbp + __arg32_1] + mov rax, r10 mov ecx, 0 - fld qword ptr [rsi] + fld qword ptr [rax] push rcx // reserve space on stack fstcw word ptr [rsp] // get current control word @@ -2032,8 +2059,7 @@ end // ; loadsi inline %0CCh - mov rax, [rsp + __arg32_1] - mov edx, eax + movsxd rdx, dword ptr [rsp + __arg32_1] end @@ -2051,41 +2077,13 @@ inline %2CCh end -// ; xloadargfi +// ; xloadarg fi inline %0CDh mov rdx, qword ptr [rbp + __arg32_1] end -// ; xloadarg si:1 -inline %1CDh - - mov rdx, rdi - -end - -// ; xloadarg si:2 -inline %2CDh - - mov rdx, rsi - -end - -// ; xloadarg si:3 -inline %3CDh - - // ; mov rdx, rdx - idle operation - -end - -// ; xloadarg si:4 -inline %4CDh - - mov rdx, rcx - -end - // ; xcreater r inline %0CEh @@ -2143,9 +2141,11 @@ inline %5CFh pop rsi + // ; align to make it 10h alignment + add rdx, 1 + and rdx, 0FFFFFFFEh + lea rax, [rdx*8] - add eax, 8 - and eax, 0FFFFFFF0h sub rsp, rax mov rcx, rdx xor rax, rax @@ -2812,41 +2812,59 @@ inline %0F0h end -// ; openin 0, 0 +// ; openin 0, n inline %1F0h push rbp + xor rax, rax + mov rbp, rsp + sub rsp, __n_2 + push rbp + push rax mov rbp, rsp end -// ; openin 1, 0 +// ; openin 1, n inline %2F0h push rbp + xor rax, rax mov rbp, rsp - push 0 - push 0 + sub rsp, __n_2 + push rbp + push rax + mov rbp, rsp + push rax + push rax end -// ; openin 2, 0 +// ; openin 2, n inline %3F0h push rbp xor rax, rax mov rbp, rsp + sub rsp, __n_2 + push rbp + push rax + mov rbp, rsp push rax push rax end -// ; openin 3, 0 +// ; openin 3, n inline %4F0h push rbp xor rax, rax mov rbp, rsp + sub rsp, __n_2 + push rbp + push rax + mov rbp, rsp push rax push rax push rax @@ -2854,7 +2872,7 @@ inline %4F0h end -// ; openin 0, n +// ; openin 4, n inline %5F0h push rbp @@ -2864,6 +2882,10 @@ inline %5F0h push rbp push rax mov rbp, rsp + push rax + push rax + push rax + push rax end @@ -2880,6 +2902,61 @@ inline %6F0h end +// ; openin 0, 0 +inline %7F0h + + push rbp + mov rbp, rsp + +end + +// ; openin 1, 0 +inline %8F0h + + push rbp + mov rbp, rsp + push 0 + push 0 + +end + +// ; openin 2, 0 +inline %9F0h + + push rbp + xor rax, rax + mov rbp, rsp + push rax + push rax + +end + +// ; openin 3, 0 +inline %0AF0h + + push rbp + xor rax, rax + mov rbp, rsp + push rax + push rax + push rax + push rax + +end + +// ; openin 4, 0 +inline %0BF0h + + push rbp + xor rax, rax + mov rbp, rsp + push rax + push rax + push rax + push rax + +end + // ; xstoresir inline %0F1h @@ -2933,11 +3010,17 @@ end // ; extopenin inline %0F2h + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - push 0 + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + mov rbp, rax xor eax, eax - mov rbp, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] push rbp push rax mov rbp, rsp @@ -2956,49 +3039,78 @@ inline %0F2h end -// ; extopenin 0, 0 +// ; extopenin 0, n inline %1F2h + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - push 0 + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + mov rbp, rax xor eax, eax - mov rbp, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] push rbp push rax mov rbp, rsp push rbp + xor rax, rax + mov rbp, rsp + sub rsp, __n_2 + push rbp + push rax mov rbp, rsp end -// ; extopenin 1, 0 +// ; extopenin 1, n inline %2F2h + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - push 0 + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + mov rbp, rax xor eax, eax - mov rbp, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] push rbp push rax mov rbp, rsp push rbp + xor rax, rax mov rbp, rsp - push 0 + sub rsp, __n_2 + push rbp + push rax + mov rbp, rsp + push rax + push rax end -// ; extopenin 2, 0 +// ; extopenin 2, n inline %3F2h + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - push 0 + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + mov rbp, rax xor eax, eax - mov rbp, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] push rbp push rax mov rbp, rsp @@ -3006,19 +3118,29 @@ inline %3F2h push rbp xor rax, rax mov rbp, rsp + sub rsp, __n_2 + push rbp + push rax + mov rbp, rsp push rax push rax end -// ; extopenin 3, 0 +// ; extopenin 3, n inline %4F2h + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - push 0 + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + mov rbp, rax xor eax, eax - mov rbp, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] push rbp push rax mov rbp, rsp @@ -3026,20 +3148,31 @@ inline %4F2h push rbp xor rax, rax mov rbp, rsp + sub rsp, __n_2 + push rbp + push rax + mov rbp, rsp + push rax push rax push rax push rax end -// ; extopenin 0, n +// ; extopenin 4, n inline %5F2h + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - push 0 + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + mov rbp, rax xor eax, eax - mov rbp, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] push rbp push rax mov rbp, rsp @@ -3051,17 +3184,27 @@ inline %5F2h push rbp push rax mov rbp, rsp + push rax + push rax + push rax + push rax end // ; extopenin i, 0 inline %6F2h + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - push 0 + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + mov rbp, rax xor eax, eax - mov rbp, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] push rbp push rax mov rbp, rsp @@ -3076,6 +3219,136 @@ inline %6F2h end +// ; extopenin 0, 0 +inline %7F2h + + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + + push rbp + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + + mov rbp, rax + xor eax, eax + push rbp + push rax + mov rbp, rsp + + push rbp + mov rbp, rsp + +end + +// ; extopenin 1, 0 +inline %8F2h + + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + + push rbp + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + + mov rbp, rax + xor eax, eax + push rbp + push rax + mov rbp, rsp + + push rbp + mov rbp, rsp + push 0 + push 0 + +end + +// ; extopenin 2, 0 +inline %9F2h + + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + + push rbp + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + + mov rbp, rax + xor eax, eax + push rbp + push rax + mov rbp, rsp + + push rbp + xor rax, rax + mov rbp, rsp + push rax + push rax + +end + +// ; extopenin 3, 0 +inline %0AF2h + + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + + push rbp + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + + mov rbp, rax + xor eax, eax + push rbp + push rax + mov rbp, rsp + + push rbp + xor rax, rax + mov rbp, rsp + push rax + push rax + push rax + push rax + +end + +// ; extopenin 4, 0 +inline %0BF2h + + mov [rsp+8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + + push rbp + mov rax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push rax + + mov rbp, rax + xor eax, eax + push rbp + push rax + mov rbp, rsp + + push rbp + xor rax, rax + mov rbp, rsp + push rax + push rax + push rax + push rax + +end + // ; movsifi inline %0F3h @@ -3216,6 +3489,82 @@ inline % 1F8h end +// ; fill 1, r +inline % 2F8h + + mov rax, __ptr64_2 + mov [rbx], rax + +end + +// ; fill 1, 0 +inline % 3F8h + + xor rax, rax + mov [rbx], rax + +end + +// ; fill 2, r +inline % 4F8h + + mov rax, __ptr64_2 + mov [rbx], rax + mov [rbx+8], rax + +end + +// ; fill 2, 0 +inline % 5F8h + + xor eax, eax + mov [rbx], rax + mov [rbx+8], rax + +end + +// ; fill 3, r +inline % 6F8h + + mov rax, __ptr64_2 + mov [rbx], rax + mov [rbx+8], rax + mov [rbx+16], rax + +end + +// ; fill 3, 0 +inline % 7F8h + + xor eax, eax + mov [rbx], rax + mov [rbx+16], rax + mov [rbx+24], rax + +end + +// ; fill 4, r +inline % 8F8h + + mov rax, __ptr64_2 + mov [rbx], rax + mov [rbx+8], rax + mov [rbx+16], rax + mov [rbx+24], rax + +end + +// ; fill 4, 0 +inline % 9F8h + + xor eax, eax + mov [rbx], rax + mov [rbx+8], rax + mov [rbx+16], rax + mov [rbx+24], rax + +end + // ; xstorefir inline %0F9h @@ -3373,7 +3722,90 @@ end // ; NOTE : __arg32_1 - message; __n_1 - arg count; __ptr32_2 - list, __n_2 - argument list offset inline % 9FAh -//; !! temporally commented + mov r8, rbx // r8 -> [esp] + mov [rsp+8], r10 // ; saving arg0 + lea rax, [rsp] + mov [rsp+16], r11 // ; saving arg1 + + mov ecx, __n_1 + mov r11, rcx // r11 -> [esp+8] + mov r12, rdx // r12 -> [esp+4] + + mov rsi, [rbx + rcx * 8] // ; get next overload list + test rsi, rsi + jz labEnd + +labNextList: + xor edx, edx + mov rbx, [rsi] // ; message from overload list + +labNextOverloadlist: + mov r9, mdata : %0 + shr ebx, ACTION_ORDER + lea r13, [rbx*8] + mov r13, [r9 + r13 * 2 + 8] + and ecx, ARG_MASK + lea rbx, [r13 - 8] + add ecx, 1 + +labNextParam: + sub ecx, 1 + jnz short labMatching + + mov rcx, r11 + mov rbx, r8 + mov r9, [rbx + rcx * 8] // ; get next overload list + + lea r13, [rdx * 8] + mov rax, [r9 + r13 * 2 + 8] + mov rdx, [r9 + r13 * 2] + mov r10, [rsp+8] // ; restore arg0 + mov r11, [rsp+16] // ; restore arg1 + jmp rax + +labMatching: + mov rdi, [rax + rcx * 8] + + //; check nil + mov rsi, rdata : %VOIDPTR + elObjectOffset + test rdi, rdi + cmovz rdi, rsi + + mov rdi, [rdi - elVMTOffset] + mov rsi, [rbx + rcx * 8] + +labNextBaseClass: + cmp rsi, rdi + jz labNextParam + mov rdi, [rdi - elPackageOffset] + and rdi, rdi + jnz short labNextBaseClass + + mov rcx, r11 + mov rbx, r8 + mov r13, [rbx + rcx * 8] // ; get next overload list + add edx, 1 + + lea r9, [rdx * 8] + mov rbx, [r13 + r9 * 2] // ; message from overload list + + and rbx, rbx + jnz labNextOverloadlist + + lea r11, [r11 + 1] + mov rcx, r11 + mov rbx, r8 + + mov rsi, [rbx + rcx * 8] // ; get next overload list + test rsi, rsi + jnz labNextList + +labEnd: + mov rbx, r8 + mov rdx, r12 + + mov r10, [rsp+8] // ; restore arg0 + mov r11, [rsp+16] // ; restore arg1 end @@ -3381,7 +3813,109 @@ end // ; NOTE : __arg32_1 - variadic message; __n_1 - arg count; __ptr32_2 - list, __n_2 - argument list offset inline % 0AFAh -//; !! temporally commented + mov [rsp+8], r10 // ; saving arg0 + lea rax, [rsp + __n_2] + mov [rsp+16], r11 // ; saving arg1 + + mov r10, __n_1 // [esp+12] + mov r11, rbx // [esp] + xor ecx, ecx + mov r12, rcx // [esp+8] + mov r9, rcx // [esp+4] + mov r14, rdx // [esp+16] + + // ; count the number of args + mov rbx, rax + mov r8, -1 +labCountParam: + lea rbx, [rbx+8] + cmp r8, [rbx] + lea rcx, [rcx+1] + jnz short labCountParam + mov r9, rcx + + mov rbx, r11 + mov rcx, r10 + mov rsi, [rbx + rcx * 8] // ; get next overload list + test rsi, rsi + jz labEnd + +labNextList: + xor rdx, rdx + mov rbx, [rsi] // ; message from overload list + +labNextOverloadlist: + mov r8, mdata : %0 + shr ebx, ACTION_ORDER + lea r13, [rbx*8] + mov rbx, [r8 + r13 * 2 + 8] + + lea rbx, [rbx - 8] + mov r12, rbx + +labNextParam: + add ecx, 1 + cmp rcx, r9 + jnz short labMatching + + mov rcx, r10 + mov rbx, r11 + mov r8, [rbx + rcx * 8] // ; get next overload list + lea r13, [rdx * 8] + mov rax, [r8 + r13 * 2 + 8] + mov rdx, [r8 + r13 * 2] + mov r10, [rsp+8] // ; restore arg0 + mov r11, [rsp+16] // ; restore arg1 + jmp rax + +labMatching: + mov rsi, r12 + lea rdi, [rsi + 8] + cmp [rdi], 0 + cmovnz rsi, rdi + mov r12, rsi + + mov rdi, [rax + rcx * 8] + + //; check nil + mov rsi, rdata : %VOIDPTR + elObjectOffset + test rdi, rdi + cmovz rdi, rsi + + mov rdi, [rdi - elVMTOffset] + mov rsi, r12 + mov rsi, [rsi] + +labNextBaseClass: + cmp rsi, rdi + jz labNextParam + mov rdi, [rdi - elPackageOffset] + and rdi, rdi + jnz short labNextBaseClass + + mov rcx, r10 + mov rbx, r11 + mov r8, [rbx + rcx * 8] + add edx, 1 + lea r13, [rdx * 8] + mov rbx, [r8 + r13 * 2] // ; message from overload list + and rbx, rbx + jnz labNextOverloadlist + + lea r10, [r10 + 1] + mov rbx, r11 + mov rcx, r10 + + mov rsi, [rbx + rcx * 8] // ; get next overload list + test rsi, rsi + jnz labNextList + +labEnd: + mov rbx, r11 + mov rdx, r14 + + mov r10, [rsp+8] // ; restore arg0 + mov r11, [rsp+16] // ; restore arg1 end diff --git a/asm/amd64/core_win.asm b/asm/amd64/core_win.asm deleted file mode 100644 index 5d7682bd5a..0000000000 --- a/asm/amd64/core_win.asm +++ /dev/null @@ -1,88 +0,0 @@ -// !! NOTE : ELENA 64 will not maintain 16 byte stack alignment due to the current call conventions -// and some language features (like a command tape). -// The alignment will be maintained only for external operations - -// !! NOTE : R15 register must be preserved - -// --- Predefined References -- -define GC_ALLOC 10001h -define HOOK 10010h -define INVOKER 10011h -define INIT_RND 10012h -define INIT_ET 10015h -define ENDFRAME 10016h -define RESTORE_ET 10017h -define OPENFRAME 10019h -define CLOSEFRAME 1001Ah -define LOCK 10021h -define UNLOCK 10022h -define LOAD_CALLSTACK 10024h - -//R12, R13, R14, and R15 - -// INVOKER(prevFrame, function, arg) -procedure % INVOKER - - // ; RCX - prevFrame - // ; RDX - function - // ; R8 - arg - - // ; save registers - push 0 - push rsi - push rdi - push rbx - push rbp - push r12 - push r13 - push r14 - push r15 - - // declare new frame - push rcx // ; FrameHeader.previousFrame - mov rax, rdx - push 0 // ; FrameHeader.reserved - mov rbp, rsp // ; FrameHeader - push r8 // ; arg - - call rax - add rsp, 24 // ; clear FrameHeader+arg - - // ; restore registers - pop r15 - pop r14 - pop r13 - pop r12 - pop rbp - pop rbx - pop rdi - pop rsi - add rsp, 4 - ret - -end - -procedure % INIT_RND - - sub rsp, 8h - mov rax, rsp - sub rsp, 10h - lea rbx, [rsp] - push rax - push rbx - push rbx - mov rcx, [rsp] - sub rsp, 18h - call extern 'dlls'KERNEL32.GetSystemTime - add rsp, 20h - - mov rcx, [rsp] - mov rdx, [rsp+8] - sub rsp, 10h - call extern 'dlls'KERNEL32.SystemTimeToFileTime - add rsp, 30h - - pop rax - ret - -end diff --git a/asm/amd64/coreapi.asm b/asm/amd64/coreapi.asm deleted file mode 100644 index e8bf3ce112..0000000000 --- a/asm/amd64/coreapi.asm +++ /dev/null @@ -1,4670 +0,0 @@ -// !! NOTE : R15 register must be preserved - -define INIT_RND 10012h - -// Object header fields -define elSizeOffset 0004h -define elVMTOffset 0010h -define elObjectOffset 0010h - -// ; --- API --- - -// wsubcopyz(target,index,size,arr) -procedure coreapi'core_wsubcopyz - - mov rax, [rsp+32] - mov rcx, [rsp+24] - mov rsi, [rsp+8] - mov rbx, [rsp+16] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, dword ptr [rax + rbx*2] - mov word ptr [rsi], dx - add ebx, 1 - lea rsi, [rsi + 2] - sub ecx, 1 - jnz short labNext - mov word ptr [rsi], cx - -labEnd: - ret - -end - -// subcopyz(target,index,size,arr) -procedure coreapi'core_subcopyz - - mov rax, [rsp+32] - mov rcx, [rsp+24] - mov rsi, [rsp+8] - mov rbx, [rsp+16] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, dword ptr [rax + rbx] - mov byte ptr [rsi], dl - add rbx, 1 - add rsi, 1 - sub ecx, 1 - jnz short labNext - mov byte ptr [rsi], cl - -labEnd: - ret - -end - -// ; insert(dest,sour,index,size) -procedure coreapi'core_insert - - mov rcx, [rsp+32] - mov rdi, [rsp+8] - mov rbx, [rsp+24] - mov rsi, [rsp+16] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, dword ptr [rsi] - mov byte ptr [rdi + rbx], dl - add ebx, 1 - lea rsi, [rsi + 1] - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -// winsert(target,source,index,len) -procedure coreapi'core_winsert - - mov rbx, [rsp+24] - mov rcx, [rsp+32] - mov rdi, [rsp+8] - mov rsi, [rsp+16] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, dword ptr [rsi] - mov word ptr [rdi + rbx*2], dx - add ebx, 1 - lea rsi, [rsi + 2] - sub ecx, 1 - jnz short labNext - -labEnd: - mov edx, ecx - mov ebx, edi - ret - -end - -// ; sadd(dest,sour,sindex,dindex) -procedure coreapi'core_sadd - - mov rcx, [rsp+24] - mov rax, [rsp+16] - mov rdx, [rsp+32] - mov rdi, [rsp+8] - - mov esi, ecx // ; src index - - mov ebx, dword ptr[rax-elSizeOffset] - and ebx, 0FFFFFh - add edx, edi - sub ecx, ebx - add esi, eax - -labNext2: - mov ebx, dword ptr[rsi] - mov byte ptr [rdx], bl - lea rsi, [rsi+1] - lea rdx, [rdx+1] - add ecx, 1 - jnz short labNext2 - - ret - -end - -// ; wadd(dest,sour,sindex,dindex) -procedure coreapi'core_wadd - - mov rcx, [rsp+24] // - mov rax, [rsp+16] // ; src - mov rbx, [rsp+32] // ; dindex - mov rdi, [rsp+8] // ; dst - - shl ebx, 1 - shl ecx, 1 - - mov edx, ebx // ; dst index - mov esi, ecx // ; src index - - mov ebx, dword ptr [rax-elSizeOffset] - and ebx, 0FFFFFh - - add rdx, rdi - sub rcx, rbx - add rsi, rax - -labNext2: - mov ebx, dword ptr [rsi] - mov word ptr [rdx], bx - lea rsi, [rsi+2] - lea rdx, [rdx+2] - add ecx, 2 - jnz short labNext2 - - ret - -end - -// sseek(s,subs,index,len) -procedure coreapi'core_sseek - - mov rdi, [rsp+8] // s - mov rdx, [rsp+24] - mov rsi, [rsp+16] // subs - - mov ebx, dword ptr[rdi-elSizeOffset] // get total length - and ebx, 0FFFFFh - - sub ebx, edx - jbe short labEnd - - add ebx, 1 - sub edx, 1 - -labNext: - add edx, 1 - mov ecx, dword ptr [rsp+32] - sub ebx, 1 - jz short labEnd - cmp ebx, ecx - jb short labEnd - mov rdi, [rsp+8] - add rdi, rdx - -labCheck: - mov eax, dword ptr [rdi] - cmp al, byte ptr [rsi] - jnz short labNext - lea rdi, [rdi+1] - lea rsi, [rsi+1] - sub ecx, 1 - jnz short labCheck - nop - nop - jmp short labEnd2 - -labEnd: - mov edx, -1 -labEnd2: - ret - -end - -// wseek(s,subs,index,len) -procedure coreapi'core_wseek - - mov rdi, [rsp+8] // s - mov rdx, [rsp+24] - mov rsi, [rsp+16] // subs - - mov ebx, dword ptr [rdi-elSizeOffset] // get total length - and ebx, 0FFFFFh - - shl edx, 1 - sub ebx, edx - jbe short labEnd - - add ebx, 2 - sub edx, 2 - -labNext: - add edx, 2 - mov ecx, dword ptr [rsp+32] - sub ebx, 2 - jz short labEnd - shl ecx, 1 - cmp ebx, ecx - jb short labEnd - mov rdi, [rsp+8] - add rdi, rdx - -labCheck: - mov eax, dword ptr [rdi] - cmp ax, word ptr [rsi] - jnz short labNext - lea rdi, [rdi+2] - lea rsi, [rsi+2] - sub ecx, 2 - jnz short labCheck - shr edx, 1 - jmp short labEnd2 - -labEnd: - mov edx, -1 -labEnd2: - ret - -end - -// ; strtochar(index,str; ebx = 0 if err ; edx - out) -procedure coreapi'core_strtochar - - mov rbx, [rsp+8] - mov rax, [rsp+16] - - xor edx, edx - mov dl, byte ptr [rax + rbx] - cmp edx, 00000080h - jl short lab1 - cmp edx, 000000C0h - jl short err - cmp edx, 000000E0h - jl short lab2 - cmp edx, 000000F0h - jl short lab3 - cmp edx, 000000F8h - jl lab4 - -err: - xor ebx, ebx - ret - -lab1: - mov ebx, eax - ret - -lab2: - mov ecx, edx - mov dl, byte ptr [rax + rbx + 1] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - shl ecx, 6 - add edx, ecx - sub edx, 3080h - mov rbx, rax - ret - -lab3: - mov ecx, edx - mov dl, byte ptr [rax + rbx + 1] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - cmp ecx, 000000E0h - jnz short lab3_1 - cmp ebx, 000000A0h - jl short err - -lab3_1: - shl ecx, 12 - shl edx, 6 - add ecx, edx - xor edx, edx - mov dl, byte ptr [rax + rbx + 2] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - add edx, ecx - sub edx, 0E2080h - mov ebx, eax - ret - -lab4: - mov ecx, edx - mov dl, byte ptr [rax + rbx + 1] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - cmp ecx, 000000F0h - jnz short lab4_1 - cmp edx, 00000090h - jl short err - -lab4_1: - cmp ecx, 000000F4h - jnz short lab4_2 - cmp edx, 00000090h - jae short err - -lab4_2: - shl ecx, 18 - shl edx, 12 - add ecx, edx - - xor edx, edx - mov dl, byte ptr [rax + rbx + 2] - mov esi, edx - and esi, 000000C0h - cmp esi, 00000080h - jnz err - - shl edx, 6 - add ecx, edx - - xor edx, edx - mov dl, byte ptr [rax + rbx + 3] - mov esi, edx - and esi, 000000C0h - cmp esi, 00000080h - jnz err - - add edx, ecx - sub edx, 3C82080h - mov ebx, eax - ret - -end - -// ; wstrtochar(index,str; ebx = 0 if err ; edx - out) -procedure coreapi'core_wstrtochar - - mov rbx, [rsp+8] - mov rax, [rsp+16] - - mov esi, dword ptr [rax + rbx * 2] - and esi, 0FFFFh - cmp esi, 0D800h - jl short lab1 - cmp esi, 0DBFFh - jg short err - - mov ecx, esi - shl ecx, 10 - mov esi, dword ptr [rax + rbx * 2 + 2] - and esi, 0FFFFh - cmp esi, 0DC00h - jl short lab2 - cmp esi, 0DFFFh - jg short err - -lab2: - mov edx, ecx - mov rbx, [rsp+8] - add edx, ebx - sub edx, 35FDC00h - ret - -lab1: - mov rbx, [rsp+16] - mov edx, esi - ret - -err: - xor ebx, ebx - ret - -end - -// ; slen_ch - ecx - len, eax - charr, esi - result -procedure coreapi'core_slen_ch - - mov rax, [rsp+24] - mov rcx, [rsp+16] - mov rdx, [rsp+8] - mov rdi, [rsp+32] - lea rax, [rax+rdx*4] - - xor ebx, ebx - test ecx, ecx - jz short labEnd - -labNext: - mov edx, dword ptr[rax] - cmp edx, 00000080h - jl short lab1 - cmp edx, 0800h - jl short lab2 - cmp edx, 10000h - jl short lab3 - - add ebx, 4 - lea rax, [rax + 4] - sub ecx, 1 - jnz short labNext -labEnd: - mov dword ptr[rdi], ebx - ret - -lab1: - add ebx, 1 - lea rax, [rax + 4] - sub ecx, 1 - jnz short labNext - mov dword ptr [rdi], ebx - ret - -lab2: - add ebx, 2 - lea rax, [rax + 4] - sub ecx, 1 - jnz short labNext - mov dword ptr[rdi], ebx - ret - -lab3: - add ebx, 3 - lea rax, [rax + 4] - sub ecx, 1 - jnz short labNext - mov dword ptr[rdi], ebx - ret - -end - -// ; wslen_ch - ecx - len, eax - charr, esi - result -procedure coreapi'core_wslen_ch - - mov rax, [rsp+24] - mov rcx, [rsp+16] - mov rdx, [rsp+8] - mov rdi, [rsp+32] - lea rax, [rax+rdx*4] - - xor ebx, ebx - test ecx, ecx - jz short labEnd - -labNext: - mov edx, dword ptr [rax] - cmp edx, 010000h - jl short lab1 - - add ebx, 2 - lea rax, [rax + 4] - sub ecx, 1 - jnz short labNext -labEnd: - mov dword ptr[rdi], ebx - ret - -lab1: - add ebx, 1 - lea rax, [rax + 4] - sub ecx, 1 - jnz short labNext - mov dword ptr[rdi], ebx - ret - -end - -procedure coreapi'core_scopychars - - mov rax, [rsp+32] - mov rcx, [rsp+24] - mov rbx, [rsp+16] - mov rdi, [rsp+8] - - test ecx, ecx - jz labEnd - - lea rsi, [rax + rbx * 4] - -labNext: - mov ebx, dword ptr [rsi] - - cmp ebx, 00000080h - jl short labs1 - cmp ebx, 0800h - jl short labs2 - cmp ebx, 10000h - jl short labs3 - - mov edx, ebx - shr edx, 18 - add edx, 000000F0h - mov byte ptr [rdi], dl - add rdi, 1 - - mov edx, ebx - shr edx, 12 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add rdi, 1 - - mov edx, ebx - shr edx, 6 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add rdi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add rdi, 1 - jmp labSave - -labs2: - mov edx, ebx - shr edx, 6 - add edx, 000000C0h - mov byte ptr [rdi], dl - add rdi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add rdi, 1 - jmp short labSave - -labs3: - mov edx, ebx - shr edx, 12 - add edx, 000000E0h - mov byte ptr [rdi], dl - add rdi, 1 - - mov edx, ebx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add rdi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add rdi, 1 - jmp short labSave - -labs1: - mov byte ptr [rdi], bl - add rdi, 1 - -labSave: - lea rsi, [rsi + 4] - sub ecx, 1 - jnz labNext - -labEnd: - mov rdx, rdi - mov rdi, [rsp+18] - sub rdx, rdi - - ret - -end - -procedure coreapi'core_wscopychars - - mov rax, [rsp+32] - mov rcx, [rsp+24] - mov rbx, [rsp+16] - mov rdi, [rsp+8] - - test ecx, ecx - jz labEnd - - lea rsi, [rax + rbx * 4] - -labNext: - mov ebx, dword ptr [rsi] - cmp ebx, 010000h - jl short lab1 - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [rdi], dx - add edi, 2 - - and ebx, 03FFh - add ebx, 0DC00h - -lab1: - mov word ptr [rdi], bx - add edi, 2 - lea rsi, [rsi + 4] - sub ecx, 1 - jnz short labNext - -labEnd: - mov rbx, rdi - pop rdi - sub rbx, rdi - shr ebx, 1 - - ret - -end - -// ; inttostr(s,b,t,out) -procedure coreapi'core_inttostr - - mov rsi, [rsp+16] - mov rax, [rsp+8] - mov rdi, [rsp+24] - - push rbp - mov rbp, rsp - xor ecx, ecx - push rax - // ; take sign into account only for the decimal representation - cmp esi, 10 - jnz short Lab6 - cmp eax, 0 - jns short Lab6 - neg eax -Lab6: - cmp eax, esi - jb short Lab5 -Lab1: - xor edx, edx - idiv esi - push rdx - add ecx, 1 - cmp eax, esi - jae short Lab1 -Lab5: - add ecx, 2 - push rax - cmp esi, 10 - jnz short Lab7 - mov rax, [rbp-8] - cmp eax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 1 -Lab7: - sub ecx, 1 - mov esi, edi - mov edx, 0FFh -Lab2: - pop rax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov byte ptr [rsi], al - add esi, 1 - sub ecx, 1 - jnz short Lab2 - mov edx, esi - sub edx, edi - lea rsp, [rsp+8] - pop rbp - mov rdi, [rsp+32] - mov dword ptr [rdi], edx - - ret - -end - -procedure coreapi'core_inttowstr - - mov rsi, [rsp+16] - mov rax, [rsp+8] - mov rdi, [rsp+24] - - push rbp - mov rbp, rsp - xor ecx, ecx - push rax - cmp eax, 0 - jns short Lab6 - neg eax -Lab6: - cmp eax, ebx - jb short Lab5 -Lab1: - xor edx, edx - idiv ebx - push rdx - add ecx, 2 - cmp eax, ebx - jae short Lab1 -Lab5: - add ecx, 4 - push rax - mov eax, dword ptr[rbp-8] - cmp eax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 2 -Lab7: - mov esi, edi - mov edx, 0FFh - sub ecx, 2 // to skip zero -Lab2: - pop rax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov word ptr [rsi], ax - add esi, 2 - sub ecx, 2 - jnz short Lab2 - mov ecx, esi - sub ecx, edi - shr ecx, 1 - lea rsp, [rsp+8] - pop rbp - - ret - -end - -// ; uinttostr(s,b,t) -procedure coreapi'core_uinttostr - - mov rsi, [rsp+16] - mov rax, [rsp+8] - mov rdi, [rsp+24] - - push rbp - mov rbp, rsp - xor ecx, ecx - - cmp eax, esi - jb short Lab5 -Lab1: - xor edx, edx - idiv esi - push rdx - add ecx, 1 - cmp eax, esi - jae short Lab1 -Lab5: - add ecx, 2 - push rax - sub ecx, 1 - mov esi, edi - mov edx, 0FFh -Lab2: - pop rax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov byte ptr [rsi], al - add rsi, 1 - sub ecx, 1 - jnz short Lab2 - mov rdx, rsi - sub rdx, rdi - pop rbp - - ret - -end - -procedure coreapi'core_uinttowstr - - mov rsi, [rsp+16] - mov rax, [rsp+8] - mov rdi, [rsp+24] - - push rbp - mov rbp, rsp - xor ecx, ecx - cmp eax, ebx - jb short Lab5 -Lab1: - xor edx, edx - idiv ebx - push rdx - add ecx, 2 - cmp eax, ebx - jae short Lab1 -Lab5: - add ecx, 4 - push rax - mov esi, edi - mov edx, 0FFh - sub ecx, 2 // to skip zero -Lab2: - pop rax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov word ptr [rsi], ax - add esi, 2 - sub ecx, 2 - jnz short Lab2 - mov ecx, esi - sub ecx, edi - shr ecx, 1 - pop rbp - - ret - -end - -// --- System Core API -- - -define CORE_ET_TABLE 2000Bh - -// ; initProcess(frameHeader) -procedure coreapi'initProcess - - finit - lea rdx, [rsp+10h] - mov rax, [rsp+8] - mov [rax+8], rdx - mov [rax+10h], rbp - ret - -end - -// ; initThread(frameHeader) -procedure coreapi'initThread - - lea rdx, [rsp+10h] - mov rax, [rsp+8] - mov [rax+8], rdx - mov [rax+10h], rbp - ret - -end - -//procedure coreapi'seh_handler -// -// push rbp -// mov rbp, rsp -// // ;** now [EBP+8]=pointer to EXCEPTION_RECORD -// // ;** [EBP+0Ch]=pointer to ERR structure -// // ;** [EBP+10h]=pointer to CONTEXT record -// push rbx -// push rdi -// push rsi -// mov rbx, [rbp+16] -// test rbx, rbx -// jz short lab5 -// test qword ptr[rbx+8],1h -// jnz lab5 -// test qword ptr[rbx+8],2h -// jz lab2 -// //; ... -// //; ... -// //; ... -// jmp lab5 -//lab2: -// //; PUSH 0 -// //; PUSH [EBP+8h] -// //; PUSH ADDR UN23 -// //; PUSH [EBP+0Ch] -// //; CALL RtlUnwind -// //; UN23: -// mov rsi, [rbp + 20h] -// //; MOV EDX,[EBP+0Ch] -////; MOV [ESI+0C4h],EDX // ; esp -// -// // ; get critical exception handler -// mov rax, [data : % CORE_ET_TABLE] -// mov [rsi+0B8h], rax // ; eip -// -// //; MOV EAX,[EDX+14h] -// //; MOV [ESI+0B4h],EAX // ; ebp -// xor rax, rax -// jmp short lab6 -//lab5: -// mov rax, 1 -//lab6: -// pop rsi -// pop rdi -// pop rbx -// mov rsp, rbp -// pop rbp -// ret -//end - -procedure coreapi'veh_handler - - push rdx - push rbp - mov rbp, rsp - mov rdx, rax // ; set exception code - mov rax, [data : % CORE_ET_TABLE] - jmp rax - -end - -procedure coreapi'default_handler - - // ; exit code - push 0 - call extern 'rt_dlls.Exit - -end - -// ; === internal === - -// strtowstr(target,source) -procedure coreapi'strtowstr - - mov rax, [rsp+16] - mov rdi, [rsp+8] - mov esi, dword ptr [rax - elSizeOffset] - and esi, 0FFFFFh - sub esi, 1 - jz labEnd - -labNext: - - xor ebx, ebx - mov bl, byte ptr [rax] - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 000000E0h - jl short lab2 - cmp ebx, 000000F0h - jl short lab3 - - mov ecx, ebx - shl ecx, 18 - - lea rax, [rax + 1] - sub esi, 1 - mov bl, byte ptr [rax] - shl ebx, 12 - add ecx, ebx - - xor ebx, ebx - lea rax, [rax + 1] - sub esi, 1 - mov bl, byte ptr [rax] - shl ebx, 6 - add ecx, ebx - - xor ebx, ebx - lea rax, [rax + 1] - sub esi, 1 - mov bl, byte ptr [rax] - add ecx, ebx - sub ecx, 3C82080h - jmp short labCont - -lab2: - mov ecx, ebx - shl ecx, 6 - - lea rax, [rax + 1] - sub esi, 1 - mov bl, byte ptr [rax] - add ecx, ebx - sub ecx, 3080h - jmp short labCont - -lab3: - mov ecx, ebx - shl ecx, 12 - - lea rax, [rax + 1] - sub esi, 1 - mov bl, byte ptr [rax] - shl ebx, 6 - add ecx, ebx - - xor ebx, ebx - lea rax, [rax + 1] - sub esi, 1 - mov bl, byte ptr [rax] - add ecx, ebx - sub ecx, 0E2080h - jmp short labCont - -lab1: - mov ecx, ebx - -labCont: - cmp ecx, 010000h - jl short labw1 - - mov edx, ecx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [rdi], dx - add edi, 2 - - and ecx, 03FFh - add ecx, 0DC00h - -labw1: - mov word ptr [rdi], ecx - add edi, 2 - - lea rax, [rax + 1] - sub esi, 1 - jnz labNext -labEnd: - mov rbx, [rsp+8] - mov edx, edi - sub edx, ebx - shr edx, 1 - ret - -end - -// strtowstr(target,source) -procedure coreapi'wstrtostr - - mov rax, [rsp+16] - mov rdi, [rsp+8] - mov esi, dword ptr [rax - elSizeOffset] - and esi, 0FFFFFh - sub esi, 2 - jz labEnd - -labNext: - mov ebx, dword ptr [rax] - and ebx, 0FFFFh - cmp ebx, 0D800h - jb short lab1 - - mov ecx, ebx - shl ecx, 10 - lea rax, [rax + 2] - sub esi, 2 - mov ebx, dword ptr [rax] - and ebx, 0FFFFh - add ebx, ecx - sub ebx, 35FDC00h - -lab1: - mov ecx, ebx - - cmp ebx, 00000080h - jl short labs1 - cmp ebx, 0800h - jl short labs2 - cmp ebx, 10000h - jl short labs3 - - mov edx, ebx - shr edx, 18 - add edx, 0F0h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ecx - shr edx, 12 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ecx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - jmp short labSave - -labs2: - mov edx, ecx - shr edx, 6 - add edx, 0C0h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - jmp short labSave - -labs3: - mov edx, ecx - shr edx, 12 - add edx, 0E0h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ecx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - jmp short labSave - -labs1: - mov byte ptr [rdi], bl - add edi, 1 - -labSave: - lea rax, [rax + 2] - sub esi, 2 - jnz labNext - -labEnd: - mov rbx, [rsp+8] - mov rdx, rdi - sub rdx, rbx - ret - -end - -procedure coreapi'wequal - - mov rdx, [rsp+16] // ; s1 - mov rsi, [rsp+8] // ; s2 - - mov ecx, dword ptr [rdx-elSizeOffset] // s1.length - mov ebx, dword ptr [rsi-elSizeOffset] - and ecx, 0FFFFCh - and ebx, 0FFFFCh - mov eax, 0 - cmp ecx, ebx // compare with s2.length - jnz short Lab1 -Lab2: - mov ebx, dword ptr [rsi] - cmp ebx, dword ptr [rdx] - jnz short Lab1 - lea rsi, [rsi+4] - lea rdx, [rdx+4] - sub ecx, 4 - jnz short Lab2 - mov eax, 1 -Lab1: - mov edx, eax - ret - -end - -procedure coreapi'wless - - mov rsi, [rsp+16] // ; s1 - mov rdx, [rsp+8] // ; s2 - - mov ecx, dword ptr [rdx-elSizeOffset] // s1 length - mov eax, 0 - and ecx, 0FFFFFh -Lab2: - mov ebx, dword ptr [rdx] // s1[i] - cmp bx, word ptr [rsi] // compare s2[i] with - jb short Lab1 - nop - nop - ja short LabEnd - lea rsi, [rsi+2] - lea rdx, [rdx+2] - sub ecx, 2 - jnz short Lab2 - nop - nop - jmp short LabEnd - -Lab1: - mov eax, 1 - -LabEnd: - mov edx, eax - ret - -end - -// tempObject(ptr), eax - vmt, edx - value -procedure coreapi'tempObject - - mov rax, [rsp+8] - mov [rax-elVMTOffset], rbx - mov qword ptr [rax], rdx - mov dword ptr [rax-elSizeOffset], 40000008h - ret - -end - -// ; chartowstr (char, target, out edx - length) -procedure coreapi'chartowstr - - mov rax, [rsp+8] - mov rdi, [rsp+16] - xor ecx, ecx - mov dword ptr [rdi], ecx - mov dword ptr [rdi+4], ecx - - mov ebx, dword ptr [rax] - cmp ebx, 010000h - jl short lab1 - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [rdi], dx - - mov edx, ebx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [rdi+2], dx - mov edx, 2 - ret - -lab1: - mov dword ptr [rdi], ebx - mov edx, 1 - ret - -end - -procedure coreapi'wstrtochararray - - mov rdx, [rsp+32] - mov rdi, [rsp+24] - mov ecx, dword ptr [rdx] - mov rsi, [rsp+16] - mov rax, [rsp+8] - mov ebx, dword ptr [rsi] - - lea rdi, [rdi + rbx * 4] - -labStart: - mov ebx, dword ptr [rax] - add rax, 2 - - and ebx, 0FFFFh - cmp ebx, 0D800h - jl short lab1 - - shl ebx, 10 - mov edx, dword ptr [rax] - add eax, 2 - and edx, 0FFFFh - add ebx, edx - sub ebx, 35FDC00h - -lab1: - mov edx, ebx - -labSave: - mov dword ptr [rdi], edx - add rdi, 4 - sub ecx, 1 - jnz labStart - - mov rcx, rdi - mov rdi, [rsp+24] - sub rcx, rdi - mov rsi, [rsp+16] - shr ecx, 2 - sub ecx, dword ptr [rsi] - mov rax, [rsp+32] - mov dword ptr [rax], ecx - - ret - -end - - -// wsubcopy(target,index,size,arr) -procedure coreapi'wsubcopyto - - mov rax, [rsp+32] - mov rdx, [rsp+24] - mov rsi, [rsp+8] - mov ecx, dword ptr [rdx] - mov rdi, [rsp+16] - test ecx, ecx - mov ebx, dword ptr [rdi] - jz short labEnd - -labNext: - mov edx, dword ptr [rax] - mov word ptr [rsi + rbx*2], dx - add rbx, 1 - add rax, 2 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -procedure coreapi'sless - - mov rsi, [rsp+16] // ; s1 - mov rdx, [rsp+8] // ; s2 - - mov ecx, dword ptr [rdx-elSizeOffset] // s1 length - mov eax, 0 - and ecx, 0FFFFFh -Lab2: - mov ebx, dword ptr [rdx] // s1[i] - cmp bl, byte ptr [rsi] // compare s2[i] with - jb short Lab1 - nop - nop - ja short LabEnd - lea rsi, [rsi+1] - lea rdx, [rdx+1] - sub ecx, 1 - jnz short Lab2 - nop - nop - jmp short LabEnd - -Lab1: - mov eax, 1 - -LabEnd: - mov edx, eax - ret - -end - -procedure coreapi'sequal - - mov rdx, [rsp+16] // ; s1 - mov rsi, [rsp+8] // ; s2 - - mov ecx, dword ptr [rdx-elSizeOffset] // s1.length - mov ebx, dword ptr [rsi-elSizeOffset] - and ecx, 0FFFFFh - and ebx, 0FFFFFh - mov eax, 0 - cmp ecx, ebx // compare with s2.length - jnz short Lab1 -Lab2: - mov ebx, dword ptr [rsi] - cmp bl, byte ptr [rdx] - jnz short Lab1 - lea rsi, [rsi+1] - lea rdx, [rdx+1] - sub ecx, 1 - jnz short Lab2 - mov eax, 1 -Lab1: - mov edx, eax - ret - -end - -// strtochararray(src,index,dst,len) -procedure coreapi'strtochararray - - mov rdx, [rsp+32] - mov rdi, [rsp+24] - mov ecx, dword ptr [rdx] - mov rsi, [rsp+16] - mov rax, [rsp+8] - mov ebx, dword ptr[rsi] - - lea rdi, [rdi + rbx * 4] - -labStart: - xor ebx, ebx - mov bl, byte ptr [rax] - add rax, 1 - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 000000E0h - jl short lab2 - cmp ebx, 000000F0h - jl short lab3 - -lab4: - mov edx, ebx - mov bl, byte ptr [rax] - add rax, 1 - shl edx, 18 - shl ebx, 12 - add edx, ebx - - xor ebx, ebx - mov bl, byte ptr [rax] - add rax, 1 - shl ebx, 6 - add edx, ebx - - xor ebx, ebx - mov bl, byte ptr [rax] - add rax, 1 - - add edx, ebx - sub edx, 3C82080h - sub ecx, 3 - jmp labSave - -lab2: - mov edx, ebx - mov bl, byte ptr [rax] - add rax, 1 - - shl edx, 6 - add edx, ebx - sub edx, 3080h - sub ecx, 1 - jmp short labSave - -lab3: - mov edx, ebx - mov bl, byte ptr [rax] - add rax, 1 - shl edx, 12 - shl ebx, 6 - add edx, ebx - xor ebx, ebx - mov bl, byte ptr [rax] - add rax, 1 - add edx, ebx - sub edx, 0E2080h - sub ecx, 2 - jmp short labSave - -lab1: - mov edx, ebx - -labSave: - mov dword ptr [rdi], edx - add rdi, 4 - sub ecx, 1 - jnz labStart - - mov rcx, rdi - mov rdi, [rsp+24] - sub rcx, rdi - mov rsi, [rsp+16] - shr ecx, 2 - sub ecx, dword ptr [rsi] - mov rax, [rsp+32] - mov dword ptr [rax], ecx - - ret - -end - -// ; chartostr (char,target, out edx - length) -procedure coreapi'chartostr - - mov rax, [rsp+8] - mov rdi, [rsp+16] - - xor ecx, ecx - mov dword ptr[rdi], ecx - mov dword ptr[rdi+4], ecx - - mov ebx, dword ptr [rax] - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 0800h - jl short lab2 - cmp ebx, 10000h - jl short lab3 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - shl edx, 24 - mov ecx, edx - - mov edx, ebx - and edx, 0FC0h - shl edx, 10 - add edx, 800000h - or ecx, edx - - mov edx, ebx - and edx, 03F000h - shr edx, 4 - add edx, 08000h - or ecx, edx - - mov edx, ebx - shr edx, 18 - and edx, 03Fh - add edx, 0F0h - or ecx, edx - - mov dword ptr [rdi], ecx - mov edx, 4 - ret - -lab1: - mov dword ptr[rdi], ebx - mov edx, 1 - ret - -lab2: - mov edx, ebx - shr edx, 6 - add edx, 0C0h - mov byte ptr [rdi], dl - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [rdi+1], bl - - mov edx, 2 - ret - -lab3: - mov edx, ebx - shr edx, 12 - add edx, 0E0h - mov byte ptr [rdi], dl - - mov edx, ebx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi+1], dl - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [rdi+2], bl - - mov edx, 3 - ret - -end - -// subcopyz(target,index,size,arr) -procedure coreapi'subcopyto - - mov rax, [rsp+32] - mov rdx, [rsp+24] - mov rsi, [rsp+8] - mov ecx, dword ptr [rdx] - mov rdi, [rsp+16] - test ecx, ecx - mov ebx, dword ptr [rdi] - jz short labEnd - -labNext: - mov edx, dword ptr [rax] - mov byte ptr [rsi + rbx], dl - add rbx, 1 - add rax, 1 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -procedure coreapi'core_callstack_load - - mov rax, [rsp+8] - mov rcx, [rsp+16] - - mov rdx, [rsp] - xor ebx, ebx - mov rsi, rbp - -labNext: - mov rdx, [rsi + 8] - cmp [rsi], 0 - jnz short labSave - test rdx, rdx - jz short labEnd - mov rsi, rdx - jmp short labNext - -labSave: - mov [rax + rbx * 8], rdx - add rbx, 1 - cmp rbx, rcx - jge short labEnd - mov rsi, [rsi] - jmp short labNext - -labEnd: - mov rdx, rbx - ret - -end - -procedure coreapi'strtoint - - mov rax, [rsp+16] // ; radix - mov rsi, [rsp+8] // ; get str - mov ebx, dword ptr [rax] - mov ecx, dword ptr [rsi-elSizeOffset] - xor edx, edx // ; clear flag - and ecx, 0FFFFFh - cmp byte ptr [rsi], 2Dh - lea rcx, [rcx-1] // ; to skip zero - jnz short Lab4 - lodsb - mov edx, 1 // ; set flag - lea rcx, [rcx-1] // ; to skip minus -Lab4: - push rdx - xor eax, eax -Lab1: - mov edx, ebx - mul edx - mov edx, eax - xor eax, eax - lodsb - cmp eax, 3Ah - jl short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short Lab2 - cmp eax, ebx - ja short Lab2 - add eax, edx - sub ecx, 1 - jnz short Lab1 - nop - pop rbx - test ebx, ebx - jz short Lab5 - neg eax -Lab5: - mov edx, eax - mov rbx, [rsp+8] - jmp short Lab3 -Lab2: - add rsp, 8 - xor ebx, ebx -Lab3: - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'wstrtoint - - mov rax, [rsp+16] // ; radix - mov rsi, [rsp+8] // ; get str - - mov ebx, dword ptr[rax] // ; radix - mov ecx, dword ptr [rsi-elSizeOffset] - xor edx, edx // ; clear flag - and ecx, 0FFFFFh - cmp byte ptr [esi], 2Dh - lea rcx, [rcx-2] // ; to skip zero - jnz short Lab4 - lodsw - mov edx, 1 // ; set flag - lea rcx, [rcx-2] // ; to skip minus -Lab4: - push rdx - xor eax, eax -Lab1: - mov edx, ebx - mul edx - mov edx, eax - xor eax, eax - lodsw - cmp eax, 3Ah - jb short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short Lab2 - cmp ax, bx - ja short Lab2 - add eax, edx - sub ecx, 2 - jnz short Lab1 - nop - pop rbx - test ebx, ebx - jz short Lab5 - neg eax -Lab5: - mov edx, eax - mov rbx, [rsp+8] - jmp short Lab3 -Lab2: - xor ebx, ebx -Lab3: - ret - -end - -procedure coreapi'longtowstr - - mov rbx, [rsp+16] - mov rax, [rsp+8] - mov rsi, [rbx] - mov rdi, [rsp+24] - - push rbp - mov rax, [rax] - mov rbp, rsp - xor ecx, ecx - push rax - cmp rax, 0 - jns short Lab6 - neg eax -Lab6: - cmp rax, rbx - jb short Lab5 -Lab1: - idiv rbx - push rdx - add ecx, 2 - cmp rax, rbx - jae short Lab1 -Lab5: - add ecx, 4 - push rax - mov rax, [rbp-8] - cmp rax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 2 -Lab7: - mov rsi, rdi - mov edx, 0FFh - sub ecx, 2 // to skip zero -Lab2: - pop rax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov word ptr [rsi], ax - add rsi, 2 - sub rcx, 2 - jnz short Lab2 - mov rcx, rsi - sub rcx, rdi - shr ecx, 1 - lea rsp, [rsp+8] - pop rbp - - ret - -end - -// ; realtowstr(str,radix,r) -procedure coreapi'realtowstr - - mov rdi, [rsp+24] // ; r - mov rsi, [rsp+16] // ; radix - mov rax, [rsp+8] // ; get str - mov ebx, dword ptr [rsi] - - mov rcx, rax - push rbp - mov rbp, rsp - - sub rsp, 104 - - push rdi - - lea rbx, [rbx-3] // get the number of decimal digits (minus 2 for sign and dot) - cmp ebx, 13 - jbe short ftoa1 - mov ebx, 13 -ftoa1: - xor edx, edx - - //------------------------------------------- - //first examine the value on FPU for validity - //------------------------------------------- - - fld qword ptr [rcx] - fxam // examine value on FPU - fstsw ax // get result - - sahf // transfer to CPU flags - jz short maybezero - jpo srcerr // C3=0 and C2=0 would be NAN or unsupported - jnc short getnumsize // continue if normal finite number - - //-------------------------------- - //value to be converted = INFINITY - //-------------------------------- - - mov al,43 // "+" - test ah,2 // C1 field = sign - jz short ftoa2 - mov al, 45 // "-" -ftoa2: - and eax, 0FFh - stosw - mov eax,4E0049h // "NI" - stosd - mov eax,490046h // "IF" - stosd - mov eax,49004Eh // "IN" - stosd - mov eax,590054h // "YT" - stosd - jmp finish - - //------------------------- - //value to be converted = 0 - //------------------------- - -maybezero: - jpe short getnumsize // would be denormalized number - fstp st(0) // flush that 0 value off the FPU - mov eax,2E0030h // ".0" szstring - stosd // write it - mov eax,30h // "0" szstring - stosw // write it - jmp finish - - //--------------------------- - // get the size of the number - //--------------------------- - -getnumsize: - fldlg2 // log10(2) - fld st(1) // copy Src - fabs // insures a positive value - fyl2x // ->[log2(Src)]*[log10(2)] = log10(Src) - - fstcw word ptr [rbp-8] // get current control word - mov ax, word ptr [rbp-8] - or ax,0C00h // code it for truncating - mov word ptr [rbp-16],ax - fldcw word ptr [rbp-16] // insure rounding code of FPU to truncating - - fist [rbp-24] // store characteristic of logarithm - fldcw word ptr [rbp-8] // load back the former control word - - ftst // test logarithm for its sign - fstsw ax // get result - sahf // transfer to CPU flags - sbb [rbp-24],0 // decrement esize if log is negative - fstp st(0) // get rid of the logarithm - - //----------------------------------------------------------------------- - // get the power of 10 required to generate an integer with the specified - // number of significant digits - //----------------------------------------------------------------------- - - mov eax, dword ptr [rbp-12] - lea rax, [rax+1] // one digit is required - or eax, eax - js short ftoa21 - cmp eax, 13 - jbe short ftoa20 - mov edx, -1 - mov ebx, 13 - mov ecx, ebx - sub ecx, eax - mov dword ptr[rbp-32], ecx - jmp short ftoa22 - -ftoa20: - add eax, ebx - cmp eax, 13 - jbe short ftoa21 - sub eax, 13 - sub ebx, eax - -ftoa21: - mov dword ptr[rbp-32], ebx - -ftoa22: - - //---------------------------------------------------------------------------------------- - // multiply the number by the power of 10 to generate required integer and store it as BCD - //---------------------------------------------------------------------------------------- - - fild dword ptr [rbp-32] - fldl2t - fmulp // ->log2(10)*exponent - fld st(0) - frndint // get the characteristic of the log - fxch st(1) - fsub st(0),st(1) // get only the fractional part but keep the characteristic - f2xm1 // ->2^(fractional part)-1 - fld1 - faddp // add 1 back - fscale // re-adjust the exponent part of the REAL number - fstp st(1) // get rid of the characteristic of the log - fmulp // ->16-digit integer - - fbstp tbyte ptr[rbp-56] // ->TBYTE containing the packed digits - fstsw ax // retrieve exception flags from FPU - shr eax,1 // test for invalid operation - jc srcerr // clean-up and return error - - //------------------------------------------------------------------------------ - // unpack BCD, the 10 bytes returned by the FPU being in the little-endian style - //------------------------------------------------------------------------------ - - lea rsi, [rbp-47] // go to the most significant byte (sign byte) - push rdi - lea rdi,[rbp-104] - mov eax,3020h - movzx ecx,byte ptr[rsi] // sign byte - cmp ecx, 00000080h - jnz short ftoa5 - mov al, 45 // insert sign if negative number -ftoa5: - - stosw - mov ecx,9 -ftoa6: - sub esi, 1 - movzx eax,byte ptr[rsi] - ror ax,4 - ror ah,4 - add eax,3030h - stosw - sub ecx, 1 - jnz short ftoa6 - - pop rdi - lea rsi,[rbp-104] - - cmp edx, 0 - jnz short scientific - - //************************ - // REGULAR STRING NOTATION - //************************ - - movsb // insert sign - xor eax, eax - stosb - - cmp byte ptr[rsi-1], 20h // test if we insert space - jnz short ftoa60 - lea rdi, [rdi-2] // erase it - -ftoa60: - mov ecx,1 // at least 1 integer digit - mov eax, dword ptr [rbp-24] - or eax, eax // is size negative (i.e. number smaller than 1) - js short ftoa61 - add ecx, eax - -ftoa61: - mov eax, ebx - add eax, ecx // ->total number of digits to be displayed - sub eax, 19 - sub esi, eax // address of 1st digit to be displayed - cmp byte ptr[rsi-1], 49 // "1" - jnz ftoa8 - sub esi, 1 - add ecx, 1 -ftoa8: - test ecx, ecx - jz short ftoa8End -ftoa8Next: // copy required integer digits - movzx eax, byte ptr [rsi] - mov word ptr [rdi], ax - lea rsi, [rsi+1] - lea rdi, [rdi+2] - sub ecx, 1 - jnz short ftoa8Next -ftoa8End: - mov ecx,ebx - or ecx,ecx - jz short ftoa9 - mov eax,46 // "." - stosw - -ftoa9Next: // copy required decimal digits - movzx eax, byte ptr [rsi] - mov word ptr [rdi], ax - lea rsi, [rsi+1] - lea rdi, [rdi+2] - sub ecx, 1 - jnz short ftoa9Next -ftoa9: - jmp finish - -scientific: - movsb // insert sign - xor eax, eax - stosb - - cmp byte ptr[rsi-1], 20h // test if we insert space - jnz short ftoa90 - lea rdi, [rdi-2] // erase it - -ftoa90: - mov ecx, ebx - mov eax, 18 - sub eax, ecx - add esi, eax - cmp byte ptr[rsi-1],49 // "1" - pushfd // save flags for extra "1" - jnz short ftoa10 - sub esi, 1 -ftoa10: - movsb // copy the integer - xor eax, eax - stosb - - mov eax,46 // "." - stosw - -ftoa10Next: // copy the decimal digits - movzx eax, byte ptr [rsi] - mov word ptr [rdi], ax - lea rsi, [rsi+1] - lea rdi, [rdi+2] - sub ecx, 1 - jnz short ftoa10Next - - mov eax,69 // "E" - stosw - mov eax,43 // "+" - mov ecx,dword ptr [rbp-24] - popfd // retrieve flags for extra "1" - jnz short ftoa11 // no extra "1" - add ecx, 1 // adjust exponent -ftoa11: - or ecx,ecx - jns short ftoa12 - mov eax,45 // "-" - neg ecx // make number positive -ftoa12: - stosw // insert proper sign - -// Note: the absolute value of the size could not exceed 4931 - - xor ebx, ebx - mov eax,ecx - mov cl,100 - div cl // ->thousands & hundreds in al, tens & units in AH - push rax - and eax,0ffh // keep only the thousands & hundreds - mov cl,10 - div cl // ->thousands in al, hundreds in AH - add eax,3030h // convert to characters - mov bl, al // insert them - mov word ptr [rdi], bx - lea rdi, [rdi+2] - shr eax, 8 - mov bl, al - mov word ptr [rdi], bx - lea rdi, [rdi+2] - pop rax - shr eax,8 // get the tens & units in al - div cl // tens in al, units in AH - add eax,3030h // convert to characters - - mov bl, al // insert them - mov word ptr [rdi], bx - lea rdi, [rdi+2] - shr eax, 8 - mov bl, al - mov word ptr [rdi], bx - lea rdi, [rdi+2] - -finish: - cmp word ptr [rdi-2], 48 // '0' - jnz short finish1 - lea rdi, [rdi-2] - jmp short finish - -finish1: - cmp word ptr [rdi-2], 46 // '.' - jnz short finish2 - lea rdi, [rdi+2] - -finish2: - mov ebx, edi - pop rdi - add rsp, 104 - pop rbp - - sub rbx, rdi - mov rcx, rbx - - jmp short finish3 - -srcerr: - pop rdi - add rsp, 104 - pop rbp - xor eax,eax -finish3: - -/* -oldcw :-4 (4) -truncw :-8 (4) -esize :-12 (4) -tempdw :-16 (4) -bcdstr :-28 (12) // -20 -unpacked:- (52) // -32 -*/ - - ret -end - -// ; rcopyl (eax:char, edi - target) -procedure coreapi'chartoshorts - - mov rsi, [rsp+8] - mov rax, [rsp+16] - mov ecx, dword ptr[rsi] - mov rdi, [rsp+24] - mov ebx, dword ptr[rax] - - cmp ecx, 010000h - jl short lab1 - - mov edx, ecx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [rdi + rbx * 2], dx - add ebx, 1 - - mov edx, ecx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [rdi+rbx * 2], dx - mov edx, 2 - ret - -lab1: - mov dword ptr[rdi + rbx * 2], ecx - mov edx, 1 - ret - -end - -procedure coreapi'strtouint - - mov rax, [rsp+16] // ; radix - mov rsi, [rsp+8] // ; get str - - mov ebx, dword ptr[rax] // ; radix - mov ecx, dword ptr [rsi-elSizeOffset] - and ecx, 0FFFFFh - xor eax, eax - lea rcx, [rcx-1] // ; to skip zero -Lab1: - mov edx, ebx - mul edx - mov edx, eax - xor eax, eax - lodsb - cmp eax, 3Ah - jl short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short Lab2 - cmp eax, ebx - ja short Lab2 - add eax, edx - sub ecx, 1 - jnz short Lab1 - mov edx, eax - mov rbx, [rsp+8] - jmp short Lab3 -Lab2: - add rsp, 8 - xor ebx, ebx -Lab3: - ret - -end - -procedure coreapi'rsqrt - - mov rax, [rsp+8] - fld qword ptr [rax] - fsqrt - fstp qword ptr [rbx] // store result - ret - -end - -procedure coreapi'rpi - - fldpi - fstp qword ptr [rbx] // store result - ret - -end - -// ; rcopyl (eax:src, ecx : base, ebx - result) -procedure coreapi'strtoreal - - mov rax, [rsp+16] // ; radix - mov rsi, [rsp+8] // ; get str - mov ecx, dword ptr[rax] - - sub rsp, 12 - xor edx, edx - xor eax, eax - xor ebx, ebx - mov rdi, rsp - stosd - stosd - mov dword ptr [rdi], eax - -atof1: - lodsb - cmp eax, 32 // " " - jz short atof1 - or eax, eax - jnz short atof2 - -atoflerr: - add rsp, 12 - xor ebx, ebx - jmp atoflend - - //---------------------- - // check for leading sign - //---------------------- - -atof2: - - cmp eax, 43 // + - jz short atof3 - cmp eax,45 // - - jnz short integer - mov dh,80h -atof3: - mov byte ptr [rdi+1], dh // put sign byte in bcd string - xor edx,edx - lodsb - - //------------------------------------ - // convert the digits to packed decimal - //------------------------------------ -integer: - - cmp eax, 46 // . - jnz short atof4 - test bh, 1 - jnz short atoflerr // only one decimal point allowed - or bh, 1 - lodsb -atof4: - cmp eax, 101 // "e" - jnz short atof5 - cmp cl, 19 - jnz short atof41 - test bh, 4 - jz short atoflerr -atof41: - jmp scient -atof5: - cmp eax,69 // "E" - jnz short atof6 - cmp cl, 19 - jnz short atof51 - test bh, 4 - jz short atoflerr -atof51: - jmp scient -atof6: - or eax,eax - jnz short atof7 - cmp cl, 19 - jnz atof61 - test bh, 4 - jz short atoflerr -atof61: - jmp laststep1 -atof7: - sub eax,48 // "0" - jc short atoflerr // unacceptable character - cmp eax,9 - ja short atoflerr // unacceptable character - or bh,4 // at least 1 numerical character - test bh,1 - jz short atof8 - add bl,1 // bl holds number of decimal digits - jc atoflerr // more than 255 decimal digits -atof8: - test eax, eax - jnz short atof9 - test bh,2 - jnz short atof9 - lodsb - jmp short integer -atof9: - or bh,2 // at least 1 non-zero numerical character - sub ecx, 1 - jnz short atof10 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof91 // if trailing decimal 0 - add ecx, 1 - sub bl, 1 - lodsb - jmp integer -atof91: - jmp atoflerr -atof10: - mov dh,al - -integer1: - lodsb - cmp eax, 46 // "." - jnz short atof20 - test bh,1 - jnz atoflerr // only one decimal point allowed - or bh, 1 // use bh bit0 as the decimal point flag - lodsb -atof20: - cmp eax, 101 // "e" - jnz short atof30 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - jmp scient -atof30: - cmp eax, 69 // "E" - jnz short atof40 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - jmp scient -atof40: - or eax,eax - jnz short atof50 - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - jmp short laststep1 -atof50: - sub eax, 48 // "0" - jc atoflerr // unacceptable character - cmp eax,9 - ja atoflerr // unacceptable character - test bh,1 - jz short atof60 - add bl, 1 // processing decimal digits -atof60: - sub ecx, 1 - jnz short atof70 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof602 - add ecx, 1 - sub bl, 1 - jmp integer1 -atof602: - jmp atoflerr -atof70: - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - sub edi, 1 - lodsb - jmp integer - -laststep1: - cmp cl,19 - jnz short laststep - fldz - jmp short laststep2 - -laststep: - - mov ah, dh -/* - push eax //;reserve space on stack - fstcw word ptr [esp] // ;get current control word - pop eax - or eax,0300h // ;code it for truncating - push eax - fldcw word ptr [esp] // ;change rounding code of FPU to truncate - pop eax -*/ - xor edx, edx - fbld [rsp] - sub cl, 1 - add bl,cl - movzx eax,bl - sub edx,eax - - push rdx - fild dword ptr [rsp] // load the exponent - fldl2t // load log2(10) - fmulp // ->log2(10)*exponent - pop rdx - - // at this point, only the log base 2 of the 10^exponent is on the FPU - // the FPU can compute the antilog only with the mantissa - // the characteristic of the logarithm must thus be removed - - fld st(0) // copy the logarithm - frndint // keep only the characteristic - fsub st(1),st(0) // keeps only the mantissa - fxch st(1) // get the mantissa on top - - f2xm1 // ->2^(mantissa)-1 - fld1 - faddp // add 1 back - - // the number must now be readjusted for the characteristic of the logarithm - - fscale // scale it with the characteristic - - // the characteristic is still on the FPU and must be removed - - fstp st(1) // clean-up the register - - fmulp - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc atoflerr // clean-up and return error - -laststep2: - - add rsp, 12 - mov rdi, [rsp+24] - fstp qword ptr[rdi] // store result at specified address - jmp short atoflend - -scient: - cmp cl,19 - jnz short atof80 - fldz - jmp short laststep2 - xor edx, edx - -atof80: - xor eax,eax - lodsb - cmp ax, 43 // "+" - jz atof90 - cmp ax, 45 // "-" - jnz short scient1 - stc - rcr eax,1 // keep sign of exponent in most significant bit of EAX - -atof90: - - lodsb // get next digit after sign - -scient1: - push rax - and eax,0ffh - jnz short atof100 // continue if 1st byte of exponent is not terminating 0 - -scienterr: - xor ebx, ebx - jmp atoflerr // no exponent - -atof100: - sub eax,30h - jc short scienterr // unacceptable character - cmp eax,9 - ja short scienterr // unacceptable character - imul edx,10 - add edx,eax - cmp edx,4931h - ja short scienterr // exponent too large - lodsb - or eax,eax - jnz short atof100 - pop rax // retrieve exponent sign flag - rcl eax,1 // is most significant bit set? - jnc short atof200 - neg edx - -atof200: - jmp laststep - -atoflend: - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'wstrtoreal - - mov rdi, [rsp+24] - mov rax, [rsp+16] // ; radix - mov rsi, [rsp+8] // ; get str - mov ecx, dword ptr[rax] - - push rdi - sub rsp, 12 - xor edx, edx - xor eax, eax - xor ebx, ebx - mov rdi, rsp - stosd - stosd - mov word ptr [rdi], ax - mov ecx, 19 - -atof1: - lodsw - cmp eax, 32 // " " - jz short atof1 - or eax, eax - jnz short atof2 - -atoflerr: - add rsp, 12 - pop rdi - xor esi, esi - jmp atoflend - - //---------------------- - // check for leading sign - //---------------------- - -atof2: - - cmp eax, 43 // + - jz short atof3 - cmp eax,45 // - - jnz short integer - mov dh,80h -atof3: - mov byte ptr [rdi+1], dh // put sign byte in bcd string - xor edx,edx - lodsw - - //------------------------------------ - // convert the digits to packed decimal - //------------------------------------ -integer: - - cmp eax, 46 // . - jnz short atof4 - test bh, 1 - jnz short atoflerr // only one decimal point allowed - or bh, 1 - lodsw -atof4: - cmp eax, 101 // "e" - jnz short atof5 - cmp cl, 19 - jnz short atof41 - test bh, 4 - jz short atoflerr -atof41: - jmp scient -atof5: - cmp eax,69 // "E" - jnz short atof6 - cmp cl, 19 - jnz short atof51 - test bh, 4 - jz short atoflerr -atof51: - jmp scient -atof6: - or eax,eax - jnz short atof7 - cmp cl, 19 - jnz atof61 - test bh, 4 - jz short atoflerr -atof61: - jmp laststep1 -atof7: - sub eax,48 // "0" - jc short atoflerr // unacceptable character - cmp eax,9 - ja short atoflerr // unacceptable character - or bh,4 // at least 1 numerical character - test bh,1 - jz short atof8 - add bl,1 // bl holds number of decimal digits - jc atoflerr // more than 255 decimal digits -atof8: - test eax, eax - jnz short atof9 - test bh,2 - jnz short atof9 - lodsw - jmp short integer -atof9: - or bh,2 // at least 1 non-zero numerical character - sub ecx, 1 - jnz short atof10 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof91 // if trailing decimal 0 - add ecx, 1 - sub bl, 1 - lodsw - jmp integer -atof91: - jmp atoflerr -atof10: - mov dh,al - -integer1: - lodsw - cmp eax, 46 // "." - jnz short atof20 - test bh,1 - jnz atoflerr // only one decimal point allowed - or bh, 1 // use bh bit0 as the decimal point flag - lodsw -atof20: - cmp eax, 101 // "e" - jnz short atof30 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - jmp scient -atof30: - cmp eax, 69 // "E" - jnz short atof40 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - jmp scient -atof40: - or eax,eax - jnz short atof50 - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - jmp short laststep1 -atof50: - sub eax, 48 // "0" - jc atoflerr // unacceptable character - cmp eax,9 - ja atoflerr // unacceptable character - test bh,1 - jz short atof60 - add bl, 1 // processing decimal digits -atof60: - sub ecx, 1 - jnz short atof70 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof602 - add ecx, 1 - sub bl, 1 - jmp integer1 -atof602: - jmp atoflerr -atof70: - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [rdi],al - mov dh, ah - sub edi, 1 - lodsw - jmp integer - -laststep1: - cmp cl,19 - jnz short laststep - fldz - jmp short laststep2 - -laststep: - mov ah, dh - xor edx, edx - fbld [rsp] - sub cl, 1 - add bl,cl - movzx eax,bl - sub edx,eax - - push rdx - fild dword ptr [rsp] // load the exponent - fldl2t // load log2(10) - fmulp // ->log2(10)*exponent - pop rdx - - // at this point, only the log base 2 of the 10^exponent is on the FPU - // the FPU can compute the antilog only with the mantissa - // the characteristic of the logarithm must thus be removed - - fld st(0) // copy the logarithm - frndint // keep only the characteristic - fsub st(1),st(0) // keeps only the mantissa - fxch st(1) // get the mantissa on top - - f2xm1 // ->2^(mantissa)-1 - fld1 - faddp // add 1 back - - // the number must now be readjusted for the characteristic of the logarithm - - fscale // scale it with the characteristic - - // the characteristic is still on the FPU and must be removed - - fstp st(1) // clean-up the register - - fmulp - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc atoflerr // clean-up and return error - -laststep2: - - add rsp, 12 - pop rdi - fstp qword ptr[rdi] // store result at specified address - jmp short atoflend - -scient: - cmp cl,19 - jnz short atof80 - fldz - jmp short laststep2 - xor edx, edx - -atof80: - xor eax,eax - lodsw - cmp ax, 43 // "+" - jz atof90 - cmp ax, 45 // "-" - jnz short scient1 - stc - rcr eax,1 // keep sign of exponent in most significant bit of EAX - -atof90: - - lodsw // get next digit after sign - -scient1: - push rax - and eax,0ffh - jnz short atof100 // continue if 1st byte of exponent is not terminating 0 - -scienterr: - pop rdi - xor esi, esi - jmp atoflerr // no exponent - -atof100: - sub eax,30h - jc short scienterr // unacceptable character - cmp eax,9 - ja short scienterr // unacceptable character - imul edx,10 - add edx,eax - cmp edx,4931h - ja short scienterr // exponent too large - lodsw - or eax,eax - jnz short atof100 - pop rax // retrieve exponent sign flag - rcl eax,1 // is most significant bit set? - jnc short atof200 - neg edx - -atof200: - jmp laststep - -atoflend: - mov rax, rsi - ret - -end - -// ; rcopyl (src,tgt) -procedure coreapi'longtoreal - - mov rax, [rsp+8] - mov rdi, [rsp+16] - fild qword ptr [rax] - fstp qword ptr [rdi] - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'strtolong - - mov rax, [rsp+16] // ; radix - mov rsi, [rsp+8] // ; get str - mov ecx, dword ptr [rax] - - push rcx - mov ecx, dword ptr[rsi-elSizeOffset] - xor edx, edx - and ecx, 0FFFFFh - - cmp byte ptr [rsi], 2Dh - lea rcx, [rcx-1] - jnz short labStart - - lea rsi, [rsi+1] - lea rcx, [rcx-1] - mov edx, 1 // set flag in ebx - -labStart: - push rdx // save sign flag - xor rax, rax - -labConvert: - mov edx, dword ptr [rsp+8] - mul rdx - mov rbx, rax - xor eax, eax - lodsb - cmp eax, 3Ah - jl short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short labErr - mov edx, dword ptr [rsp+8] - cmp eax, edx - ja short labErr - add rax, rbx - sub ecx, 1 - jnz short labConvert - - mov rbx, rax - pop rax // restore flag - test eax, eax - jz short labSave - neg rbx - -labSave: - pop rsi - - mov rax, [rsp+24] - mov [rax], rbx - mov rbx, [rsp+8] - - jmp short labQuit - -labErr: - xor ebx, ebx - pop rdx - -labQuit: - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'wstrtolong - - mov rax, [rsp+16] // ; radix - mov rsi, [rsp+8] // ; get str - mov rcx, [rax] - - push rcx - mov esi, eax - mov ecx, dword ptr [rsi-elSizeOffset] - xor edx, edx - and ecx, 0FFFFFh - - cmp byte ptr [rsi], 2Dh - lea rcx, [rcx-2] - jnz short labStart - - lea rsi, [rsi+2] - lea rcx, [rcx-2] - mov edx, 1 // set flag in ebx - -labStart: - push rdx // save sign flag - xor edi, edi // edi - DHI - xor ebx, ebx // ebx - DLO - -labConvert: - mov rdx, [rsp+4] - mov eax, edi - mul edx // DHI * 10 - mov edi, eax - - mov eax, ebx - mov rdx, [rsp+4] - mul edx // DLO * 10 - add edi, edx - mov ebx, eax - - xor eax, eax - lodsw - sub al, 30h - jb short labErr - cmp al, 9 - ja short labErr - - add ebx, eax // DLO + EAX - adc edi, 0 // DHI + CF - - sub ecx, 2 - jnz short labConvert - - pop rax // restore flag - test eax, eax - jz short labSave - - not edi // invert number - neg ebx - -labSave: - - mov edx, edi - pop rsi - - mov rax, [rsp+12] - mov dword ptr [rax], ebx - mov dword ptr [rax+4], edx - mov rbx, [rsp+8] - - jmp short labEnd - -labErr: - xor ebx, ebx - pop rbx - -labEnd: - ret - -end - -// ; (esi - index, ecx - char, edi - target ; out : ecx : length) -procedure coreapi'chartobytes - - mov rsi, [rsp+8] - mov rax, [rsp+16] - mov ecx, dword ptr [rsi] - mov rdi, [rsp+24] - mov ebx, dword ptr[rax] - - cmp ecx, 00000080h - jl short lab1 - cmp ecx, 0800h - jl short lab2 - cmp ecx, 10000h - jl short lab3 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi + rbx], dl - add ebx, 1 - - mov edx, ecx - shr edx, 12 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [rdi + rbx], dl - add ebx, 1 - - mov edx, ecx - shr edx, 6 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [rdi + rbx], dl - add ebx, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi + rbx], dl - add ebx, 1 - mov edx, 4 - ret - -lab1: - mov byte ptr [rdi + rbx], cl - add ebx, 1 - mov edx, 1 - ret - -lab2: - mov edx, ecx - shr edx, 6 - add edx, 0C0h - mov byte ptr [rdi + rbx], dl - add ebx, 1 - - and ecx, 03Fh - add ecx, 00000080h - mov byte ptr [rdi+rbx], cl - add ebx, 1 - mov edx, 2 - ret - -lab3: - mov edx, ecx - shr edx, 12 - add edx, 0E0h - mov byte ptr [rdi + rbx], dl - add ebx, 1 - - mov edx, ecx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi+rbx], dl - add ebx, 1 - - and ecx, 03Fh - add ecx, 00000080h - mov byte ptr [rdi+rbx], cl - add ebx, 1 - mov edx, 3 - ret - -end - -// ; move(target,index,len,offs) -procedure coreapi'move - - mov rdx, [rsp+16] - mov rax, [rsp+24] - mov rdi, [rsp+8] // ; target - mov ecx, dword ptr[rax] - mov rsi, [rsp+32] - mov ebx, dword ptr [rdx] // ; index - - test ecx, ecx // ; len - jz short labEnd - - movsxd rdx, dword ptr[rsi] // ; offs - cmp rdx, 0 - jl short labDelete - - add ebx, ecx - sub ebx, 1 - - add edx, ebx - - add edx, edi - add ebx, edi - -labNext: - mov esi, dword ptr [rsi] - mov dword ptr [rdx], esi - sub ebx, 1 - sub edx, 1 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -labDelete: - add rdx, rbx - - add rdx, rdi - add rbx, rdi - -labNext2: - mov esi, dword ptr [rbx] - mov dword ptr [rdx], esi - add ebx, 1 - add edx, 1 - sub ecx, 1 - jnz short labNext2 - ret - -end - -// subcopyz(target,index,size,arr) -procedure coreapi'subcopy - - mov rax, [rsp+32] - mov rdx, [rsp+24] - mov rsi, [rsp+8] - mov ecx, dword ptr[rdx] - mov rdi, [rsp+16] - test ecx, ecx - mov ebx, dword ptr[rdi] - jz short labEnd - -labNext: - mov rdx, [rax + rbx] - mov byte ptr [rsi], dl - add rbx, 1 - add rsi, 1 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -procedure coreapi'longtostr - - mov rbx, [rsp+16] - mov rax, [rsp+8] - mov rsi, [rbx] - mov rdi, [rsp+24] - - push rbp - mov rax, [rax] - mov rbp, rsp - xor ecx, ecx - push rax - // ; take sign into account only for the decimal representation - cmp rsi, 10 - jnz short Lab6 - cmp rax, 0 - jns short Lab6 - neg rax -Lab6: - cmp rax, rsi - jb short Lab5 -Lab1: - cqo - idiv rsi - push rdx - add ecx, 1 - cmp rax, rsi - jae short Lab1 -Lab5: - add ecx, 2 - push rax - cmp rsi, 10 - jnz short Lab7 - mov rax, [rbp-8] - cmp eax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 1 -Lab7: - sub ecx, 1 - mov rsi, rdi - mov edx, 0FFh -Lab2: - pop rax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov byte ptr [rsi], al - add esi, 1 - sub ecx, 1 - jnz short Lab2 - mov edx, esi - sub edx, edi - lea rsp, [rsp+8] - pop rbp - - ret - -end - -// ; realtostr(str,radix,r) -procedure coreapi'realtostr - - mov rdi, [rsp+24] // ; r - mov rsi, [rsp+16] // ; radix - mov rax, [rsp+8] // ; get str - mov ebx, dword ptr [rsi] - - mov rcx, rax - push rbp - mov rbp, rsp - - sub rsp, 104 - - push rdi - - lea rbx, [rbx-3] // get the number of decimal digits (minus 2 for sign and dot) - cmp ebx, 13 - jbe short ftoa1 - mov ebx, 13 -ftoa1: - xor edx, edx - - //------------------------------------------- - //first examine the value on FPU for validity - //------------------------------------------- - - fld qword ptr [rcx] - fxam // examine value on FPU - fstsw ax // get result - - sahf // transfer to CPU flags - jz short maybezero - jpo srcerr // C3=0 and C2=0 would be NAN or unsupported - jnc short getnumsize // continue if normal finite number - - //-------------------------------- - //value to be converted = INFINITY - //-------------------------------- - - mov al,43 // "+" - test ah,2 // C1 field = sign - jz short ftoa2 - mov al, 45 // "-" -ftoa2: - and eax, 0FFh - stosw - mov eax,4E49h // "NI" - stosw - mov eax,4946h // "IF" - stosw - mov eax,494Eh // "IN" - stosw - mov eax,5954h // "YT" - stosw - jmp finish - - //------------------------- - //value to be converted = 0 - //------------------------- - -maybezero: - jpe short getnumsize // would be denormalized number - fstp st(0) // flush that 0 value off the FPU - mov eax,2E30h // ".0" szstring - stosw // write it - mov eax,30h // "0" szstring - stosb // write it - jmp finish - - //--------------------------- - // get the size of the number - //--------------------------- - -getnumsize: - fldlg2 // log10(2) - fld st(1) // copy Src - fabs // insures a positive value - fyl2x // ->[log2(Src)]*[log10(2)] = log10(Src) - - fstcw word ptr [rbp-8] // get current control word - mov ax, word ptr [rbp-8] - or ax,0C00h // code it for truncating - mov word ptr [rbp-16],ax - fldcw word ptr [rbp-16] // insure rounding code of FPU to truncating - - fist [rbp-24] // store characteristic of logarithm - fldcw word ptr [rbp-8] // load back the former control word - - ftst // test logarithm for its sign - fstsw ax // get result - sahf // transfer to CPU flags - sbb [rbp-24],0 // decrement esize if log is negative - fstp st(0) // get rid of the logarithm - - //----------------------------------------------------------------------- - // get the power of 10 required to generate an integer with the specified - // number of significant digits - //----------------------------------------------------------------------- - - mov eax, dword ptr[rbp-24] - lea rax, [rax+1] // one digit is required - or eax, eax - js short ftoa21 - cmp eax, 13 - jbe short ftoa20 - mov edx, -1 - mov ebx, 13 - mov ecx, ebx - sub ecx, eax - mov dword ptr [rbp-32], ecx - jmp short ftoa22 - -ftoa20: - add eax, ebx - cmp eax, 13 - jbe short ftoa21 - sub eax, 13 - sub ebx, eax - -ftoa21: - mov dword ptr[rbp-32], ebx - -ftoa22: - - //---------------------------------------------------------------------------------------- - // multiply the number by the power of 10 to generate required integer and store it as BCD - //---------------------------------------------------------------------------------------- - - fild dword ptr [rbp-32] - fldl2t - fmulp // ->log2(10)*exponent - fld st(0) - frndint // get the characteristic of the log - fxch st(1) - fsub st(0),st(1) // get only the fractional part but keep the characteristic - f2xm1 // ->2^(fractional part)-1 - fld1 - faddp // add 1 back - fscale // re-adjust the exponent part of the REAL number - fstp st(1) // get rid of the characteristic of the log - fmulp // ->16-digit integer - - fbstp tbyte ptr[rbp-56] // ->TBYTE containing the packed digits - fstsw ax // retrieve exception flags from FPU - shr eax,1 // test for invalid operation - jc srcerr // clean-up and return error - - //------------------------------------------------------------------------------ - // unpack BCD, the 10 bytes returned by the FPU being in the little-endian style - //------------------------------------------------------------------------------ - - lea rsi, [rbp-47] // go to the most significant byte (sign byte) - push rdi - lea rdi,[rbp-104] - mov eax,3020h - movzx ecx,byte ptr[rsi] // sign byte - cmp ecx, 00000080h - jnz short ftoa5 - mov al, 45 // insert sign if negative number -ftoa5: - - stosw - mov ecx,9 -ftoa6: - sub esi, 1 - movzx eax,byte ptr[rsi] - ror ax,4 - ror ah,4 - add eax,3030h - stosw - sub ecx, 1 - jnz short ftoa6 - - pop rdi - lea rsi,[rbp-104] - - cmp edx, 0 - jnz short scientific - - //************************ - // REGULAR STRING NOTATION - //************************ - - movsb // insert sign - - cmp byte ptr[rsi-1], 20h // test if we insert space - jnz short ftoa60 - lea rdi, [rdi-1] // erase it - -ftoa60: - mov ecx,1 // at least 1 integer digit - mov eax, dword ptr[rbp-24] - or eax, eax // is size negative (i.e. number smaller than 1) - js short ftoa61 - add ecx, eax - -ftoa61: - mov eax, ebx - add eax, ecx // ->total number of digits to be displayed - sub eax, 19 - sub esi, eax // address of 1st digit to be displayed - cmp byte ptr[esi-1], 49 // "1" - jnz ftoa8 - sub esi, 1 - add ecx, 1 -ftoa8: - test ecx, ecx - jz short ftoa8End -ftoa8Next: // copy required integer digits - movzx eax, byte ptr [rsi] - mov byte ptr [rdi], al - lea rsi, [rsi+1] - lea rdi, [rdi+1] - sub ecx, 1 - jnz short ftoa8Next -ftoa8End: - mov ecx,ebx - or ecx,ecx - jz short ftoa9 - mov eax,46 // "." - stosb - -ftoa9Next: // copy required decimal digits - movzx eax, byte ptr [rsi] - mov byte ptr [rdi], al - lea rsi, [rsi+1] - lea rdi, [rdi+1] - sub ecx, 1 - jnz short ftoa9Next -ftoa9: - jmp finish - -scientific: - movsb // insert sign - - cmp byte ptr[rsi-1], 20h // test if we insert space - jnz short ftoa90 - lea rdi, [rdi-1] // erase it - -ftoa90: - mov ecx, ebx - mov eax, 18 - sub eax, ecx - add esi, eax - cmp byte ptr[rsi-1],49 // "1" - pushfd // save flags for extra "1" - jnz short ftoa10 - sub esi, 1 -ftoa10: - movsb // copy the integer - xor eax, eax - stosb - - mov eax,46 // "." - stosb - -ftoa10Next: // copy the decimal digits - movzx eax, byte ptr [rsi] - mov byte ptr [rdi], al - lea rsi, [rsi+1] - lea rdi, [rdi+1] - sub ecx, 1 - jnz short ftoa10Next - - mov eax,69 // "E" - stosb - mov eax,43 // "+" - mov ecx,dword ptr [rbp-24] - popfd // retrieve flags for extra "1" - jnz short ftoa11 // no extra "1" - add ecx, 1 // adjust exponent -ftoa11: - or ecx,ecx - jns short ftoa12 - mov eax,45 // "-" - neg ecx // make number positive -ftoa12: - stosb // insert proper sign - -// Note: the absolute value of the size could not exceed 4931 - - xor ebx, ebx - mov eax,ecx - mov cl,100 - div cl // ->thousands & hundreds in al, tens & units in AH - push rax - and eax,0ffh // keep only the thousands & hundreds - mov cl,10 - div cl // ->thousands in al, hundreds in AH - add eax,3030h // convert to characters - mov bl, al // insert them - mov byte ptr [rdi], bl - lea rdi, [rdi+1] - shr eax, 8 - mov bl, al - mov byte ptr [rdi], bl - lea rdi, [rdi+1] - pop rax - shr eax,8 // get the tens & units in al - div cl // tens in al, units in AH - add eax,3030h // convert to characters - - mov bl, al // insert them - mov byte ptr [rdi], bl - lea rdi, [rdi+1] - shr eax, 8 - mov bl, al - mov byte ptr [rdi], bl - lea rdi, [rdi+1] - -finish: - cmp byte ptr [rdi-1], 48 // '0' - jnz short finish1 - lea rdi, [rdi-1] - jmp short finish - -finish1: - cmp byte ptr [rdi-1], 46 // '.' - jnz short finish2 - lea rdi, [rdi+1] - -finish2: - mov rbx, rdi - pop rdi - add rsp, 104 - pop rbp - - sub rbx, rdi - mov rdx, rbx - - jmp short finish3 - -srcerr: - pop rdi - add rsp, 104 - pop rbp - xor ebx,ebx -finish3: - -/* -oldcw :-4 (4) -truncw :-8 (4) -esize :-12 (4) -tempdw :-16 (4) -bcdstr :-28 (12) // -20 -unpacked:- (52) // -32 -*/ - - ret -end - -// ; s_encode(index,out length, src, dst, out len2) -procedure coreapi's_encode - - mov rbx, [rsp+16] - mov rsi, [rsp+8] - mov ecx, dword ptr [rbx] - mov rdi, [rsp+32] - mov rax, [rsp+24] - - push rdi - add eax, dword ptr [rsi] - push rax - push rbx - -labNext: - xor ebx, ebx - mov bl, byte ptr [rax] - add eax, 1 - cmp ebx, 00000080h - jl lab1 - cmp ebx, 000000C0h - jl err2 - cmp ebx, 000000E0h - jl short lab2 - cmp ebx, 000000F0h - jl lab3 - cmp ebx, 000000F8h - jl lab4 - nop - nop - jmp err2 - -lab2: - sub ecx, 2 - jb short err - mov esi, ebx - mov bl, byte ptr [rax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - shl esi, 6 - add esi, ebx - sub esi, 3080h - jmp labSave - -lab3: - sub ecx, 3 - jb err - mov esi, ebx - mov bl, byte ptr [rax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - cmp esi, 000000E0h - jnz short lab3_1 - cmp ebx, 000000A0h - jl err2 - -lab3_1: - shl esi, 12 - shl ebx, 6 - add esi, ebx - xor ebx, ebx - mov bl, byte ptr [rax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - add esi, ebx - sub esi, 0E2080h - jmp labSave - -lab4: - sub ecx, 4 - jb short err - mov esi, ebx - mov bl, byte ptr [rax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - cmp esi, 000000F0h - jnz short lab4_1 - cmp ebx, 00000090h - jl err2 - -lab4_1: - cmp esi, 000000F4h - jnz short lab4_2 - cmp ebx, 00000090h - jae err2 - -lab4_2: - shl esi, 18 - shl ebx, 12 - add esi, ebx - - xor ebx, ebx - mov bl, byte ptr [rax] - add eax, 1 - mov edx, ebx - and edx, 000000C0h - cmp edx, 00000080h - jnz err2 - - shl ebx, 6 - add esi, ebx - - xor ebx, ebx - mov bl, byte ptr [rax] - add eax, 1 - mov edx, ebx - and edx, 000000C0h - cmp edx, 00000080h - jnz err2 - - add esi, ebx - sub esi, 3C82080h - jmp labSave - -lab1: - mov esi, ebx - sub ecx, 1 - -labSave: - mov dword ptr [rdi], esi - add edi, 4 - - test ecx, ecx - jnz labNext - -err: - pop rbx - mov edx, eax - pop rax - sub edx, eax - mov ecx, edi - pop rdi - sub ecx, edi - shr ecx, 2 - mov rax, [rsp+40] - mov dword ptr [rax], ecx - mov rsi, [rsp+16] - mov dword ptr [rsi], edx - - ret - -err2: - add rsp, 24 - xor ebx, ebx - ret - -end - -// ; s_decode(index,out length, src, dst, out len2) -procedure coreapi's_decode - - mov rbx, [rsp+16] - mov rsi, [rsp+8] - mov ecx, dword ptr [rbx] - mov rdi, [rsp+32] - mov ebx, dword ptr [rsi] - mov rax, [rsp+24] - - push rdi - lea rax, [rax + rbx * 4] - push rax - push rbx - -labNext: - mov ebx, dword ptr [rax] - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 0800h - jl short lab2 - cmp ebx, 10000h - jl short lab3 - - sub ecx, 1 - - mov edx, ebx - shr edx, 18 - and edx, 03Fh - add edx, 000000F0h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ebx - and edx, 03F000h - shr edx, 12 - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ebx - and edx, 0FC0h - shr edx, 6 - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - - jmp labSave - -lab2: - sub ecx, 1 - - mov edx, ebx - shr edx, 6 - add edx, 0C0h - mov byte ptr [rdi], dl - add edi, 1 - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [rdi], bl - add edi, 1 - jmp labSave - -lab3: - sub ecx, 1 - - mov edx, ebx - shr edx, 12 - add edx, 0E0h - mov byte ptr [rdi], dl - add edi, 1 - - mov edx, ebx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [rdi], dl - add edi, 1 - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [rdi], bl - jmp short labSave - -lab1: - mov byte ptr [rdi], bl - add edi, 1 - sub ecx, 1 - -labSave: - add eax, 4 - test ecx, ecx - jnz labNext - -err: - pop rbx - mov edx, eax - pop rax - sub edx, eax - shr edx, 2 - mov ecx, edi - pop rdi - sub ecx, edi - mov rax, [rsp+40] - mov dword ptr [rax], ecx - mov rsi, [rsp+16] - mov dword ptr [rsi], edx - mov ebx, eax - - ret - -end - -procedure coreapi'ws_encode - - mov rbx, [rsp+16] - mov rsi, [rsp+8] - mov ecx, dword ptr [rbx] - mov rdi, [rsp+32] - mov rax, [rsp+24] - - push rdi - add eax, dword ptr [rsi] - push rax - push rbx - -labNext: - mov ebx, dword ptr [rax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0D800h - jl short lab1 - cmp ebx, 0DBFFh - jg short err2 - - sub ecx, 2 - jl short err - - mov esi, ebx - shl esi, 10 - mov ebx, dword ptr [rax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0DC00h - jl short lab2 - cmp ebx, 0DFFFh - jg short err2 - -lab2: - add ebx, esi - sub ebx, 35FDC00h - -lab1: - mov esi, ebx - sub ecx, 2 - -labSave: - mov dword ptr [rdi], esi - add edi, 4 - - test ecx, ecx - jnz labNext - -err: - pop rbx - mov edx, eax - pop rax - sub edx, eax - mov ecx, edi - pop rdi - sub ecx, edi - shr ecx, 2 - mov rax, [rsp+40] - mov dword ptr[rax], ecx - mov rsi, [rsp+16] - mov dword ptr [rsi], edx - - ret - -err2: - add rsp, 24 - xor ebx, ebx - ret - -end - - -procedure coreapi'ws_encodew - - mov rbx, [rsp+16] - mov rsi, [rsp+8] - mov ecx, dword ptr [rbx] - mov rdi, [rsp+32] - shl ecx, 1 - mov rax, [rsp+24] - - push rdi - add eax, dword ptr [rsi] - add eax, dword ptr [rsi] - push rax - push rbx - -labNext: - mov ebx, dword ptr [rax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0D800h - jl short lab1 - cmp ebx, 0DBFFh - jg short err2 - - sub ecx, 2 - jl short err - - mov esi, ebx - shl esi, 10 - mov ebx, dword ptr [rax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0DC00h - jl short lab2 - cmp ebx, 0DFFFh - jg short err2 - -lab2: - add ebx, esi - sub ebx, 35FDC00h - -lab1: - mov esi, ebx - sub ecx, 2 - -labSave: - mov dword ptr [rdi], esi - add edi, 4 - - test ecx, ecx - jnz labNext - -err: - pop rbx - mov edx, eax - pop rax - sub edx, eax - mov ecx, edi - pop rdi - sub ecx, edi - shr ecx, 2 - mov rax, [rsp+40] - mov dword ptr [rax], ecx - - ret - -err2: - add rsp, 24 - xor ebx, ebx - ret - -end - -procedure coreapi'ws_decode - - mov rbx, [rsp+16] - mov rsi, [rsp+8] - mov ecx, dword ptr [rbx] - mov rdi, [rsp+32] - mov ebx, dword ptr [rsi] - mov rax, [rsp+24] - - push rdi - lea rax, [rax + rbx * 4] - push rax - push rbx - -labNext: - mov ebx, dword ptr [rax] - cmp ebx, dword ptr 128 - jl short labCH1 - - cmp ebx, 0800h - jl short lab1 - - sub ecx, 2 - jl short err - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [rdi], dx - add rdi, 2 - - mov edx, ebx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [rdi], dx - add rdi, 2 - jmp short labSave - -lab1: - mov word ptr [rdi], bx - add edi, 2 - sub ecx, 1 - jmp short labSave - -labCH1: - mov word ptr [rdi], bx - add edi, 2 - sub ecx, 1 - -labSave: - add eax, 4 - test ecx, ecx - jnz labNext - -err: - pop rbx - mov edx, eax - pop rax - sub edx, eax - shr edx, 2 - mov ecx, edi - pop rdi - sub ecx, edi - shr ecx, 1 - mov rax, [rsp+40] - mov dword ptr[rax], ecx - mov esi, dword ptr [rsp+16] - mov dword ptr [rsi], edx - mov ebx, eax - - ret - -err2: - add rsp, 24 - xor ebx, ebx - ret - -end - -procedure coreapi'ws_decodew - - mov rbx, [rsp+16] - mov rsi, [rsp+8] - mov ecx, dword ptr [rbx] - mov rdi, [rsp+32] - mov ebx, dword ptr [rsi] - mov rax, [rsp+24] - - push rdi - lea rax, [rax + rbx * 4] - push rax - push rbx - -labNext: - mov ebx, dword ptr [rax] - cmp ebx, dword ptr 128 - jl short labCH1 - - cmp ebx, 0800h - jl short lab1 - - sub ecx, 2 - jl short err - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [rdi], dx - add edi, 2 - - mov edx, ebx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [rdi], dx - add edi, 2 - jmp short labSave - -lab1: - mov word ptr [rdi], bx - add edi, 2 - sub ecx, 1 - jmp short labSave - -labCH1: - mov word ptr [rdi], bx - add edi, 2 - sub ecx, 1 - -labSave: - add eax, 4 - test ecx, ecx - jnz labNext - -err: - pop rbx - mov edx, eax - pop rax - sub edx, eax - shr edx, 2 - mov ecx, edi - pop rdi - sub ecx, edi - shr ecx, 1 - mov rax, [rsp+40] - mov dword ptr [rax], ecx - mov rsi, [rsp+16] - mov dword ptr [rsi], edx - mov ebx, eax - - ret - -err2: - add rsp, 24 - xor ebx, ebx - ret - -end - -procedure coreapi'wstrcharlen - - mov rax, [rsp+8] - mov rcx, [rsp+16] - push rax - -labNext: - mov edx, dword ptr [rax] - and edx, 0FFFFh - cmp edx, 0D800h - jl short lab1 - - add ebx, 1 - add eax, 4 - sub ecx, 2 - jnz short labNext - pop rax - ret - -lab1: - add ebx, 1 - add eax, 2 - sub ecx, 1 - jnz short labNext - mov edx, ebx - pop rax - ret - -end - -// ; strcharlen(s,len) -procedure coreapi'strcharlen - - mov rax, [rsp+8] - mov rcx, [rsp+16] - push rax - - xor edx, edx - xor ebx, ebx - -labNext: - mov dl, byte ptr [rax] - cmp edx, 00000080h - jl short lab1 - cmp edx, 000000E0h - jl short lab2 - cmp edx, 000000F0h - jl short lab3 - cmp edx, 000000F5h - jl short lab4 - -lab1: - add ebx, 1 - add eax, 1 - sub ecx, 1 - jnz short labNext - mov edx, ebx - pop rax - ret - -lab2: - add ebx, 1 - add eax, 2 - sub ecx, 2 - jnz short labNext - mov edx, ebx - pop rax - ret - -lab3: - add ebx, 1 - add eax, 3 - sub ecx, 3 - jnz short labNext - mov edx, ebx - pop rax - ret - -lab4: - add ebx, 1 - add eax, 4 - sub ecx, 4 - jnz short labNext - mov edx, ebx - pop rbx - ret - -end - -procedure coreapi'register_critical_exception_handler - - mov [data : % CORE_ET_TABLE], rbx - ret - -end - -procedure coreapi'get_seh_handler - - mov rdx, data : % CORE_ET_TABLE - ret - -end - -// core_utf8hashcode(s,len) -procedure coreapi'core_utf8hashcode - - mov rax, [rsp+8] - mov rcx, [rsp+16] - - mov edi, 15051505h - mov esi, edi - -labLoop: - cmp ecx, 8 - jb short labSkip - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, dword ptr [rax] - xor ebx, edx - mov edi, ebx - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - mov edx, dword ptr [rax+4] - xor ebx, edx - mov esi, ebx - - add eax, 8 - sub ecx, 8 - jmp short labLoop - - add ecx, 8 - and ecx, 7 - -labSkip: - cmp ecx, 4 - jb short labSkip2 - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, dword ptr [rax] - xor ebx, edx - mov edi, ebx - add eax, 4 - sub ecx, 4 - -labSkip2: - mov ebx, 3 - sub ebx, ecx - shl ebx, 3 - mov ecx, ebx - - mov ebx, 0FFFFFFFFh - shr ebx, cl - mov ecx, dword ptr [rax] - and ecx, ebx - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - xor ebx, ecx - mov esi, ebx - - mov edx, esi - imul edx, 1566083941 - add edx, edi - mov eax, edx - ret - -end - -// core_utf16hashcode(s,len) -procedure coreapi'core_utf16hashcode - - mov rax, [rsp+8] - mov rcx, [rsp+16] - - mov edi, 15051505h - mov esi, edi - -labLoop: - cmp ecx, 4 - jb short labSkip - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, dword ptr [rax] - xor ebx, edx - mov edi, ebx - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - mov edx, dword ptr[rax+4] - xor ebx, edx - mov esi, ebx - - add eax, 8 - sub ecx, 4 - jmp short labLoop - - add ecx, 4 - and ecx, 7 - -labSkip: - cmp ecx, 2 - jb short labSkip2 - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, dword ptr [rax] - xor ebx, edx - mov edi, ebx - add eax, 4 - sub ecx, 2 - -labSkip2: - mov ecx, dword ptr [rax] - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - xor ebx, ecx - mov esi, ebx - - mov ebx, esi - imul ebx, 1566083941 - add ebx, edi - ret - -end - -procedure coreapi'nsubcopy - - mov rdi, [rsp+8] - mov rsi, [rsp+24] - mov rdx, [rsp+8] - mov rax, [rsp+32] - mov ecx, dword ptr [rsi] - mov ebx, dword ptr [rdx] - - mov esi, edi - test ecx, ecx - jz short labEnd - -labNext: - mov rdx, [rax + rbx * 8] - mov [rsi], rdx - add ebx, 1 - lea rsi, [rsi + 8] - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -// ninsert(target,index,len,source) -procedure coreapi'ninsert - - mov rdx, [rsp+16] - mov rax, [rsp+24] - mov rdi, [rsp+8] - mov ecx, dword ptr [rax] - mov rsi, [rsp+32] - mov ebx, dword ptr [rdx] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, dword ptr [rsi] - mov dword ptr [rdi + rbx*4], edx - add ebx, 1 - lea rsi, [rsi + 4] - sub ecx, 1 - jnz short labNext - -labEnd: - mov edx, ebx - mov rbx, rdi - ret - -end - -// ; nmove(target,index,len,offs) -procedure coreapi'nmove - - mov rdi, [rsp+8] - mov rax, [rsp+24] - mov rbx, [rsp+16] - mov ecx, dword ptr[rax] - mov ebx, dword ptr [rbx] - mov rdx, [rsp+32] - - test ecx, ecx - jz short labEnd - - movsxd rsi, dword ptr [rdx] - cmp esi, 0 - jl short labDelete - - add ebx, ecx - sub ebx, 1 - - add esi, ebx - shl esi, 2 - - add esi, edi - shl ebx, 2 - add ebx, edi - -labNext: - mov edx, dword ptr [rbx] - mov dword ptr [rsi], edx - sub ebx, 4 - sub esi, 4 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -labDelete: - add rsi, rbx - shl rsi, 2 - - add rsi, rdi - shl rbx, 2 - add rbx, rdi - -labNext2: - mov edx, dword ptr [rbx] - mov dword ptr [rsi], edx - add ebx, 4 - add esi, 4 - sub ecx, 1 - jnz short labNext2 - ret - -end - -// ; longtoint(l) -procedure coreapi'longtoint - - mov rbx, [rsp+8] - mov ecx, dword ptr [rbx+4] - cmp ecx, 0 - jl labNegative - nop - jnz labErr - mov edx, dword ptr [rbx] - ret -labNegative: - cmp ecx, 0FFFFFFFFh - jnz labErr - mov edx, dword ptr [rbx] - ret - -labErr: - xor ebx, ebx - ret - -end - -procedure coreapi'core_rnd_init - - mov rdi, [rsp+8] - call code : % INIT_RND - mov [rdi], rax - mov rbx, rax - ret - -end - -procedure coreapi'core_rnd_next - - mov rdi, [rsp+8] - mov rax, [rsp+24] - mov rbx, [rsp+16] - - xor rdx, rdx - mov rcx, rbx - cmp rcx, rdx - jle short labEnd - - push rax - push rbx - - mov ebx, dword ptr [rdi+4] // NUM.RE - mov esi, dword ptr [rdi] // NUM.FR - mov eax, ebx - mov ecx, 15Ah - mov ebx, 4E35h - test eax, eax - jz short Lab1 - mul ebx -Lab1: - xchg eax, ecx - mul esi - add eax, ecx - xchg eax, esi - mul ebx - add edx, esi - add eax, 1 - adc edx, 0 - mov ebx, eax - mov esi, edx - mov rcx, rdi - mov dword ptr [rcx+4], ebx - mov eax, esi - and eax, 7FFFFFFFh - mov dword ptr[rcx] , esi - cdq - pop rcx - idiv ecx - pop rax -labEnd: - mov dword ptr [rax], edx - ret - -end - -procedure coreapi'core_rnd_nextint - - mov rdi, [rsp+8] - mov rax, [rsp+16] - - push rax - - mov ebx, dword ptr [rdi+4] // NUM.RE - mov esi, dword ptr [rdi] // NUM.FR - mov eax, ebx - mov ecx, 15Ah - mov ebx, 4E35h - test eax, eax - jz short Lab1 - mul ebx -Lab1: - xchg eax, ecx - imul esi - add eax, ecx - xchg eax, esi - imul ebx - add edx, esi - add eax, 1 - adc edx, 0 - mov ebx, eax - mov esi, edx - mov rcx, rdi - mov dword ptr [rcx+4], ebx - mov eax, esi - and eax, 7FFFFFFFh - mov dword ptr [rcx], esi - mov edx, eax - pop rax -labEnd: - mov dword ptr [rax], edx - ret - -end diff --git a/asm/ppc64le/core60.asm b/asm/ppc64le/core60.asm index 5fd733f812..c2f724c9bc 100644 --- a/asm/ppc64le/core60.asm +++ b/asm/ppc64le/core60.asm @@ -932,6 +932,13 @@ inline %02Ch end +// ; parent +inline %02Dh + + ld r15, -elPackageOffset(r15) + +end + // ; xget inline %02Eh @@ -3788,6 +3795,82 @@ labEnd: end +// ; fillir +inline %3F8h + + li r16, __arg16_1 + li r17, 0 + mr r18, r15 + +labLoop: + cmpwi r16,0 + beq labEnd + addi r16, r16, -1 + std r17, 0(r18) + addi r18, r18, 8 + b labLoop + +labEnd: + +end + +// ; fillir +inline %5F8h + + li r16, __arg16_1 + li r17, 0 + mr r18, r15 + +labLoop: + cmpwi r16,0 + beq labEnd + addi r16, r16, -1 + std r17, 0(r18) + addi r18, r18, 8 + b labLoop + +labEnd: + +end + +// ; fillir +inline %7F8h + + li r16, __arg16_1 + li r17, 0 + mr r18, r15 + +labLoop: + cmpwi r16,0 + beq labEnd + addi r16, r16, -1 + std r17, 0(r18) + addi r18, r18, 8 + b labLoop + +labEnd: + +end + +// ; fillir +inline %9F8h + + li r16, __arg16_1 + li r17, 0 + mr r18, r15 + +labLoop: + cmpwi r16,0 + beq labEnd + addi r16, r16, -1 + std r17, 0(r18) + addi r18, r18, 8 + b labLoop + +labEnd: + +end + // ; xstorefir inline %0F9h diff --git a/asm/x32/core.asm b/asm/x32/core.asm deleted file mode 100644 index 516bdf06c4..0000000000 --- a/asm/x32/core.asm +++ /dev/null @@ -1,3498 +0,0 @@ -// --- Predefined References -- -define GC_ALLOC 10001h -define HOOK 10010h -define INVOKER 10011h -define INIT_RND 10012h -define CALC_SIZE 1001Fh -define GET_COUNT 10020h -define THREAD_WAIT 10021h -define GC_ALLOCPERM 10031h - -define CORE_GC_TABLE 20002h -define CORE_STATICROOT 20005h -define CORE_TLS_INDEX 20007h -define THREAD_TABLE 20008h -define CORE_MESSAGE_TABLE 2000Ah -define CORE_ET_TABLE 2000Bh -define SYSTEM_ENV 2000Ch -define VOID 2000Dh -define VOIDPTR 2000Eh - -// GC TABLE OFFSETS -define gc_header 0000h -define gc_start 0004h -define gc_yg_start 0008h -define gc_yg_current 000Ch -define gc_yg_end 0010h -define gc_shadow 0014h -define gc_shadow_end 0018h -define gc_mg_start 001Ch -define gc_mg_current 0020h -define gc_end 0024h -define gc_mg_wbar 0028h -define gc_et_current 002Ch -define gc_stack_frame 0030h -define gc_lock 0034h -define gc_signal 0038h -define tt_ptr 003Ch -define tt_lock 0040h -define gc_rootcount 004Ch -define gc_perm_start 0050h -define gc_perm_end 0054h -define gc_perm_current 0058h - -// SYSTEM_ENV OFFSETS -define se_mgsize 0014h -define se_ygsize 001Ch - -// Page Size -define page_size 10h -define page_size_order 4h -define page_size_order_minus2 2h -define page_mask 0FFFFFFF0h -define page_ceil 17h -define struct_mask 800000h -define struct_mask_inv 7FFFFFh - -// Object header fields -define elSizeOffset 0004h -define elVMTOffset 0008h -define elObjectOffset 0008h - -define elPageSizeOffset 0004h -define elPageVMTOffset 0000h - -// VMT header fields -define elVMTSizeOffset 0004h -define elVMTFlagOffset 000Ch -define elPackageOffset 0010h - -define page_align_mask 000FFFF0h - -define ACTION_ORDER 9 -define ARG_ACTION_MASK 1DFh -define ACTION_MASK 1E0h -define ARG_MASK 01Fh -define ARG_MASK_INV 0FFFFFFE0h - -// --- System Core Preloaded Routines -- - -structure % CORE_ET_TABLE - - dd 0 // ; critical_exception ; +x00 - pointer to critical exception handler - -end - -structure %CORE_GC_TABLE - - dd 0 // ; gc_header : +00h - dd 0 // ; gc_start : +04h - dd 0 // ; gc_yg_start : +08h - dd 0 // ; gc_yg_current : +0Ch - dd 0 // ; gc_yg_end : +10h - dd 0 // ; gc_shadow : +14h - dd 0 // ; gc_shadow_end : +18h - dd 0 // ; gc_mg_start : +1Ch - dd 0 // ; gc_mg_current : +20h - dd 0 // ; gc_end : +24h - dd 0 // ; gc_mg_wbar : +28h - dd 0 // ; gc_et_current : +2Ch - dd 0 // ; gc_stack_frame : +30h - dd 0 // ; gc_lock : +34h - dd 0 // ; gc_signal : +38h - dd 0 // ; tt_ptr : +3Ch - dd 0 // ; tt_lock : +40h - dd 0 // ; dbg_ptr : +44h - dd 0 // ; gc_roots : +48h - dd 0 // ; gc_rootcount : +4Ch - dd 0 // ; gc_perm_start : +50h - dd 0 // ; gc_perm_end : +54h - dd 0 // ; gc_perm_current : +58h - -end - -// ; NOTE : the table is tailed with GCMGSize,GCYGSize and MaxThread fields -rstructure %SYSTEM_ENV - - dd 0 - dd data : %CORE_STATICROOT - dd data : %CORE_GC_TABLE - dd data : %CORE_TLS_INDEX - dd data : %THREAD_TABLE - dd code : %INVOKER - -end - -rstructure %VOID - - dd 0 - dd 0 // ; a reference to the super class class - dd 0 - dd 0 - dd 0 - -end - -rstructure %VOIDPTR - - dd rdata : %VOID + elPackageOffset - dd 0 - dd 0 - -end - -// --- GC_ALLOC --- -// in: ecx - size ; out: ebx - created object -procedure %GC_ALLOC - - mov eax, [data : %CORE_GC_TABLE + gc_yg_current] - mov edx, [data : %CORE_GC_TABLE + gc_yg_end] - add ecx, eax - cmp ecx, edx - jae short labYGCollect - mov [data : %CORE_GC_TABLE + gc_yg_current], ecx - lea ebx, [eax + elObjectOffset] - ret - -labYGCollect: - // ; restore ecx - sub ecx, eax - - // ; save registers - push ebp - - // ; lock frame - mov [data : %CORE_GC_TABLE + gc_stack_frame], esp - - push ecx - - // ; create set of roots - mov ebp, esp - xor ecx, ecx - push ecx // ; reserve place - push ecx - push ecx - - // ; save static roots - mov esi, data : %CORE_STATICROOT - mov ecx, [data : %CORE_GC_TABLE + gc_rootcount] - push esi - push ecx - - // ; collect frames - mov eax, [data : %CORE_GC_TABLE + gc_stack_frame] - mov ecx, eax - -labYGNextFrame: - mov esi, eax - mov eax, [esi] - test eax, eax - jnz short labYGNextFrame - - push ecx - sub ecx, esi - neg ecx - push ecx - - mov eax, [esi + 4] - test eax, eax - mov ecx, eax - jnz short labYGNextFrame - - mov [ebp-4], esp // ; save position for roots - - mov ebx, [ebp] - mov eax, esp - - // ; restore rbp to correctly display a call stack - mov edx, ebp - mov ebp, [edx+4] - - push edx - push ebx - push eax - call extern 'rt_dlls.GCCollect - - mov ebx, eax - add esp, 8 - pop ebp - - mov esp, ebp - pop ecx - pop ebp - - ret - -end - -// --- GC_ALLOCPERM --- -// in: ecx - size ; out: ebx - created object -procedure %GC_ALLOCPERM - - mov eax, [data : %CORE_GC_TABLE + gc_perm_current] - mov edx, [data : %CORE_GC_TABLE + gc_perm_end] - add ecx, eax - cmp ecx, edx - jae short labPERMCollect - mov [data : %CORE_GC_TABLE + gc_perm_current], ecx - lea ebx, [eax + elObjectOffset] - ret - -labPERMCollect: - // ; restore ecx - sub ecx, eax - - // ; lock frame - mov [data : %CORE_GC_TABLE + gc_stack_frame], esp - - push ecx - call extern 'rt_dlls.GCCollectPerm - - mov ebx, eax - add esp, 4 - - ret - -end - -// ; --- HOOK --- -// ; in: ecx - catch offset -procedure %HOOK - - mov eax, [esp] - lea ecx, [eax + ecx - 5] - ret - -end - -// --- System Core Functions -- - -procedure % THREAD_WAIT - - ret - -end - -procedure % CALC_SIZE - - mov ecx, edx - add ecx, page_ceil - and ecx, page_mask - - ret - -end - -procedure % GET_COUNT - - mov edx, [ebx - elSizeOffset] - test edx, struct_mask - jnz short labErr - and edx, 0FFFFFFh - shr edx, 2 - ret - -labErr: - xor edx, edx - ret - -end - -// ; ==== Command Set == - -// ; coalesce -inline % 2 - - mov eax, [esp] - test ebx, ebx - cmovz ebx, eax - -end - -// ; peek -inline % 3 - - mov eax, [esp] - mov ebx, [eax+edx*4] - -end - -// ; snop -inline % 4 - - nop - -end - -// ; pushverb -inline % 5 - - mov eax, edx - mov ecx, edx - shr eax, ACTION_ORDER - mov edi, rdata : % CORE_MESSAGE_TABLE - test ecx, ecx - cmovs eax, [edi + edx] - push eax - -end - -// ; loadverb -inline % 6 - - mov ecx, edx - shr edx, ACTION_ORDER - mov eax, rdata : % CORE_MESSAGE_TABLE - test ecx, ecx - cmovs edx, [eax + edx] - -end - -// ; throw -inline % 7 - - mov eax, [data : %CORE_GC_TABLE + gc_et_current] - jmp [eax] - -end - -// ; push -inline % 09h - - mov eax, [ebx + edx * 4] - push eax - -end - -// ; xnew -inline % 0Ch - - mov eax, [esp] - mov ecx, page_ceil - push ebx - mov edx, [eax] - lea ecx, [ecx + edx*4] - and ecx, page_mask - - call code : %GC_ALLOC - - pop edi - mov eax, [esp] - xor edx, edx - mov [ebx-elVMTOffset], edi - mov ecx, [eax] - mov esi, struct_mask - test ecx, ecx - cmovz edx, esi - shl ecx, 2 - or ecx, edx - mov [ebx-elSizeOffset], ecx - -end - -// ; storev -inline % 0Dh - - mov eax, edx - and eax, ACTION_MASK - mov ecx, [esp] - and ecx, ARG_MASK - or ecx, edx - mov [esp], ecx - -end - -// ; bsredirect -inline % 0Eh // (ebx - object, edx - message) - - mov edi, [ebx - elVMTOffset] - xor ecx, ecx - mov esi, [edi - elVMTSizeOffset] - -labSplit: - test esi, esi - jz short labEnd - -labStart: - shr esi, 1 - setnc cl - cmp edx, [edi+esi*8] - je short labFound - lea eax, [edi+esi*8] - jb short labSplit - lea edi, [eax+8] - sub esi, ecx - jmp labSplit - nop - nop -labFound: - jmp [edi+esi*8+4] - -labEnd: - -end - -// ; setv -inline % 0Fh - - mov eax, [ebx] - and eax, ARG_ACTION_MASK - mov ecx, edx - shl ecx, ACTION_ORDER - or eax, ecx - mov [ebx], eax - -end - -// ; open -inline % 11h - - push ebp - mov ebp, esp - -end - -// ; sub -inline % 13h - - sub edx, [ebx] - -end - -// ; swapd -inline % 14h - - mov eax, [esp] - mov [esp], edx - mov edx, eax - -end - -// ; close -inline % 15h - - mov esp, ebp - pop ebp - -end - -// ; rexp -inline % 16h - - mov eax, [esp] - mov edx, 0 - fld qword ptr [eax] // ; Src - - fldl2e // ; ->log2(e) - fmulp // ; ->log2(e)*Src - - // ; the FPU can compute the antilog only with the mantissa - // ; the characteristic of the logarithm must thus be removed - - fld st(0) // ; copy the logarithm - frndint // ; keep only the characteristic - fsub st(1),st(0) // ; keeps only the mantissa - fxch // ; get the mantissa on top - - f2xm1 // ; ->2^(mantissa)-1 - fld1 - faddp // ; add 1 back - - //; the number must now be readjusted for the characteristic of the logarithm - - fscale // ;, scale it with the characteristic - - fstsw ax // ; retrieve exception flags from FPU - shr al,1 // ; test for invalid operation - jc short lErr // ; clean-up and return if error - - // ; the characteristic is still on the FPU and must be removed - - fstp st(1) // ; get rid of the characteristic - - fstp qword ptr [ebx] // ; store result - mov edx, 1 - jmp short labEnd - -lErr: - ffree st(1) - -labEnd: - -end - -// ; get -inline % 18h - - mov ebx, [ebx + edx * 4] - -end - -// ; set -inline % 19h - - // ; calculate write-barrier address - mov ecx, ebx - mov esi, [data : %CORE_GC_TABLE + gc_header] - sub ecx, [data : %CORE_GC_TABLE + gc_start] - mov eax, [esp] - shr ecx, page_size_order - mov [ebx + edx*4], eax - mov byte ptr [ecx + esi], 1 - -end - -// ; swap -inline % 1Ah - - mov eax, [esp] - mov [esp], ebx - mov ebx, eax - -end - -// ; mquit -inline % 1Bh - - mov ecx, edx - pop esi - and ecx, ARG_MASK - lea esp, [esp + ecx * 4] - jmp esi - nop - nop - -end - -// ; count -inline % 1Ch - - mov ecx, 0FFFFFh - mov edx, [ebx-elSizeOffset] - and edx, ecx - shr edx, 2 - -end - -// ; unhook -inline % 1Dh - - mov esi, [data : %CORE_GC_TABLE + gc_et_current] - mov esp, [esi + 4] - mov ebp, [esi + 8] - pop ecx - mov [data : %CORE_GC_TABLE + gc_et_current], ecx - -end - -// ; rsin -inline % 1Eh - - mov eax, [esp] - fld qword ptr [eax] - fldpi - fadd st(0),st(0) // ; ->2pi - fxch - -lReduce: - fprem // ; reduce the angle - fsin - fstsw ax // ; retrieve exception flags from FPU - shr al,1 // ; test for invalid operation - // ; jc short lErr // ; clean-up and return error - sahf // ; transfer to the CPU flags - jpe short lReduce // ; reduce angle again if necessary - fstp st(1) // ; get rid of the 2pi - - fstp qword ptr [ebx] // ; store result - -end - -// ; allocd -inline % 1Fh - - mov ecx, edx - mov edi, edx - shl edi, 2 - sub esp, edi - xor eax, eax - mov edi, esp - rep stos - -end - -// ; rcos -inline % 20h - - mov eax, [esp] - fld qword ptr [eax] - fcos - fstp qword ptr [ebx] // store result - -end - -// ; rarctan -inline % 21h - - mov eax, [esp] - fld qword ptr [eax] - fld1 - fpatan // i.e. arctan(Src/1) - fstp qword ptr [ebx] // store result - -end - -// ; xtrans -inline % 24h - - mov eax, [esp] - mov ecx, [eax+edx*4] - mov [ebx+edx*4], ecx - -end - -// ; include -inline % 25h - - add esp, 4 - -end - -// ; exclude -inline % 26h - - push ebp - mov [data : %CORE_GC_TABLE + gc_stack_frame], esp - -end - -// ; trylock -inline % 27h - - xor edx, edx - -end - -// ; freelock -inline % 28h - - nop - -end - -// ; freed -inline % 29h - - mov edi, edx - shl edi, 2 - add esp, edi - -end - -// ; loadenv -inline % 2Ah - - mov edx, rdata : %SYSTEM_ENV - -end - -// ; store -inline % 2Bh - - mov eax, [esp] - mov dword ptr [eax+edx*4], ebx - -end - -// ; rln -inline % 2Ch - - mov eax, [esp] - mov edx, 0 - fld qword ptr [eax] - - fldln2 - fxch - fyl2x // ->[log2(Src)]*ln(2) = ln(Src) - - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc short lErr // clean-up and return error - - fstp qword ptr [ebx] // store result - mov edx, 1 - jmp short labEnd - -lErr: - ffree st(0) - -labEnd: - -end - -// ; read -inline % 2Dh - - mov edx, [ebx + edx] - -end - -// ; clone -inline % 02Eh - - mov ecx, [ebx - elSizeOffset] - mov esi, [esp] - and ecx, struct_mask_inv - mov edi, ebx - add ecx, 3 - shr ecx, 2 - rep movsd - -end - -// ; xset -inline % 2Fh - - mov eax, [esp] - mov [ebx + edx * 4], eax - -end - -// ; rabs -inline %30h - - mov eax, [esp] - fld qword ptr [eax] - fabs - fstp qword ptr [ebx] // ; store result - -end - -// ; len -inline % 31h - - mov edx, 0FFFFFh - mov ecx, [ebx-elSizeOffset] - and edx, ecx - -end - -// ; rload -inline %32h - - fld qword ptr [ebx] - -end - -// ; flag -inline % 33h - - mov eax, [ebx - elVMTOffset] - mov edx, [eax - elVMTFlagOffset] - -end - -// ; parent -inline % 35h - - mov ebx, [ebx - elPackageOffset] - -end - -// ; class -inline % 36h - - mov ebx, [ebx - elVMTOffset] - -end - -// ; mindex -inline % 37h - - mov ecx, edx - mov edi, [ebx - elVMTOffset] - xor edx, edx - mov esi, [edi - elVMTSizeOffset] - -labSplit: - test esi, esi - jz short labEnd - -labStart: - shr esi, 1 - setnc dl - cmp ecx, [edi+esi*8] - jb short labSplit - nop - nop - jz short labFound - lea edi, [edi+esi*8+8] - sub esi, edx - jnz short labStart - nop - nop -labEnd: - mov edx, 0FFFFFFFFh -labFound: - -end - -// ; rround -inline %3Dh - - mov eax, [esp] - mov edx, 0 - fld qword ptr [eax] - - push eax // ; reserve space on CPU stack - - fstcw word ptr [esp] // ;get current control word - mov ax,[esp] - and ax,0F3FFh // ; code it for rounding - push eax - fldcw word ptr [esp] // ; change rounding code of FPU to round - - frndint // ; round the number - pop eax // ; get rid of last push - fldcw word ptr [esp] // ; load back the former control word - - fstsw ax // ; retrieve exception flags from FPU - shr al,1 // ; test for invalid operation - pop ecx // ; clean CPU stack - jc short lErr // ; clean-up and return error - - fstp qword ptr [ebx] // ; store result - mov edx, 1 - jmp short labEnd - -lErr: - ffree st(0) - -labEnd: - -end - -// ; equal -inline % 3Eh - - mov eax, [esp] - xor edx, edx - cmp eax, ebx - setz dl - -end - -// ; nequal -inline % 40h - - mov eax, [esp] - xor edx, edx - mov ecx, [ebx] - cmp ecx, [eax] - setz dl - -end - -// ; nless -inline % 41h - - mov eax, [esp] - xor edx, edx - mov ecx, [ebx] - cmp ecx, [eax] - setl dl - -end - -// ; lequal - -inline % 43h - - mov edi, [esp] - mov ecx, [ebx] - xor edx, edx - mov esi, [ebx+4] - cmp ecx, [edi] - setz dl - cmp esi, [edi+4] - setz cl - and dl, cl - -end - -// ; lless(lo, ro, tr, fr) -inline % 44h - - mov edi, [esp] - xor edx, edx - xor ecx, ecx - mov esi, [ebx] - cmp esi, [edi] - setl cl - mov esi, [ebx+4] - cmp esi, [edi+4] - setl dl - cmovz edx, ecx - -end - -// ; rset (src, tgt) -inline % 45h - - push edx - fild dword ptr [esp] - pop edx - -end - -// ; rsave -inline % 46h - - fstp qword ptr [ebx] - -end - -// ; save -inline % 47h - - mov [ebx], edx - -end - -// ; load -inline % 48h - - mov edx, [ebx] - -end - -// ; rsaven -inline % 49h - - fistp dword ptr [ebx] - -end - -// ; rsavel -inline % 4Ah - - fistp qword ptr [ebx] - -end - -// ; lsave -inline % 4Bh - - mov [ebx], edx - mov [ebx+4], edi - -end - -// ; lload -inline % 4Ch - - mov eax, edx - cdq - mov [ebx+4], edx - mov [ebx], eax - mov edx, eax - -end - -// ; rint -inline % 4Fh - - mov eax, [esp] - mov ecx, 0 - fld qword ptr [eax] - - push ecx // reserve space on stack - fstcw word ptr [esp] // get current control word - mov dx, [esp] - or dx,0c00h // code it for truncating - push edx - fldcw word ptr [esp] // change rounding code of FPU to truncate - - frndint // truncate the number - pop edx // remove modified CW from CPU stack - fldcw word ptr [esp] // load back the former control word - pop edx // clean CPU stack - - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc short labErr // clean-up and return error - -labSave: - fstp qword ptr [ebx] // store result - mov ecx, 1 - jmp short labEnd - -labErr: - ffree st(1) - -labEnd: - mov edx, ecx - -end - -// ; addf -inline % 050h - - lea esi, [ebp+__arg1] - add [esi], edx - -end - -// ; subf -inline % 051h - - lea esi, [ebp+__arg1] - sub [esi], edx - -end - -// ; nxorf -inline % 52h - - mov ecx, [ebx] - xor [ebp+__arg1], ecx - -end - -// ; norf -inline % 53h - - mov ecx, [ebx] - or [ebp+__arg1], ecx - -end - -// ; nandf -inline % 54h - - mov ecx, [ebx] - and [ebp+__arg1], ecx - -end - -// ; movfipd -inline % 55h - - lea ecx, [edx*4] - lea ebx, [ebp+__arg1] - sub ebx, ecx - -end - -// ; div -inline %05Bh - - mov eax, edx - mov ecx, __arg1 - xor edx, edx - idiv ecx - mov edx, eax - -end - -// ; xwrite -inline % 5Ch - - mov esi, [esp] - mov ecx, __arg1 - lea edi, [ebx+edx] - rep movsb - -end - -// ; xwrite -inline % 15Ch - - mov ecx, [esp] - lea edi, [ebx+edx] - mov eax, [ecx] - mov byte ptr [edi], al - -end - -// ; xwrite -inline % 25Ch - - mov ecx, [esp] - lea edi, [ebx+edx] - mov eax, [ecx] - mov word ptr [edi], ax - -end - -// ; xwrite -inline % 35Ch - - mov ecx, [esp] - lea edi, [ebx+edx] - mov eax, [ecx] - mov dword ptr [edi], eax - -end - -// ; xwrite -inline % 45Ch - - mov ecx, [esp] - lea edi, [ebx+edx] - mov esi, [ecx+4] - mov eax, [ecx] - mov dword ptr [edi], eax - mov dword ptr [edi+4], esi - -end - -// ; xsave -inline % 5Ah - - lea eax, [ebx+__arg1] - mov [eax], edx - -end - -// ; copyto -inline % 5Dh - - lea edi, [ebx+edx] - mov ecx, __arg1 - mov esi, [esp] - rep movsd - -end - -// ; copyto -inline % 15Dh - - mov esi, [esp] - lea edi, [ebx+edx] - mov eax, [esi] - mov [edi], eax - -end - -// ; copyto -inline % 25Dh - - mov esi, [esp] - lea edi, [ebx+edx] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - -end - -// ; copyto -inline % 35Dh - - mov esi, [esp] - lea edi, [ebx+edx] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov eax, [esi+8] - mov [edi+4], ecx - mov [edi+8], eax - -end - -// ; copyto -inline % 45Dh - - mov esi, [esp] - lea edi, [ebx+edx] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - mov eax, [esi+8] - mov [edi+8], eax - mov ecx, [esi+12] - mov [edi+12], ecx - -end - -// ; nshlf -inline % 5Eh - - mov eax, [ebp+__arg1] - mov ecx, [ebx] - shl eax, cl - mov [ebp+__arg1], eax - -end - -// ; nshrf -inline % 5Fh - - mov eax, [ebp+__arg1] - mov ecx, [ebx] - shr eax, cl - mov [ebp+__arg1], eax - -end - -// ; mul -inline %060h - - mov eax, edx - mov ecx, __arg1 - imul ecx - mov edx, eax - -end - -// ; checksi -inline % 061h - - mov edi, [esp+__arg1] - xor edx, edx - mov esi, [ebx-elVMTOffset] -labNext: - mov eax, 0 - cmp esi, edi - mov esi, [esi - elPackageOffset] - setz dl - cmovnz eax, esi - and eax, eax - jnz short labNext - -end - -// ; xredirect -inline % 062h - - lea ebx, [ebx + __arg2] // ; NOTE use __arg2 due to current implementation - push ebx - push edx - - mov esi, [ebx] // ; get next overload list - test esi, esi - jz labEnd - -labNextList: - xor edx, edx - mov ebx, [esi] // ; message from overload list - -labNextOverloadlist: - shr ebx, ACTION_ORDER - mov edi, rdata : % CORE_MESSAGE_TABLE - mov ecx, [esp] - mov ebx, [edi + ebx * 8 + 4] - and ecx, ARG_MASK - lea ebx, [edi + ebx - 4] - inc ecx - -labNextParam: - sub ecx, 1 - jnz short labMatching - - pop eax - pop esi - mov ecx, edx - mov esi, [esi] - mov ebx, [esp] - mov edx, [esi + ecx * 8] - jmp [esi + ecx * 8 + 4] - -labMatching: - mov edi, [eax + ecx * 4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi - elVMTOffset] - mov esi, [ebx + ecx * 4] - -labNextBaseClass: - cmp esi, edi - jz labNextParam - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov esi, [esp+4] - add edx, 1 - mov esi, [esi] - mov ebx, [esi + edx * 8] // ; message from overload list - and ebx, ebx - jnz labNextOverloadlist - add [esp+4], 4 - mov esi, [esp+4] - mov edx, [esi] - test edx, edx - jnz labNextList - -labEnd: - pop edx - pop ebx - -end - -// ; xvredirect -inline % 063h - - lea ebx, [ebx + __arg2] // ; NOTE use __arg2 due to current implementation - push ebx - push edx - - mov esi, [ebx] // ; get next overload list - test esi, esi - jz labEnd - -labNextList: - xor edx, edx - mov ebx, eax - xor ecx, ecx - -labCountParam: - lea ebx, [ebx+4] - cmp [ebx], -1 - lea ecx, [ecx+1] - jnz short labCountParam - - push ecx - mov ebx, [esi] // ; message from overload list - -labNextOverloadlist: - mov edi, rdata : % CORE_MESSAGE_TABLE - shr ebx, ACTION_ORDER - mov ecx, [esp] // ; param count - mov ebx, [edi + ebx * 8 + 4] - lea ebx, [edi + ebx - 4] - -labNextParam: - // ; check if signature contains the next class ptr - lea esi, [ebx + 4] - cmp [esi], 0 - cmovnz ebx, esi - - sub ecx, 1 - jnz short labMatching - - lea esp, [esp + 4] - pop eax - pop esi - mov ecx, edx - mov esi, [esi] - mov ebx, [esp] - mov edx, [esi + ecx * 8] - jmp [esi + ecx * 8 + 4] - -labMatching: - mov esi, [esp] - sub esi, ecx - mov edi, [eax + esi * 4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi - elVMTOffset] - mov esi, [ebx] - -labNextBaseClass: - cmp esi, edi - jz labNextParam - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov esi, [esp+8] - add edx, 1 - mov esi, [esi] - mov ebx, [esi + edx * 8] // ; message from overload list - and ebx, ebx - jnz labNextOverloadlist - - add [esp+8], 4 - mov esi, [esp+8] - mov edx, [esi] - test edx, edx - jnz labNextList - -labEnd: - lea esp, [esp + 4] - pop edx - pop ebx - -end - -// ; laddf -inline % 74h - - lea edi, [ebp+__arg1] - mov eax, [ebx+4] - mov ecx, [ebx] - add [edi], ecx - adc [edi+4], eax - -end - -// ; lsubf -inline % 75h - - lea edi, [ebp+__arg1] - mov esi, [edi] - mov ecx, [edi+4] - sub esi, [ebx] - sbb ecx, [ebx+4] - mov [edi], esi - mov [edi+4], ecx - -end - -// ; lmulf -inline % 76h - - lea edi, [ebp+__arg1] - mov esi, ebx // sour - mov edx, edi // dest - - push ebx - - mov ecx, [edx+4] // DHI - mov eax, [esi+4] // SHI - or eax, ecx - mov ecx, [edx] // DLO - jnz short lLong - mov eax, [esi] - mul ecx - jmp short lEnd - -lLong: - mov eax, [esi+4] - mov edi, edx - mul ecx // SHI * DLO - mov ebx, eax - mov eax, dword ptr [esi] - mul dword ptr [edi+4] // SLO * DHI - add ebx, eax - mov eax, dword ptr [esi] // SLO * DLO - mul ecx - add edx, ebx - -lEnd: - mov [edi], eax - mov [edi+4], edx - pop ebx - -end - -// ; ldiv -inline % 77h - - lea edi, [ebp+__arg1] - mov esi, edi // ; esi - DVND, ebx - DVSR - - push ebx - - push [esi+4] // ; DVND hi dword - push [esi] // ; DVND lo dword - push [ebx+4] // ; DVSR hi dword - push [ebx] // ; DVSR lo dword - - xor edi, edi - - mov eax, [esp+0Ch] // hi DVND - or eax, eax - jge short L1 - add edi, 1 - mov edx, [esp+8] // lo DVND - neg eax - neg edx - sbb eax, 0 - mov [esp+0Ch], eax // hi DVND - mov [esp+8], edx // lo DVND - -L1: - mov eax, [esp+4] // hi DVSR - or eax, eax - jge short L2 - add edi, 1 - mov edx, [esp] // lo DVSR - neg eax - neg edx - sbb eax, 0 - mov [esp+4], eax // hi DVSR - mov [esp], edx // lo DVSR - -L2: - or eax, eax - jnz short L3 - mov ecx, [esp] // lo DVSR - mov eax, [esp+0Ch] // hi DVND - xor edx, edx - div ecx - mov ebx, eax - mov eax, [esp+8] // lo DVND - div ecx - - mov esi, eax // result - jmp short L4 - -L3: - mov ebx, eax - mov ecx, [esp] // lo DVSR - mov edx, [esp+0Ch] // hi DVND - mov eax, [esp+8] // lo DVDN -L5: - shr ebx, 1 - rcr ecx, 1 - shr edx, 1 - rcr eax, 1 - or ebx, ebx - jnz short L5 - div ecx - mov esi, eax // result - - // check the result with the original - mul [esp+4] // hi DVSR - mov ecx, eax - mov eax, [esp] // lo DVSR - mul esi - add edx, ecx - - // carry means Quotient is off by 1 - jb short L6 - - cmp edx, [esp+0Ch] // hi DVND - ja short L6 - jb short L7 - cmp eax, [esp+8] // lo DVND - jbe short L7 - -L6: - sub esi, 1 - -L7: - xor ebx, ebx - -L4: - mov edx, ebx - mov eax, esi - - sub edi, 1 - jnz short L8 - neg edx - neg eax - sbb edx, 0 - -L8: - lea esp, [esp+10h] - lea edi, [ebp+__arg1] - - mov [edi], eax - mov [edi+4], edx - pop ebx - -end - - -// ; landf -inline % 78h - lea edi, [ebp+__arg1] - mov eax, ebx - mov ebx, [edi] - mov edx, [eax] - - mov ecx, [edi+4] - mov esi, [eax+4] - - and ebx, edx - and ecx, esi - - mov [edi], ebx - mov [edi+4], ecx - mov ebx, eax -end - -// ; lorf -inline % 79h - lea edi, [ebp+__arg1] - mov eax, ebx - mov ebx, [edi] - mov edx, [eax] - - mov ecx, [edi+4] - mov esi, [eax+4] - - or ebx, edx - or ecx, esi - - mov [edi], ebx - mov [edi+4], ecx - mov ebx, eax -end - -// ; lxorf -inline % 7Ah - lea edi, [ebp+__arg1] - mov eax, ebx - mov ebx, [edi] - mov edx, [eax] - - mov ecx, [edi+4] - mov esi, [eax+4] - - xor ebx, edx - xor ecx, esi - - mov [edi], ebx - mov [edi+4], ecx - mov ebx, eax -end - -// ; lshlf -inline % 7Bh - - mov eax, ebx - lea edi, [ebp+__arg1] - mov ecx, edx - mov edx, [edi] - mov ebx, [edi+4] - - cmp cl, 40h - jae short lErr - cmp cl, 20h - jae short LL32 - shld edx, ebx, cl - shl ebx, cl - jmp short lEnd - -LL32: - mov ebx, edx - xor edx, edx - sub cl, 20h - shl ebx, cl - jmp short lEnd - -lErr: - xor eax, eax - jmp short lEnd2 - -lEnd: - mov [edi], edx - mov [edi+4], ebx - -lEnd2: - mov ebx, eax - -end - -// ; lshrf -inline % 7Dh - - mov eax, ebx - lea edi, [ebp+__arg1] - mov ecx, edx - mov edx, [edi] - mov ebx, [edi+4] - - cmp cl, 64 - jae short lErr - - cmp cl, 32 - jae short LR32 - shrd edx, ebx, cl - sar ebx, cl - jmp short lEnd - -LR32: - mov edx, ebx - xor ebx, ebx - sub cl, 20h - shr edx, cl - jmp short lEnd - -lErr: - xor eax, eax - jmp short lEnd2 - -lEnd: - mov [edi], edx - mov [edi+4], ebx - -lEnd2: - mov ebx, eax - -end - -// ; raddnf -inline % 80h - - lea edi, [ebp+__arg1] - fild dword ptr [ebx] - fadd qword ptr [edi] - fstp qword ptr [edi] - -end - -// ; rsubnf -inline % 81h - - lea edi, [ebp+__arg1] - fld qword ptr [edi] - fisub dword ptr [ebx] - fstp qword ptr [edi] - -end - -// ; rmulnf -inline % 82h - - lea edi, [ebp+__arg1] - fld qword ptr [edi] - fimul dword ptr [ebx] - fstp qword ptr [edi] - -end - -// ; requal -inline % 83h - - mov edi, [esp] - fld qword ptr [edi] - fld qword ptr [ebx] - xor edx, edx - fcomip st, st(1) - sete dl - fstp st(0) - -end - -// ; rless(lo, ro, tr, fr) -inline % 84h - - mov edi, [esp] - fld qword ptr [edi] - fld qword ptr [ebx] - xor edx, edx - fcomip st, st(1) - setb dl - fstp st(0) - -end - -// ; raddf -inline % 85h - - lea edi, [ebp+__arg1] - fld qword ptr [ebx] - fadd qword ptr [edi] - fstp qword ptr [edi] - -end - -// ; rsubf -inline % 86h - - lea edi, [ebp+__arg1] - fld qword ptr [edi] - fsub qword ptr [ebx] - fstp qword ptr [edi] - -end - -// ; rmulf -inline % 87h - - lea edi, [ebp+__arg1] - fld qword ptr [edi] - fmul qword ptr [ebx] - fstp qword ptr [edi] - -end - -// ; rdivf -inline % 88h - - lea edi, [ebp+__arg1] - fld qword ptr [edi] - fdiv qword ptr [ebx] - fstp qword ptr [edi] - -end - -// ; rdivnf -inline % 89h - - lea edi, [ebp+__arg1] - fld qword ptr [edi] - fidiv dword ptr [ebx] - fstp qword ptr [edi] - -end - -// ; rintf - -inline % 8Eh - - lea edi, [ebp+__arg1] - mov ecx, 0 - fld qword ptr [ebx] - - push ecx // reserve space on stack - fstcw word ptr [esp] // get current control word - mov dx, [esp] - or dx,0c00h // code it for truncating - push edx - fldcw word ptr [esp] // change rounding code of FPU to truncate - - frndint // truncate the number - pop edx // remove modified CW from CPU stack - fldcw word ptr [esp] // load back the former control word - pop edx // clean CPU stack - - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc short labErr // clean-up and return error - -labSave: - fstp qword ptr [edi] // store result - mov edx, 1 - jmp short labEnd - -labErr: - ffree st(1) - -labEnd: - -end - -// ; geti -inline % 91h - - mov ebx, [ebx+__arg1] - -end - -// ; restore -inline % 92h - - add ebp, __arg1 - -end - -// ; peekfi -inline % 94h - - mov ebx, [ebp+__arg1] - -end - -// ; peeksi -inline % 95h - - mov ebx, [esp+__arg1] - -end - -// ; ifheap - part of the command -inline % 96h - - xor edx, edx - mov eax,[data : %CORE_GC_TABLE + gc_start] - mov esi, 1 - mov ecx,[data : %CORE_GC_TABLE + gc_end] - cmp ebx, eax - cmovl edx, esi - cmp ebx, ecx - cmovg edx, esi - and edx, edx - -end - -// ; xseti -inline %97h - - mov eax, [esp] - mov [ebx + __arg1], eax - -end - -// ; create -inline % 9Ah - - mov eax, [esp] - mov ecx, page_ceil - mov edx, [eax] - lea ecx, [ecx + edx*4] - and ecx, page_mask - - call code : %GC_ALLOC - - mov eax, [esp] - xor edx, edx - mov [ebx-elVMTOffset], __arg1 - mov ecx, [eax] - mov esi, struct_mask - test ecx, ecx - cmovz edx, esi - shl ecx, 2 - or ecx, edx - mov [ebx-elSizeOffset], ecx - -end - -// ; fillr (__arg1 - r) -inline % 09Bh - mov esi, [esp] - mov eax, __arg1 - mov edi, ebx - mov ecx, [esi] - rep stosd - -end - -// ; ajumpvi -inline % 0A1h - - mov eax, [ebx - elVMTOffset] - jmp [eax + __arg1] - -end - -// ; callvi (ecx - offset to VMT entry) -inline % 0A2h - - mov eax, [ebx - elVMTOffset] - call [eax + __arg1] - -end - -// ; hook label (ecx - offset) -// ; NOTE : hook calling should be the first opcode -inline % 0A6h - - call code : %HOOK - - push [data : %CORE_GC_TABLE + gc_et_current] - - mov edx, esp - push ebp - push edx - push ecx - - mov [data : %CORE_GC_TABLE + gc_et_current], esp - -end - -// ; address label (ecx - offset) -inline % 0A7h - - call code : %HOOK - mov edx, ecx - -end - -// ; calli -inline % 0A8h - - mov esi, [ebx + __arg1] - call esi - -end - -// ; ifcount -// ; - partial opcode -inline % 0AFh - - mov ecx, 0FFFFFh - mov eax, [ebx-elSizeOffset] - and eax, ecx - shr eax, 2 - cmp eax, edx - -end - -// ; movn -inline % 0B1h - - mov edx, __arg1 - -end - -// ; equalfi -inline % 0B3h - - mov eax, [ebp+__arg1] - xor edx, edx - cmp eax, ebx - setz dl - -end - -// ; pushai -inline % 0B4h - - push [ebx+__arg1] - -end - -// ; loadf -inline % 0B5h - - mov edx, [ebp + __arg1] - -end - -// ; loadfi -inline % 0B7h - - mov edx, [ebp + __arg1] - -end - -// ; dloadsi -inline % 0B8h - - mov edx, [esp + __arg1] - -end - -// ; savef -inline % 0B9h - - mov [ebp + __arg1], edx - -end - -// ; savesi -inline % 0BBh - - mov [esp + __arg1], edx - -end - -// ; savefi -inline % 0BCh - - mov eax, [ebp + __arg1] - mov [eax], edx - -end - -// ; pushf -inline % 0BDh - - lea eax, [ebp + __arg1] - push eax - -end - -// ; reserve -inline % 0BFh - - sub esp, __arg1 - push ebp - push 0 - mov ebp, esp - -end - -// ; pushsip -inline % 0BEh - - lea eax, [esp + __arg1] - push eax - -end - -// ; seti -inline %0C0h - - mov esi, ebx - mov eax, [esp] - // calculate write-barrier address - sub esi, [data : %CORE_GC_TABLE + gc_start] - mov ecx, [data : %CORE_GC_TABLE + gc_header] - shr esi, page_size_order - mov [ebx + __arg1], eax - mov byte ptr [esi + ecx], 1 - -end - -// ; storesi -inline % 0C3h - - mov [esp+__arg1], ebx - -end - -// ; storefi -inline % 0C4h - - mov [ebp+__arg1], ebx - -end - -// ; naddf -inline % 0C5h - - mov ecx, [ebx] - add [ebp+__arg1], ecx - -end - -// ; nmulf -inline % 0C6h - - mov eax, [ebp+__arg1] - imul dword ptr [ebx] - mov [ebp+__arg1], eax - -end - -// ; xsetr -inline % 0C7h - - mov [ebx + edx * 4], __arg1 - -end - -// ; nsubf -inline % 0C8h - - mov ecx, dword ptr [ebx] - sub [ebp+__arg1], ecx - -end - -// ; ndivf -inline % 0C9h - - mov eax, [ebp+__arg1] - cdq - idiv dword ptr [ebx] - mov [ebp+__arg1], eax - -end - -// ; loadi -inline % 0CAh - - mov edx, [ebx + __arg1] - -end - -// ; savei -inline % 0CBh - - mov [ebx + __arg1], edx - -end - -// ; xor -inline % 0CDh - - xor edx, __arg1 - -end - -// ; clonef -inline % 0CEh - - mov ecx, [ebx - elSizeOffset] - and ecx, struct_mask_inv - lea esi, [ebp+__arg1] - shr ecx, 2 - mov edi, ebx - rep movsd - -end - -// ; xload -inline % 0CFh - - mov edx, [ebx + __arg1] - -end - -// ; alloci -inline %0D1h - - // ; generated in jit : sub esp, __arg1*4 - mov ecx, __arg1 - xor eax, eax - mov edi, esp - rep stos - -end - -// ; xcreate -inline % 0D2h - - mov eax, [esp] - mov edx, 0FFFFFh - mov ecx, [eax-elSizeOffset] - and edx, ecx - mov ecx, page_ceil - add ecx, edx - and ecx, page_mask - - call code : %GC_ALLOC - - mov eax, [esp] - mov [ebx-elVMTOffset], __arg1 - mov edx, 0FFFFFh - mov ecx, [eax-elSizeOffset] - and edx, ecx - mov [ebx-elSizeOffset], edx - -end - -// ; inc -inline %0D6h - - add edx, __arg1 - -end - -// ; coalescer -inline % 0D8h - - mov eax, __arg1 - test ebx, ebx - cmovz ebx, eax - -end - -// ; vjumprm -inline % 0DBh - - mov ecx, __arg1 - mov eax, [ebx - elVMTOffset] - jmp [eax + ecx * 8 + 4] - -end - - -// ; xsaveai (__arg1 - index, __arg2 - n) -inline % 0DCh - - mov eax, __arg2 - mov [ebx + __arg1], eax - -end - -// ; copyai (__arg1 - index, __arg2 - n) -inline % 0DDh - - mov ecx, __arg2 - lea esi, [ebx + __arg1] - mov edi, [esp] - rep movsd - -end - -inline % 01DDh - - lea esi, [ebx + __arg1] - mov edi, [esp] - mov eax, [esi] - mov [edi], eax - -end - -inline % 02DDh - - lea esi, [ebx + __arg1] - mov edi, [esp] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - -end - -inline % 03DDh - - lea esi, [ebx + __arg1] - mov edi, [esp] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - mov eax, [esi+8] - mov [edi+8], eax - -end - -inline % 04DDh - - lea esi, [ebx + __arg1] - mov edi, [esp] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - mov eax, [esi+8] - mov [edi+8], eax - mov ecx, [esi+12] - mov [edi+12], ecx - -end - -// ; move -inline % 0DEh - - lea esi, [ebx+__arg1] - mov ecx, __arg2 - mov edi, [esp] - rep movsb - -end - -// ; move -inline % 01DEh - - lea esi, [ebx+__arg1] - mov edi, [esp] - mov eax, [esi] - mov byte ptr [edi], al - -end - -inline % 02DEh - - lea esi, [ebx+__arg1] - mov edi, [esp] - mov eax, [esi] - mov word ptr [edi], ax - -end - -inline % 03DEh - - lea esi, [ebx+__arg1] - mov edi, [esp] - mov eax, [esi] - mov [edi], eax - -end - -inline % 04DEh - - lea esi, [ebx+__arg1] - mov edi, [esp] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - -end - -// ; moveto -inline % 0DFh - - lea edi, [ebx+__arg1] - mov ecx, __arg2 - mov esi, [esp] - rep movsb - -end - -inline % 01DFh - - mov esi, [esp] - lea edi, [ebx+__arg1] - mov eax, [esi] - mov byte ptr [edi], al - -end - -inline % 02DFh - - mov esi, [esp] - lea edi, [ebx+__arg1] - mov eax, [esi] - mov word ptr [edi], ax - -end - -inline % 03DFh - - mov esi, [esp] - lea edi, [ebx+__arg1] - mov eax, [esi] - mov [edi], eax - -end - -inline % 04DFh - - mov esi, [esp] - lea edi, [ebx+__arg1] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - -end - -// ; mtredirect (__arg3 - number of parameters, eax - points to the stack arg list) -inline % 0E8h - - mov esi, __arg1 - push ebx - xor edx, edx - mov ebx, [esi] // ; message from overload list - -labNextOverloadlist: - shr ebx, ACTION_ORDER - mov edi, rdata : % CORE_MESSAGE_TABLE - mov ebx, [edi + ebx * 8 + 4] - mov ecx, __arg3 - lea ebx, [edi + ebx - 4] - -labNextParam: - sub ecx, 1 - jnz short labMatching - - mov esi, __arg1 - pop ebx - mov eax, [esi + edx * 8 + 4] - mov ecx, [ebx - elVMTOffset] - mov edx, [esi + edx * 8] - jmp [ecx + eax * 8 + 4] - -labMatching: - mov edi, [eax + ecx * 4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi - elVMTOffset] - mov esi, [ebx + ecx * 4] - -labNextBaseClass: - cmp esi, edi - jz labNextParam - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov esi, __arg1 - add edx, 1 - mov ebx, [esi + edx * 8] // ; message from overload list - and ebx, ebx - jnz labNextOverloadlist - - pop ebx - -end - -// ; xmtredirect (__arg3 - number of parameters, eax - points to the stack arg list) -inline % 0E9h - - mov esi, __arg1 - push ebx - xor edx, edx - mov ebx, [esi] // ; message from overload list - -labNextOverloadlist: - shr ebx, ACTION_ORDER - mov edi, rdata : % CORE_MESSAGE_TABLE - mov ebx, [edi + ebx * 8 + 4] - mov ecx, __arg3 - lea ebx, [edi + ebx - 4] - -labNextParam: - sub ecx, 1 - jnz short labMatching - - mov esi, __arg1 - mov ecx, edx - pop ebx - mov edx, [esi + ecx * 8] - jmp [esi + ecx * 8 + 4] - -labMatching: - mov edi, [eax + ecx * 4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi - elVMTOffset] - mov esi, [ebx + ecx * 4] - -labNextBaseClass: - cmp esi, edi - jz labNextParam - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov esi, __arg1 - add edx, 1 - mov ebx, [esi + edx * 8] // ; message from overload list - and ebx, ebx - jnz labNextOverloadlist - - pop ebx - -end - -// ; mtredirect<1> -inline % 1E8h - - mov ecx, __arg1 - xor edx, edx - mov eax, [eax + 4] - mov ecx, [ecx] // ; message from overload list - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test eax, eax - cmovz eax, esi - - mov eax, [eax - elVMTOffset] - -labNextOverloadlist: - shr ecx, ACTION_ORDER - mov edi, rdata : % CORE_MESSAGE_TABLE - mov ecx, [edi + ecx * 8 + 4] - lea ecx, [edi + ecx] - -labMatching: - mov edi, eax - mov esi, [ecx] - -labNextBaseClass: - cmp esi, edi - jnz short labContinue - - mov esi, __arg1 - mov eax, [esi + edx * 8 + 4] - mov ecx, [ebx - elVMTOffset] - mov edx, [esi + edx * 8] - jmp [ecx + eax * 8 + 4] - -labContinue: - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov ecx, __arg1 - add edx, 1 - mov ecx, [ecx + edx * 8] // ; message from overload list - and ecx, ecx - jnz labNextOverloadlist - -labEnd: - -end - -// ; xmtredirect<1> -inline % 1E9h - - mov ecx, __arg1 - mov eax, [eax + 4] - xor edx, edx - mov ecx, [ecx] // ; message from overload list - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test eax, eax - cmovz eax, esi - - mov eax, [eax - elVMTOffset] - -labNextOverloadlist: - shr ecx, ACTION_ORDER - mov edi, rdata : % CORE_MESSAGE_TABLE - mov ecx, [edi + ecx * 8 + 4] - lea ecx, [edi + ecx] - -labMatching: - mov edi, eax - mov esi, [ecx] - -labNextBaseClass: - cmp esi, edi - jnz short labContinue - - mov ecx, edx - mov esi, __arg1 - mov edx, [esi + edx * 8] - jmp [esi + ecx * 8 + 4] - -labContinue: - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov ecx, __arg1 - add edx, 1 - mov ecx, [ecx + edx * 8] // ; message from overload list - and ecx, ecx - jnz labNextOverloadlist - -labEnd: - -end - -// ; mtredirect<2> (eax - refer to the stack) -inline % 2E8h - - mov ecx, __arg1 - xor edx, edx - mov ecx, [ecx] // ; message from overload list - -labNextOverloadlist: - mov edi, rdata : % CORE_MESSAGE_TABLE - shr ecx, ACTION_ORDER - mov ecx, [edi + ecx * 8 + 4] - lea ecx, [edi + ecx] - -labMatching: - mov edi, [eax+4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi-elVMTOffset] - mov esi, [ecx] - -labNextBaseClass: - cmp esi, edi - jnz labContinue - - mov edi, [eax+8] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi-elVMTOffset] - mov esi, [ecx + 4] - -labNextBaseClass2: - cmp esi, edi - jnz short labContinue2 - - mov esi, __arg1 - mov eax, [esi + edx * 8 + 4] - mov ecx, [ebx - elVMTOffset] - mov edx, [esi + edx * 8] - jmp [ecx + eax * 8 + 4] - -labContinue2: - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass2 - nop - nop - jmp short labNext - -labContinue: - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - -labNext: - mov ecx, __arg1 - add edx, 1 - mov ecx, [ecx + edx * 8] // ; message from overload list - and ecx, ecx - jnz labNextOverloadlist - -end - -// ; xmtredirect<2> (eax - refer to the stack) -inline % 2E9h - -// ecx -> eax -// ebx -> ecx - - mov ecx, __arg1 - xor edx, edx - mov ecx, [ecx] // ; message from overload list - -labNextOverloadlist: - mov edi, rdata : % CORE_MESSAGE_TABLE - shr ecx, ACTION_ORDER - mov ecx, [edi + ecx * 8 + 4] - lea ecx, [edi + ecx] - -labMatching: - mov edi, [eax+4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi-elVMTOffset] - mov esi, [ecx] - -labNextBaseClass: - cmp esi, edi - jnz labContinue - - mov edi, [eax+8] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi-elVMTOffset] - mov esi, [ecx + 4] - -labNextBaseClass2: - cmp esi, edi - jnz short labContinue2 - - mov esi, __arg1 - mov ecx, edx - mov edx, [esi + ecx * 8] - jmp [esi + ecx * 8 + 4] - -labContinue2: - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass2 - nop - nop - jmp short labNext - -labContinue: - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - -labNext: - mov ecx, __arg1 - add edx, 1 - mov ecx, [ecx + edx * 8] // ; message from overload list - and ecx, ecx - jnz labNextOverloadlist - -end - -// ; mtredirect<12> (__arg3 - number of parameters, eax - points to the stack arg list) - -inline % 0CE8h - - push ebx - xor edx, edx - mov ebx, eax - xor ecx, ecx - -labCountParam: - lea ebx, [ebx+4] - cmp [ebx], -1 - lea ecx, [ecx+1] - jnz short labCountParam - - mov esi, __arg1 - push ecx - mov ebx, [esi] // ; message from overload list - -labNextOverloadlist: - mov edi, rdata : % CORE_MESSAGE_TABLE - shr ebx, ACTION_ORDER - mov ecx, [esp] // ; param count - mov ebx, [edi + ebx * 8 + 4] - lea ebx, [edi + ebx - 4] - -labNextParam: - // ; check if signature contains the next class ptr - lea esi, [ebx + 4] - cmp [esi], 0 - cmovnz ebx, esi - - sub ecx, 1 - jnz short labMatching - - mov esi, __arg1 - lea esp, [esp + 4] - pop ebx - mov eax, [esi + edx * 8 + 4] - mov ecx, [ebx - elVMTOffset] - mov edx, [esi + edx * 8] - jmp [ecx + eax * 8 + 4] - -labMatching: - mov esi, [esp] - sub esi, ecx - mov edi, [eax + esi * 4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi - elVMTOffset] - mov esi, [ebx] - -labNextBaseClass: - cmp esi, edi - jz labNextParam - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov esi, __arg1 - add edx, 1 - mov ebx, [esi + edx * 8] // ; message from overload list - and ebx, ebx - jnz labNextOverloadlist - - lea esp, [esp + 4] - pop eax - -end - -// ; xmtredirect<12> - -inline % 0CE9h - - push ebx - xor edx, edx - mov ebx, eax - xor ecx, ecx - -labCountParam: - lea ebx, [ebx+4] - cmp [ebx], -1 - lea ecx, [ecx+1] - jnz short labCountParam - - mov esi, __arg1 - push ecx - mov ebx, [esi] // ; message from overload list - -labNextOverloadlist: - mov edi, rdata : % CORE_MESSAGE_TABLE - shr ebx, ACTION_ORDER - mov ecx, [esp] // ; param count - mov ebx, [edi + ebx * 8 + 4] - lea ebx, [edi + ebx - 4] - -labNextParam: - // ; check if signature contains the next class ptr - lea esi, [ebx + 4] - cmp [esi], 0 - cmovnz ebx, esi - - sub ecx, 1 - jnz short labMatching - - mov esi, __arg1 - mov ecx, edx - lea esp, [esp + 4] - pop ebx - mov edx, [esi + ecx * 8] - jmp [esi + ecx * 8 + 4] - -labMatching: - mov esi, [esp] - sub esi, ecx - mov edi, [eax + esi * 4] - - //; check nil - mov esi, rdata : %VOIDPTR + elObjectOffset - test edi, edi - cmovz edi, esi - - mov edi, [edi - elVMTOffset] - mov esi, [ebx] - -labNextBaseClass: - cmp esi, edi - jz labNextParam - mov edi, [edi - elPackageOffset] - and edi, edi - jnz short labNextBaseClass - - mov esi, __arg1 - add edx, 1 - mov ebx, [esi + edx * 8] // ; message from overload list - and ebx, ebx - jnz labNextOverloadlist - - lea esp, [esp + 4] - pop eax - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 0E0h - - mov ecx, __arg2 - lea edi, [ebp + __arg1] - lea esi, [ebx+edx] - rep movsd - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 1E0h - - mov ecx, [ebx+edx] - lea edi, [ebp + __arg1] - mov dword ptr [edi], ecx -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 2E0h - - mov ecx, [ebx+edx] - lea edi, [ebp + __arg1] - mov dword ptr [edi], ecx - mov eax, [ebx+edx+4] - mov dword ptr [edi+4], eax - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 3E0h - - mov ecx, [ebx+edx] - lea edi, [ebp + __arg1] - mov dword ptr [edi], ecx - mov eax, [ebx+edx+4] - mov dword ptr [edi+4], eax - mov ecx, [ebx+edx+8] - mov dword ptr [edi+8], ecx - -end - -// ; readtof (__arg1 - index, __arg2 - n) -inline % 4E0h - - mov ecx, [ebx+edx] - lea edi, [ebp + __arg1] - mov dword ptr [edi], ecx - mov eax, [ebx+edx+4] - mov dword ptr [edi+4], eax - mov ecx, [ebx+edx+8] - mov dword ptr [edi+8], ecx - mov eax, [ebx+edx+12] - mov dword ptr [edi+12], eax - -end - -// ; createn (__arg1 - item size) -inline % 0E1h - - mov eax, [esp] - mov ecx, page_ceil - mov eax, [eax] - mov ebx, __arg1 - imul ebx - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov eax, [esp] - mov ecx, struct_mask - mov eax, [eax] - mov esi, __arg1 - imul esi - or ecx, eax - mov [ebx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 1) -inline % 1E1h - - mov eax, [esp] - mov ecx, page_ceil - add ecx, [eax] - and ecx, page_mask - - call code : %GC_ALLOC - - mov eax, [esp] - mov ecx, struct_mask - or ecx, [eax] - mov [ebx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 2) -inline % 2E1h - - mov eax, [esp] - mov ecx, page_ceil - mov eax, [eax] - shl eax, 1 - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov eax, [esp] - mov ecx, struct_mask - mov eax, [eax] - shl eax, 1 - or ecx, eax - mov [ebx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 4) -inline % 3E1h - - mov eax, [esp] - mov ecx, page_ceil - mov eax, [eax] - shl eax, 2 - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov eax, [esp] - mov ecx, struct_mask - mov eax, [eax] - shl eax, 2 - or ecx, eax - mov [ebx-elSizeOffset], ecx - -end - -// ; createn (__arg1 = 8) -inline % 4E1h - - mov eax, [esp] - mov ecx, page_ceil - mov eax, [eax] - shl eax, 3 - add ecx, eax - and ecx, page_mask - - call code : %GC_ALLOC - - mov eax, [esp] - mov ecx, struct_mask - mov eax, [eax] - shl eax, 3 - or ecx, eax - mov [ebx-elSizeOffset], ecx - -end - -// ; xsetfi (__arg1 - index, __arg2 - index) -inline % 0E2h - - mov eax, [ebp + __arg1] - mov [ebx + __arg2], eax - -end - -// ; copytoai (__arg1 - index, __arg2 - n) -inline % 0E3h - - mov ecx, __arg2 - lea edi, [ebx + __arg1] - mov esi, [esp] - rep movsd - -end - -inline % 01E3h - - mov esi, [esp] - lea edi, [ebx + __arg1] - mov eax, [esi] - mov [edi], eax - -end - -inline % 02E3h - - mov esi, [esp] - lea edi, [ebx + __arg1] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - -end - -inline % 03E3h - - mov esi, [esp] - lea edi, [ebx + __arg1] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - mov eax, [esi+8] - mov [edi+8], eax - -end - -inline % 04E3h - - mov esi, [esp] - lea edi, [ebx + __arg1] - mov eax, [esi] - mov [edi], eax - mov ecx, [esi+4] - mov [edi+4], ecx - mov eax, [esi+8] - mov [edi+8], eax - mov ecx, [esi+12] - mov [edi+12], ecx - -end - -// ; copytofi (__arg1 - index, __arg2 - n) -inline % 0E4h - - mov ecx, __arg2 - mov edi, [ebp + __arg1] - mov esi, ebx - rep movsd - -end - -inline % 1E4h - - mov edi, [ebp + __arg1] - mov eax, [ebx] - mov [edi], eax - -end - -inline % 2E4h - - mov edi, [ebp + __arg1] - mov eax, [ebx] - mov ecx, [ebx+4] - mov [edi], eax - mov [edi+4], ecx - -end - -inline % 3E4h - - mov edi, [ebp + __arg1] - mov eax, [ebx] - mov ecx, [ebx+4] - mov [edi], eax - mov esi, [ebx+8] - mov [edi+4], ecx - mov [edi+8], esi - -end - -inline % 4E4h - - mov edi, [ebp + __arg1] - mov eax, [ebx] - mov ecx, [ebx+4] - mov [edi], eax - mov esi, [ebx+8] - mov [edi+4], ecx - mov eax, [ebx+12] - mov [edi+8], esi - mov [edi+12], eax - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 0E5h - - mov ecx, __arg2 - lea edi, [ebp + __arg1] - mov esi, ebx - rep movsd - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 1E5h - - lea edi, [ebp + __arg1] - mov eax, [ebx] - mov [edi], eax - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 2E5h - - lea edi, [ebp + __arg1] - mov eax, [ebx] - mov [edi], eax - mov ecx, [ebx+4] - mov [edi+4], ecx - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 3E5h - - lea edi, [ebp + __arg1] - mov eax, [ebx] - mov [edi], eax - mov ecx, [ebx+4] - mov [edi+4], ecx - mov eax, [ebx+8] - mov [edi+8], eax - -end - -// ; copytof (__arg1 - index, __arg2 - n) -inline % 4E5h - - lea edi, [ebp + __arg1] - mov eax, [ebx] - mov [edi], eax - mov ecx, [ebx+4] - mov [edi+4], ecx - mov eax, [ebx+8] - mov [edi+8], eax - mov ecx, [ebx+12] - mov [edi+12], ecx - -end - -// ; copyfi (__arg1 - index, __arg2 - n) -inline % 0E6h - - mov ecx, __arg2 - mov esi, [ebp + __arg1] - mov edi, ebx - rep movsd - -end - -inline % 01E6h - - mov esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - -end - -inline % 02E6h - - mov esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - mov ecx, [esi+4] - mov [ebx+4], ecx - -end - -inline % 03E6h - - mov esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - mov ecx, [esi+4] - mov [ebx+4], ecx - mov eax, [esi+8] - mov [ebx+8], eax - -end - -inline % 04E6h - - mov esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - mov ecx, [esi+4] - mov [ebx+4], ecx - mov eax, [esi+8] - mov [ebx+8], eax - mov ecx, [esi+12] - mov [ebx+8], ecx - -end - -// ; copyf (__arg1 - index, __arg2 - n) -inline % 0E7h - - mov ecx, __arg2 - lea esi, [ebp + __arg1] - mov edi, ebx - rep movsd - -end - -inline % 01E7h - - lea esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - -end - -inline % 02E7h - - lea esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - mov ecx, [esi+4] - mov [ebx+4], ecx - -end - -inline % 03E7h - - lea esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - mov ecx, [esi+4] - mov [ebx+4], ecx - mov eax, [esi+8] - mov [ebx+8], eax - -end - -inline % 04E7h - - lea esi, [ebp + __arg1] - mov eax, [esi] - mov [ebx], eax - mov ecx, [esi+4] - mov [ebx+4], ecx - mov eax, [esi+8] - mov [ebx+8], eax - mov ecx, [esi+12] - mov [ebx+12], ecx - -end - -// ; xrsavef (__arg1 - index, __arg2 - n) -inline % 0EDh - - push __arg2 - fild dword ptr [esp] - lea edi, [ebp+__arg1] - fstp qword ptr [edi] - lea esp, [esp+4] - -end - -// ; xaddf (__arg1 - index, __arg2 - n) -inline % 0EEh - - add dword ptr [ebp + __arg1], __arg2 - -end - -// ; xsavef (__arg1 - index, __arg2 - n) -inline % 0EFh - - mov dword ptr [ebp + __arg1], __arg2 - -end - -// ; new (__arg1 - size) -inline % 0F0h - - mov ecx, __arg1 - call code : %GC_ALLOC - -end - -// ; fillri (__arg1 - count) -inline % 0F2h - - mov edi, ebx - mov ecx, __arg1 - rep stosd - -end - -// ; xselectr (eax - r1, __arg1 - r2) -inline % 0F3h - - test ebx, ebx - mov ebx, __arg1 - cmovnz ebx, eax - -end - -// ; vcallrm -inline % 0F4h - - mov ecx, __arg1 - mov eax, [ebx - elVMTOffset] - call [eax + ecx * 8 + 4] - -end - -// ; jumprm -inline % 0F5h - - cmp [ebx], ebx - jmp __arg1 - -end - -// ; selectr (ebx - r1, __arg1 - r2) -inline % 0F6h - - mov ecx, __arg1 - test edx, edx - cmovnz ebx, ecx - -end - -// ; allocn (__arg1 - size) -inline % 0F8h - - mov ecx, __arg1 - call code : %GC_ALLOCPERM - -end - -// ; xsavesi (__arg1 - index, __arg2 - n) -inline % 0F9h - - mov eax, __arg2 - mov [esp + __arg1], eax - -end - -// callrm (edx contains message, __arg1 contains vmtentry) -inline % 0FEh - - call code : __arg1 - -end - -// ; callextr -inline % 0FFh - - call extern __arg1 - mov edx, eax - -end - -// ; lcallextr -inline % 1FFh - - call extern __arg1 - mov edi, edx - mov edx, eax - -end diff --git a/asm/x32/core60.asm b/asm/x32/core60.asm index 1553fae111..6ce0f210f7 100644 --- a/asm/x32/core60.asm +++ b/asm/x32/core60.asm @@ -754,6 +754,13 @@ inline %02Ch end +// ; parent +inline %02Dh + + mov ebx, [ebx - elPackageOffset] + +end + // ; xget inline %02Eh @@ -1278,10 +1285,8 @@ end // ; copy 8 inline %790h - mov eax, [esi] - mov edi, [esi+4] - mov dword ptr [ebx], eax - mov dword ptr [ebx+4], edi + movq xmm0, qword ptr [esi] + movq qword ptr [ebx] , xmm0 end @@ -1798,7 +1803,7 @@ inline % 0ADh end -// ; xfillr i,0 +// ; xfillr 0 inline % 1ADh xor eax, eax mov edi, ebx @@ -2606,11 +2611,8 @@ end // ; copydpn dpn, 8 inline %4E0h - mov eax, [esi] - lea edi, [ebp + __arg32_1] - mov ecx, [esi+4] - mov [edi], eax - mov [edi + 4], ecx + movq xmm0, qword ptr [esi] + movq qword ptr [ebp + __arg32_1] , xmm0 end @@ -3098,39 +3100,57 @@ inline %0F0h end -// ; openin 0, 0 +// ; openin 0, n inline %1F0h push ebp mov ebp, esp + xor ecx, ecx + sub esp, __n_2 + push ebp + push ecx + mov ebp, esp end -// ; openin 1, 0 +// ; openin 1, n inline %2F0h push ebp mov ebp, esp - push 0 + xor ecx, ecx + sub esp, __n_2 + push ebp + push ecx + mov ebp, esp + push ecx end -// ; openin 2, 0 +// ; openin 2, n inline %3F0h push ebp mov ebp, esp xor ecx, ecx + sub esp, __n_2 + push ebp + push ecx + mov ebp, esp push ecx push ecx end -// ; openin 3, 0 +// ; openin 3, n inline %4F0h push ebp + mov ebp, esp xor ecx, ecx + sub esp, __n_2 + push ebp + push ecx mov ebp, esp push ecx push ecx @@ -3138,16 +3158,21 @@ inline %4F0h end -// ; openin 0, n +// ; openin 4, n inline %5F0h - push ebp - mov ebp, esp - xor ecx, ecx - sub esp, __n_2 - push ebp - push ecx - mov ebp, esp + push ebp + mov ebp, esp + xor ecx, ecx + sub esp, __n_2 + xorps xmm0, xmm0 + push ebp + push ecx + mov ebp, esp + + sub esp, 16 + movq qword ptr [esp], xmm0 + movq qword ptr [esp+8], xmm0 end @@ -3164,51 +3189,56 @@ inline %6F0h end -// ; openin 2, n +// ; openin 0, 0 inline %7F0h push ebp mov ebp, esp - xor eax, eax - sub esp, __n_2 - push ebp - push eax - mov ebp, esp - push eax - push eax end -// ; openin 3, n +// ; openin 1, 0 inline %8F0h push ebp mov ebp, esp - xor eax, eax - sub esp, __n_2 + push 0 + +end + +// ; openin 2, 0 +inline %9F0h + push ebp - push eax mov ebp, esp - push eax - push eax - push eax + xor ecx, ecx + push ecx + push ecx end -// ; openin 4, n -inline %9F0h +// ; openin 3, 0 +inline %0AF0h push ebp + xor ecx, ecx mov ebp, esp - xor eax, eax - sub esp, __n_2 + push ecx + push ecx + push ecx + +end + +// ; openin 4, 0 +inline %0BF0h + push ebp - push eax + xorps xmm0, xmm0 mov ebp, esp - push eax - push eax - push eax - push eax + + sub esp, 16 + movq qword ptr [esp], xmm0 + movq qword ptr [esp+8], xmm0 end @@ -3268,7 +3298,7 @@ inline %0F2h end -// ; extopenin 0, 0 +// ; extopenin 0, n inline %1F2h push ebp @@ -3282,11 +3312,16 @@ inline %1F2h mov ebp, esp push ebp + xor eax, eax + mov ebp, esp + sub esp, __n_2 + push ebp + push eax mov ebp, esp end -// ; extopenin 1, 0 +// ; extopenin 1, n inline %2F2h push ebp @@ -3300,12 +3335,17 @@ inline %2F2h mov ebp, esp push ebp + xor eax, eax mov ebp, esp - push 0 + sub esp, __n_2 + push ebp + push eax + mov ebp, esp + push eax end -// ; extopenin 2, 0 +// ; extopenin 2, n inline %3F2h push ebp @@ -3321,12 +3361,16 @@ inline %3F2h push ebp xor eax, eax mov ebp, esp + sub esp, __n_2 + push ebp + push eax + mov ebp, esp push eax push eax end -// ; extopenin 3, 0 +// ; extopenin 3, n inline %4F2h push ebp @@ -3342,13 +3386,17 @@ inline %4F2h push ebp xor eax, eax mov ebp, esp + sub esp, __n_2 + push ebp + push eax + mov ebp, esp push eax push eax push eax end -// ; extopenin 0, n +// ; extopenin 4, n inline %5F2h push ebp @@ -3368,6 +3416,10 @@ inline %5F2h push ebp push eax mov ebp, esp + push eax + push eax + push eax + push eax end @@ -3394,6 +3446,109 @@ inline %6F2h end +// ; extopenin 0, 0 +inline %7F2h + + push ebp + mov eax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push eax + + mov ebp, eax + xor eax, eax + push ebp + push eax + mov ebp, esp + + push ebp + mov ebp, esp + +end + +// ; extopenin 1, 0 +inline %8F2h + + push ebp + mov eax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push eax + + mov ebp, eax + xor eax, eax + push ebp + push eax + mov ebp, esp + + push ebp + mov ebp, esp + push 0 + +end + +// ; extopenin 2, 0 +inline %9F2h + + push ebp + mov eax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push eax + + mov ebp, eax + xor eax, eax + push ebp + push eax + mov ebp, esp + + push ebp + xor eax, eax + mov ebp, esp + push eax + push eax + +end + +// ; extopenin 3, 0 +inline %0AF2h + + push ebp + mov eax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push eax + + mov ebp, eax + xor eax, eax + push ebp + push eax + mov ebp, esp + + push ebp + xor eax, eax + mov ebp, esp + push eax + push eax + push eax + +end + +// ; extopenin 4, 0 +inline %0BF2h + + push ebp + mov eax, [data : %CORE_SINGLE_CONTENT + tt_stack_frame] + push eax + + mov ebp, eax + xor eax, eax + push ebp + push eax + mov ebp, esp + + push ebp + xor eax, eax + mov ebp, esp + push eax + push eax + push eax + push eax + +end + // ; movsifi inline %0F3h @@ -3511,6 +3666,83 @@ inline % 1F8h end +// ; fill 1, r +inline % 2F8h + + mov eax, __ptr32_2 + mov [ebx], eax + +end + +// ; fill 1, 0 +inline % 3F8h + + xor eax, eax + mov [ebx], eax + +end + +// ; fill 2, r +inline % 4F8h + + mov eax, __ptr32_2 + mov [ebx], eax + mov [ebx+4], eax + +end + +// ; fill 2, 0 +inline % 5F8h + + xorps xmm0, xmm0 + movq qword ptr [ebx], xmm0 + +//; xor eax, eax +//; mov [ebx], eax +//; mov [ebx+4], eax + +end + +// ; fill 3, r +inline % 6F8h + + mov eax, __ptr32_2 + mov [ebx], eax + mov [ebx+4], eax + mov [ebx+8], eax + +end + +// ; fill 3, 0 +inline % 7F8h + + xor eax, eax + mov [ebx], eax + mov [ebx+4], eax + mov [ebx+8], eax + +end + +// ; fill 4, r +inline % 8F8h + + mov eax, __ptr32_2 + mov [ebx], eax + mov [ebx+4], eax + mov [ebx+8], eax + mov [ebx+0Ch], eax + +end + +// ; fill 4, 0 +inline % 9F8h + + xorps xmm0, xmm0 + movq qword ptr [ebx], xmm0 + movq qword ptr [ebx+8], xmm0 + +end + // ; xstorefir inline %0F9h @@ -3662,11 +3894,11 @@ labNextBaseClass: end // ; xdispatchmr -// ; NOTE : __arg32_1 - variadic message; __n_1 - arg count; __ptr32_2 - list, __n_2 - argument list offset +// ; NOTE : __arg32_1 - message; __n_1 - list index, __n_2 - argument list offset inline % 9FAh mov [esp+4], esi // ; saving arg0 - lea eax, [esp + __n_2] + lea eax, [esp] mov ecx, __n_1 push ecx @@ -3688,6 +3920,7 @@ labNextOverloadlist: mov ebx, [edi + ebx * 8 + 4] and ecx, ARG_MASK lea ebx, [ebx - 4] + add ecx, 1 labNextParam: sub ecx, 1 @@ -3711,7 +3944,7 @@ labMatching: cmovz edi, esi mov edi, [edi - elVMTOffset] - mov esi, [ebx + ecx * 4 + 4] + mov esi, [ebx + ecx * 4] labNextBaseClass: cmp esi, edi @@ -3724,7 +3957,6 @@ labNextBaseClass: mov ebx, [esp] mov esi, [ebx + ecx * 4] // ; get next overload list add edx, 1 - mov esi, [esi] mov ebx, [esi + edx * 8] // ; message from overload list and ebx, ebx jnz labNextOverloadlist diff --git a/asm/x32/core_lnx.asm b/asm/x32/core_lnx.asm deleted file mode 100644 index 54cc92ce0a..0000000000 --- a/asm/x32/core_lnx.asm +++ /dev/null @@ -1,66 +0,0 @@ -// --- Predefined References -- -define GC_ALLOC 10001h -define HOOK 10010h -define INVOKER 10011h -define INIT_RND 10012h -define LOCK 10021h -define UNLOCK 10022h -define LOAD_CALLSTACK 10024h -define NEW_EVENT 10101h - -define PROT_READ_WRITE 03h -define MAP_ANONYMOUS 22h -define SIGABRT 06h - -procedure % INIT_RND - -/* - sub esp, 8h - mov eax, esp - sub esp, 10h - lea ebx, [esp] - push eax - push ebx - push ebx - call extern 'dlls'KERNEL32.GetSystemTime - call extern 'dlls'KERNEL32.SystemTimeToFileTime - add esp, 10h - pop eax - pop edx -*/ - // ; ! temporally - xor eax, eax - xor edx, edx - - ret - -end - -// INVOKER(prevFrame, function) -procedure % INVOKER - - // ; save registers - mov eax, [esp+8] // ; function - push esi - mov esi, [esp+8] // ; prevFrame - push edi - push ecx - push ebx - push ebp - - // declare new frame - push esi // ; FrameHeader.previousFrame - push 0 // ; FrameHeader.reserved - mov ebp, esp // ; FrameHeader - call eax - add esp, 8 // ; clear FrameHeader - - // ; restore registers - pop ebp - pop ebx - pop ecx - pop edi - pop esi - ret - -end diff --git a/asm/x32/core_win.asm b/asm/x32/core_win.asm deleted file mode 100644 index 3ce3a56077..0000000000 --- a/asm/x32/core_win.asm +++ /dev/null @@ -1,62 +0,0 @@ -// --- Predefined References -- -define GC_ALLOC 10001h -define HOOK 10010h -define INVOKER 10011h -define INIT_RND 10012h -define INIT_ET 10015h -define LOCK 10021h -define UNLOCK 10022h -define LOAD_CALLSTACK 10024h - -define GC_HEAP_ATTRIBUTE 00Dh - -procedure % INIT_RND - - sub esp, 8h - mov eax, esp - sub esp, 10h - lea ebx, [esp] - push eax - push ebx - push ebx - call extern 'dlls'KERNEL32.GetSystemTime - call extern 'dlls'KERNEL32.SystemTimeToFileTime - add esp, 10h - pop eax - pop edx - ret - -end - -// INVOKER(prevFrame, function, arg) -procedure % INVOKER - - // ; save registers - mov eax, [esp+8] // ; function - push esi - mov esi, [esp+8] // ; prevFrame - push edi - mov edi, [esp+20] // ; arg - push ecx - push ebx - push ebp - - // declare new frame - push esi // ; FrameHeader.previousFrame - push 0 // ; FrameHeader.reserved - mov ebp, esp // ; FrameHeader - push edi // ; arg - - call eax - add esp, 12 // ; clear FrameHeader+arg - xor eax, eax - - // ; restore registers - pop ebp - pop ebx - pop ecx - pop edi - pop esi - ret - -end diff --git a/asm/x32/coreapi.asm b/asm/x32/coreapi.asm deleted file mode 100644 index eca5465599..0000000000 --- a/asm/x32/coreapi.asm +++ /dev/null @@ -1,4908 +0,0 @@ -// --- System Core API -- -define GC_ALLOC 10001h -define INIT_RND 10012h -define CALC_SIZE 1001Fh -define GET_COUNT 10020h - -define CORE_ET_TABLE 2000Bh - -define elVMTSizeOffset 0004h - -define elSizeOffset 0004h -define elVMTOffset 0008h -define elObjectOffset 0008h - -// ; --- API --- - -procedure coreapi'core_callstack_load - - mov eax, [esp+4] - mov ecx, [esp+8] - - mov edx, [esp] - xor ebx, ebx - mov esi, ebp - -labNext: - mov edx, [esi + 4] - cmp [esi], 0 - jnz short labSave - test edx, edx - jz short labEnd - mov esi, edx - jmp short labNext - -labSave: - mov [eax + ebx * 4], edx - add ebx, 1 - cmp ebx, ecx - jge short labEnd - mov esi, [esi] - jmp short labNext - -labEnd: - mov edx, ebx - ret - -end - -// core_subcopyz(target,index,size,arr) -procedure coreapi'core_subcopyz - - mov eax, [esp+16] - mov ecx, [esp+12] - mov esi, [esp+4] - mov ebx, [esp+8] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [eax + ebx] - mov byte ptr [esi], dl - add ebx, 1 - add esi, 1 - sub ecx, 1 - jnz short labNext - mov byte ptr [esi], cl - -labEnd: - ret - -end - -// core_wsubcopyz(target,index,size,arr) -procedure coreapi'core_wsubcopyz - - mov eax, [esp+16] - mov ecx, [esp+12] - mov esi, [esp+4] - mov ebx, [esp+8] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [eax + ebx*2] - mov word ptr [esi], dx - add ebx, 1 - lea esi, [esi + 2] - sub ecx, 1 - jnz short labNext - mov word ptr [esi], cx - -labEnd: - ret - -end - -// ; insert(dest,sour,index,size) -procedure coreapi'core_insert - - mov ecx, [esp+16] - mov edi, [esp+4] - mov ebx, [esp+12] - mov esi, [esp+8] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [esi] - mov byte ptr [edi + ebx], dl - add ebx, 1 - lea esi, [esi + 1] - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -// winsert(target,source,index,len) -procedure coreapi'core_winsert - - mov ebx, [esp+12] - mov ecx, [esp+16] - mov edi, [esp+4] - mov esi, [esp+8] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [esi] - mov word ptr [edi + ebx*2], dx - add ebx, 1 - lea esi, [esi + 2] - sub ecx, 1 - jnz short labNext - -labEnd: - mov edx, ecx - mov ebx, edi - ret - -end - -// ; sadd(dest,sour,sindex,dindex) -procedure coreapi'core_sadd - - mov ecx, [esp+12] - mov eax, [esp+8] - mov edx, [esp+16] - mov edi, [esp+4] - - mov esi, ecx // ; src index - - mov ebx, [eax-elSizeOffset] - and ebx, 0FFFFFh - add edx, edi - sub ecx, ebx - add esi, eax - -labNext2: - mov ebx, [esi] - mov byte ptr [edx], bl - lea esi, [esi+1] - lea edx, [edx+1] - add ecx, 1 - jnz short labNext2 - - ret - -end - -// ; wadd(dest,sour,sindex,dindex) -procedure coreapi'core_wadd - - mov ecx, [esp+12] - mov eax, [esp+8] - mov ebx, [esp+16] - mov edi, [esp+4] - - shl ebx, 1 - shl ecx, 1 - - mov edx, ebx // ; dst index - mov esi, ecx // ; src index - - mov ebx, [eax-elSizeOffset] - and ebx, 0FFFFFh - - add edx, edi - sub ecx, ebx - add esi, eax - -labNext2: - mov ebx, [esi] - mov word ptr [edx], ebx - lea esi, [esi+2] - lea edx, [edx+2] - add ecx, 2 - jnz short labNext2 - - ret - -end - -// sseek(s,subs,index,subslen) -procedure coreapi'core_sseek - - mov edi, [esp+4] // s - mov edx, [esp+12] - mov esi, [esp+8] // subs - - mov ebx, [edi-elSizeOffset] // get total length - and ebx, 0FFFFFh - - sub ebx, edx - jbe short labEnd - - add ebx, 1 - sub edx, 1 - -labNext: - add edx, 1 - mov ecx, [esp+16] - sub ebx, 1 - jz short labEnd - cmp ebx, ecx - jb short labEnd - mov edi, [esp+4] - add edi, edx - -labCheck: - mov eax, [edi] - cmp al, byte ptr [esi] - jnz short labNext - lea edi, [edi+1] - lea esi, [esi+1] - sub ecx, 1 - jnz short labCheck - nop - nop - jmp short labEnd2 - -labEnd: - mov edx, -1 -labEnd2: - ret - -end - -// wseek(s,subs,index,len) -procedure coreapi'core_wseek - - mov edi, [esp+4] // s - mov edx, [esp+12] - mov esi, [esp+8] // subs - - mov ebx, [edi-elSizeOffset] // get total length - and ebx, 0FFFFFh - - shl edx, 1 - sub ebx, edx - jbe short labEnd - - add ebx, 2 - sub edx, 2 - -labNext: - add edx, 2 - mov ecx, [esp+16] - sub ebx, 2 - jz short labEnd - shl ecx, 1 - cmp ebx, ecx - jb short labEnd - mov edi, [esp+4] - add edi, edx - -labCheck: - mov eax, [edi] - cmp ax, word ptr [esi] - jnz short labNext - lea edi, [edi+2] - lea esi, [esi+2] - sub ecx, 2 - jnz short labCheck - shr edx, 1 - jmp short labEnd2 - -labEnd: - mov edx, -1 -labEnd2: - ret - -end - -// ; strtochar(index,str; ebx = 0 if err ; edx - out) -procedure coreapi'core_strtochar - - mov ebx, [esp+4] - mov eax, [esp+8] - - xor edx, edx - mov dl, byte ptr [eax + ebx] - cmp edx, 00000080h - jl short lab1 - cmp edx, 000000C0h - jl short err - cmp edx, 000000E0h - jl short lab2 - cmp edx, 000000F0h - jl short lab3 - cmp edx, 000000F8h - jl lab4 - -err: - xor ebx, ebx - ret - -lab1: - mov ebx, eax - ret - -lab2: - mov ecx, edx - mov dl, byte ptr [eax + ebx + 1] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - shl ecx, 6 - add edx, ecx - sub edx, 3080h - mov ebx, eax - ret - -lab3: - mov ecx, edx - mov dl, byte ptr [eax + ebx + 1] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - cmp ecx, 000000E0h - jnz short lab3_1 - cmp ebx, 000000A0h - jl short err - -lab3_1: - shl ecx, 12 - shl edx, 6 - add ecx, edx - xor edx, edx - mov dl, byte ptr [eax + ebx + 2] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - add edx, ecx - sub edx, 0E2080h - mov ebx, eax - ret - -lab4: - mov ecx, edx - mov dl, byte ptr [eax + ebx + 1] - mov esi, edx - and esi, 0C0h - cmp esi, 00000080h - jnz err - cmp ecx, 000000F0h - jnz short lab4_1 - cmp edx, 00000090h - jl short err - -lab4_1: - cmp ecx, 000000F4h - jnz short lab4_2 - cmp edx, 00000090h - jae short err - -lab4_2: - shl ecx, 18 - shl edx, 12 - add ecx, edx - - xor edx, edx - mov dl, byte ptr [eax + ebx + 2] - mov esi, edx - and esi, 000000C0h - cmp esi, 00000080h - jnz err - - shl edx, 6 - add ecx, edx - - xor edx, edx - mov dl, byte ptr [eax + ebx + 3] - mov esi, edx - and esi, 000000C0h - cmp esi, 00000080h - jnz err - - add edx, ecx - sub edx, 3C82080h - mov ebx, eax - ret - -end - -// ; wstrtochar(index,str; ebx = 0 if err ; edx - out) -procedure coreapi'core_wstrtochar - - mov ebx, [esp+4] - mov eax, [esp+8] - - mov esi, dword ptr [eax + ebx * 2] - and esi, 0FFFFh - cmp esi, 0D800h - jl short lab1 - cmp esi, 0DBFFh - jg short err - - mov ecx, esi - shl ecx, 10 - mov esi, dword ptr [eax + ebx * 2 + 2] - and esi, 0FFFFh - cmp esi, 0DC00h - jl short lab2 - cmp esi, 0DFFFh - jg short err - -lab2: - mov edx, ecx - mov ebx, [esp+4] - add edx, ebx - sub edx, 35FDC00h - ret - -lab1: - mov ebx, [esp+8] - mov edx, esi - ret - -err: - xor ebx, ebx - ret - -end - -procedure coreapi'core_wstrtochararray - - mov ecx, [esp+16] - mov edi, [esp+12] - mov ebx, [esp+8] - mov eax, [esp+4] - - lea edi, [edi + ebx * 4] - -labStart: - mov ebx, dword ptr [eax] - add eax, 2 - - and ebx, 0FFFFh - cmp ebx, 0D800h - jl short lab1 - - shl ebx, 10 - mov edx, dword ptr [eax] - add eax, 2 - and edx, 0FFFFh - add ebx, edx - sub ebx, 35FDC00h - -lab1: - mov edx, ebx - -labSave: - mov [edi], edx - add edi, 4 - sub ecx, 1 - jnz labStart - - mov ecx, edi - mov edi, [esp+12] - sub ecx, edi - mov esi, [esp+8] - shr ecx, 2 - sub ecx, [esi] - mov eax, [esp+16] - mov [eax], ecx - - ret - -end - -// ; slen_ch - ecx - len, eax - charr, esi - result -procedure coreapi'core_slen_ch - - mov eax, [esp+12] - mov ecx, [esp+8] - mov edx, [esp+4] - mov edi, [esp+16] - lea eax, [eax+edx*4] - - xor ebx, ebx - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [eax] - cmp edx, 00000080h - jl short lab1 - cmp edx, 0800h - jl short lab2 - cmp edx, 10000h - jl short lab3 - - add ebx, 4 - lea eax, [eax + 4] - sub ecx, 1 - jnz short labNext -labEnd: - mov [edi], ebx - ret - -lab1: - add ebx, 1 - lea eax, [eax + 4] - sub ecx, 1 - jnz short labNext - mov [edi], ebx - ret - -lab2: - add ebx, 2 - lea eax, [eax + 4] - sub ecx, 1 - jnz short labNext - mov [edi], ebx - ret - -lab3: - add ebx, 3 - lea eax, [eax + 4] - sub ecx, 1 - jnz short labNext - mov [edi], ebx - ret - -end - -// ; wslen_ch - ecx - len, eax - charr, esi - result -procedure coreapi'core_wslen_ch - - mov eax, [esp+12] - mov ecx, [esp+8] - mov edx, [esp+4] - mov edi, [esp+16] - lea eax, [eax+edx*4] - - xor ebx, ebx - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [eax] - cmp edx, 010000h - jl short lab1 - - add ebx, 2 - lea eax, [eax + 4] - sub ecx, 1 - jnz short labNext -labEnd: - mov [edi], ebx - ret - -lab1: - add ebx, 1 - lea eax, [eax + 4] - sub ecx, 1 - jnz short labNext - mov [edi], ebx - ret - -end - -procedure coreapi'core_scopychars - - mov eax, [esp+16] - mov ecx, [esp+12] - mov ebx, [esp+8] - mov edi, [esp+4] - - test ecx, ecx - jz labEnd - - lea esi, [eax + ebx * 4] - -labNext: - mov ebx, [esi] - - cmp ebx, 00000080h - jl short labs1 - cmp ebx, 0800h - jl short labs2 - cmp ebx, 10000h - jl short labs3 - - mov edx, ebx - shr edx, 18 - add edx, 000000F0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - shr edx, 12 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - shr edx, 6 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - jmp labSave - -labs2: - mov edx, ebx - shr edx, 6 - add edx, 000000C0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - jmp short labSave - -labs3: - mov edx, ebx - shr edx, 12 - add edx, 000000E0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - jmp short labSave - -labs1: - mov byte ptr [edi], bl - add edi, 1 - -labSave: - lea esi, [esi + 4] - sub ecx, 1 - jnz labNext - -labEnd: - mov edx, edi - mov edi, [esp+8] - sub edx, edi - - ret - -end - -procedure coreapi'core_wscopychars - - mov eax, [esp+16] - mov ecx, [esp+12] - mov ebx, [esp+8] - mov edi, [esp+4] - - test ecx, ecx - jz labEnd - - lea esi, [eax + ebx * 4] - -labNext: - mov ebx, [esi] - cmp ebx, 010000h - jl short lab1 - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [edi], dx - add edi, 2 - - and ebx, 03FFh - add ebx, 0DC00h - -lab1: - mov word ptr [edi], bx - add edi, 2 - lea esi, [esi + 4] - sub ecx, 1 - jnz short labNext - -labEnd: - mov ebx, edi - pop edi - sub ebx, edi - shr ebx, 1 - - ret - -end - -// ; inttostr(s,b,t,out) -procedure coreapi'core_inttostr - - mov esi, [esp+8] - mov eax, [esp+4] - mov edi, [esp+12] - - push ebp - mov ebp, esp - xor ecx, ecx - push eax - // ; take sign into account only for the decimal representation - cmp esi, 10 - jnz short Lab6 - cmp eax, 0 - jns short Lab6 - neg eax -Lab6: - cmp eax, esi - jb short Lab5 -Lab1: - xor edx, edx - idiv esi - push edx - add ecx, 1 - cmp eax, esi - jae short Lab1 -Lab5: - add ecx, 2 - push eax - cmp esi, 10 - jnz short Lab7 - mov eax, [ebp-4] - cmp eax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 1 -Lab7: - sub ecx, 1 - mov esi, edi - mov edx, 0FFh -Lab2: - pop eax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov byte ptr [esi], al - add esi, 1 - sub ecx, 1 - jnz short Lab2 - mov edx, esi - sub edx, edi - lea esp, [esp+4] - pop ebp - mov edi, [esp+16] - mov dword ptr[edi], edx - - ret - -end - -procedure coreapi'core_inttowstr - - mov esi, [esp+8] - mov eax, [esp+4] - mov edi, [esp+12] - - push ebp - mov ebp, esp - xor ecx, ecx - push eax - cmp eax, 0 - jns short Lab6 - neg eax -Lab6: - cmp eax, ebx - jb short Lab5 -Lab1: - xor edx, edx - idiv ebx - push edx - add ecx, 2 - cmp eax, ebx - jae short Lab1 -Lab5: - add ecx, 4 - push eax - mov eax, [ebp-4] - cmp eax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 2 -Lab7: - mov esi, edi - mov edx, 0FFh - sub ecx, 2 // to skip zero -Lab2: - pop eax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov word ptr [esi], ax - add esi, 2 - sub ecx, 2 - jnz short Lab2 - mov ecx, esi - sub ecx, edi - shr ecx, 1 - lea esp, [esp+4] - pop ebp - - ret - -end - -// ; uinttostr(s,b,t) -procedure coreapi'core_uinttostr - - mov esi, [esp+8] - mov eax, [esp+4] - mov edi, [esp+12] - - push ebp - mov ebp, esp - xor ecx, ecx - - cmp eax, esi - jb short Lab5 -Lab1: - xor edx, edx - idiv esi - push edx - add ecx, 1 - cmp eax, esi - jae short Lab1 -Lab5: - add ecx, 2 - push eax - sub ecx, 1 - mov esi, edi - mov edx, 0FFh -Lab2: - pop eax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov byte ptr [esi], al - add esi, 1 - sub ecx, 1 - jnz short Lab2 - mov edx, esi - sub edx, edi - pop ebp - - ret - -end - -procedure coreapi'core_uinttowstr - - mov esi, [esp+8] - mov eax, [esp+4] - mov edi, [esp+12] - - push ebp - mov ebp, esp - xor ecx, ecx - cmp eax, ebx - jb short Lab5 -Lab1: - xor edx, edx - idiv ebx - push edx - add ecx, 2 - cmp eax, ebx - jae short Lab1 -Lab5: - add ecx, 4 - push eax - mov esi, edi - mov edx, 0FFh - sub ecx, 2 // to skip zero -Lab2: - pop eax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, edx - mov word ptr [esi], ax - add esi, 2 - sub ecx, 2 - jnz short Lab2 - mov ecx, esi - sub ecx, edi - shr ecx, 1 - pop ebp - - ret - -end - -// ; === internal === - -// strtowstr(target,source) -procedure coreapi'strtowstr - - mov eax, [esp+8] - mov edi, [esp+4] - mov esi, [eax - elSizeOffset] - and esi, 0FFFFFh - sub esi, 1 - jz labEnd - -labNext: - - xor ebx, ebx - mov bl, byte ptr [eax] - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 000000E0h - jl short lab2 - cmp ebx, 000000F0h - jl short lab3 - - mov ecx, ebx - shl ecx, 18 - - lea eax, [eax + 1] - sub esi, 1 - mov bl, byte ptr [eax] - shl ebx, 12 - add ecx, ebx - - xor ebx, ebx - lea eax, [eax + 1] - sub esi, 1 - mov bl, byte ptr [eax] - shl ebx, 6 - add ecx, ebx - - xor ebx, ebx - lea eax, [eax + 1] - sub esi, 1 - mov bl, byte ptr [eax] - add ecx, ebx - sub ecx, 3C82080h - jmp short labCont - -lab2: - mov ecx, ebx - shl ecx, 6 - - lea eax, [eax + 1] - sub esi, 1 - mov bl, byte ptr [eax] - add ecx, ebx - sub ecx, 3080h - jmp short labCont - -lab3: - mov ecx, ebx - shl ecx, 12 - - lea eax, [eax + 1] - sub esi, 1 - mov bl, byte ptr [eax] - shl ebx, 6 - add ecx, ebx - - xor ebx, ebx - lea eax, [eax + 1] - sub esi, 1 - mov bl, byte ptr [eax] - add ecx, ebx - sub ecx, 0E2080h - jmp short labCont - -lab1: - mov ecx, ebx - -labCont: - cmp ecx, 010000h - jl short labw1 - - mov edx, ecx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [edi], dx - add edi, 2 - - and ecx, 03FFh - add ecx, 0DC00h - -labw1: - mov word ptr [edi], ecx - add edi, 2 - - lea eax, [eax + 1] - sub esi, 1 - jnz labNext -labEnd: - mov ebx, [esp+4] - mov edx, edi - sub edx, ebx - shr edx, 1 - ret - -end - -// strtochararray(src,index,dst,len) -procedure coreapi'strtochararray - - mov edx, [esp+16] - mov edi, [esp+12] - mov ecx, [edx] - mov esi, [esp+8] - mov eax, [esp+4] - mov ebx, [esi] - - lea edi, [edi + ebx * 4] - -labStart: - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 000000E0h - jl short lab2 - cmp ebx, 000000F0h - jl short lab3 - -lab4: - mov edx, ebx - mov bl, byte ptr [eax] - add eax, 1 - shl edx, 18 - shl ebx, 12 - add edx, ebx - - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - shl ebx, 6 - add edx, ebx - - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - - add edx, ebx - sub edx, 3C82080h - sub ecx, 3 - jmp labSave - -lab2: - mov edx, ebx - mov bl, byte ptr [eax] - add eax, 1 - - shl edx, 6 - add edx, ebx - sub edx, 3080h - sub ecx, 1 - jmp short labSave - -lab3: - mov edx, ebx - mov bl, byte ptr [eax] - add eax, 1 - shl edx, 12 - shl ebx, 6 - add edx, ebx - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - add edx, ebx - sub edx, 0E2080h - sub ecx, 2 - jmp short labSave - -lab1: - mov edx, ebx - -labSave: - mov [edi], edx - add edi, 4 - sub ecx, 1 - jnz labStart - - mov ecx, edi - mov edi, [esp+12] - sub ecx, edi - mov esi, [esp+8] - shr ecx, 2 - sub ecx, [esi] - mov eax, [esp+16] - mov [eax], ecx - - ret - -end - -procedure coreapi'wstrtochararray - - mov edx, [esp+16] - mov edi, [esp+12] - mov ecx, [edx] - mov esi, [esp+8] - mov eax, [esp+4] - mov ebx, [esi] - - lea edi, [edi + ebx * 4] - -labStart: - mov ebx, dword ptr [eax] - add eax, 2 - - and ebx, 0FFFFh - cmp ebx, 0D800h - jl short lab1 - - shl ebx, 10 - mov edx, dword ptr [eax] - add eax, 2 - and edx, 0FFFFh - add ebx, edx - sub ebx, 35FDC00h - -lab1: - mov edx, ebx - -labSave: - mov [edi], edx - add edi, 4 - sub ecx, 1 - jnz labStart - - mov ecx, edi - mov edi, [esp+12] - sub ecx, edi - mov esi, [esp+8] - shr ecx, 2 - sub ecx, [esi] - mov eax, [esp+16] - mov [eax], ecx - - ret - -end - -// strtowstr(target,source) -procedure coreapi'wstrtostr - - mov eax, [esp+8] - mov edi, [esp+4] - mov esi, [eax - elSizeOffset] - and esi, 0FFFFFh - sub esi, 2 - jz labEnd - -labNext: - mov ebx, [eax] - and ebx, 0FFFFh - cmp ebx, 0D800h - jb short lab1 - - mov ecx, ebx - shl ecx, 10 - lea eax, [eax + 2] - sub esi, 2 - mov ebx, dword ptr [eax] - and ebx, 0FFFFh - add ebx, ecx - sub ebx, 35FDC00h - -lab1: - mov ecx, ebx - - cmp ebx, 00000080h - jl short labs1 - cmp ebx, 0800h - jl short labs2 - cmp ebx, 10000h - jl short labs3 - - mov edx, ebx - shr edx, 18 - add edx, 0F0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ecx - shr edx, 12 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ecx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - jmp short labSave - -labs2: - mov edx, ecx - shr edx, 6 - add edx, 0C0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - jmp short labSave - -labs3: - mov edx, ecx - shr edx, 12 - add edx, 0E0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ecx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - jmp short labSave - -labs1: - mov byte ptr [edi], bl - add edi, 1 - -labSave: - lea eax, [eax + 2] - sub esi, 2 - jnz labNext - -labEnd: - mov ebx, [esp+4] - mov edx, edi - sub edx, ebx - ret - -end - -// subcopyz(target,index,size,arr) -procedure coreapi'subcopyto - - mov eax, [esp+16] - mov edx, [esp+12] - mov esi, [esp+4] - mov ecx, [edx] - mov edi, [esp+8] - test ecx, ecx - mov ebx, [edi] - jz short labEnd - -labNext: - mov edx, [eax] - mov byte ptr [esi + ebx], dl - add ebx, 1 - add eax, 1 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -// subcopyz(target,index,size,arr) -procedure coreapi'subcopy - - mov eax, [esp+16] - mov edx, [esp+12] - mov esi, [esp+4] - mov ecx, [edx] - mov edi, [esp+8] - test ecx, ecx - mov ebx, [edi] - jz short labEnd - -labNext: - mov edx, [eax + ebx] - mov byte ptr [esi], dl - add ebx, 1 - add esi, 1 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -// wsubcopy(target,index,size,arr) -procedure coreapi'wsubcopyto - - mov eax, [esp+16] - mov edx, [esp+12] - mov esi, [esp+4] - mov ecx, [edx] - mov edi, [esp+8] - test ecx, ecx - mov ebx, [edi] - jz short labEnd - -labNext: - mov edx, [eax] - mov word ptr [esi + ebx*2], dx - add ebx, 1 - add eax, 2 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -// ninsert(target,index,len,source) -procedure coreapi'ninsert - - mov edx, [esp+8] - mov eax, [esp+12] - mov edi, [esp+4] - mov ecx, [eax] - mov esi, [esp+16] - mov ebx, [edx] - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [esi] - mov [edi + ebx*4], edx - add ebx, 1 - lea esi, [esi + 4] - sub ecx, 1 - jnz short labNext - -labEnd: - mov edx, ebx - mov ebx, edi - ret - -end - -// ; move(target,index,len,offs) -procedure coreapi'move - - mov edx, [esp+8] - mov eax, [esp+12] - mov edi, [esp+4] // ; target - mov ecx, [eax] - mov esi, [esp+16] - mov ebx, [edx] // ; index - - test ecx, ecx // ; len - jz short labEnd - - mov edx, [esi] // ; offs - cmp edx, 0 - jl short labDelete - - add ebx, ecx - sub ebx, 1 - - add edx, ebx - - add edx, edi - add ebx, edi - -labNext: - mov esi, dword ptr [esi] - mov dword ptr [edx], esi - sub ebx, 1 - sub edx, 1 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -labDelete: - add edx, ebx - - add edx, edi - add ebx, edi - -labNext2: - mov esi, dword ptr [ebx] - mov dword ptr [edx], esi - add ebx, 1 - add edx, 1 - sub ecx, 1 - jnz short labNext2 - ret - -end - -// ; nmove(target,index,len,offs) -procedure coreapi'nmove - - mov edi, [esp+4] - mov eax, [esp+12] - mov ebx, [esp+8] - mov ecx, [eax] - mov ebx, [ebx] - mov edx, [esp+16] - - test ecx, ecx - jz short labEnd - - mov esi, [edx] - cmp esi, 0 - jl short labDelete - - add ebx, ecx - sub ebx, 1 - - add esi, ebx - shl esi, 2 - - add esi, edi - shl ebx, 2 - add ebx, edi - -labNext: - mov edx, dword ptr [ebx] - mov dword ptr [esi], edx - sub ebx, 4 - sub esi, 4 - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -labDelete: - add esi, ebx - shl esi, 2 - - add esi, edi - shl ebx, 2 - add ebx, edi - -labNext2: - mov edx, dword ptr [ebx] - mov dword ptr [esi], edx - add ebx, 4 - add esi, 4 - sub ecx, 1 - jnz short labNext2 - ret - -end - -procedure coreapi'strtoint - - mov eax, [esp+8] // ; radix - mov esi, [esp+4] // ; get str - mov ebx, [eax] - mov ecx, [esi-elSizeOffset] - xor edx, edx // ; clear flag - and ecx, 0FFFFFh - cmp byte ptr [esi], 2Dh - lea ecx, [ecx-1] // ; to skip zero - jnz short Lab4 - lodsb - mov edx, 1 // ; set flag - lea ecx, [ecx-1] // ; to skip minus -Lab4: - push edx - xor eax, eax -Lab1: - mov edx, ebx - mul edx - mov edx, eax - xor eax, eax - lodsb - cmp eax, 3Ah - jl short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short Lab2 - cmp eax, ebx - ja short Lab2 - add eax, edx - sub ecx, 1 - jnz short Lab1 - nop - pop ebx - test ebx, ebx - jz short Lab5 - neg eax -Lab5: - mov edx, eax - mov ebx, [esp+4] - jmp short Lab3 -Lab2: - add esp, 4 - xor ebx, ebx -Lab3: - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'strtolong - - mov eax, [esp+8] // ; radix - mov esi, [esp+4] // ; get str - mov ecx, [eax] - - push ecx - mov ecx, [esi-elSizeOffset] - xor edx, edx - and ecx, 0FFFFFh - - cmp byte ptr [esi], 2Dh - lea ecx, [ecx-1] - jnz short labStart - - lea esi, [esi+1] - lea ecx, [ecx-1] - mov edx, 1 // set flag in ebx - -labStart: - push edx // save sign flag - xor edi, edi // edi - DHI - xor ebx, ebx // ebx - DLO - -labConvert: - mov edx, [esp+4] - mov eax, edi - mul edx // DHI * 10 - mov edi, eax - - mov eax, ebx - mov edx, [esp+4] - mul edx // DLO * 10 - add edi, edx - mov ebx, eax - - xor eax, eax - lodsb - cmp eax, 3Ah - jl short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short labErr - mov edx, [esp+4] - cmp dl, al - ja short labErr - - add ebx, eax // DLO + EAX - adc edi, 0 // DHI + CF - - sub ecx, 1 - jnz short labConvert - - pop eax // restore flag - test eax, eax - jz short labSave - - not edi // invert number - neg ebx - -labSave: - - mov edx, edi - pop esi - - mov eax, [esp+12] - mov [eax], ebx - mov [eax+4], edx - mov ebx, [esp+4] - - jmp short labEnd - -labErr: - xor ebx, ebx - pop edx - -labEnd: - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'wstrtolong - - mov eax, [esp+8] // ; radix - mov esi, [esp+4] // ; get str - mov ecx, [eax] - - push ecx - mov esi, eax - mov ecx, [esi-elSizeOffset] - xor edx, edx - and ecx, 0FFFFFh - - cmp byte ptr [esi], 2Dh - lea ecx, [ecx-2] - jnz short labStart - - lea esi, [esi+2] - lea ecx, [ecx-2] - mov edx, 1 // set flag in ebx - -labStart: - push edx // save sign flag - xor edi, edi // edi - DHI - xor ebx, ebx // ebx - DLO - -labConvert: - mov edx, [esp+4] - mov eax, edi - mul edx // DHI * 10 - mov edi, eax - - mov eax, ebx - mov edx, [esp+4] - mul edx // DLO * 10 - add edi, edx - mov ebx, eax - - xor eax, eax - lodsw - sub al, 30h - jb short labErr - cmp al, 9 - ja short labErr - - add ebx, eax // DLO + EAX - adc edi, 0 // DHI + CF - - sub ecx, 2 - jnz short labConvert - - pop eax // restore flag - test eax, eax - jz short labSave - - not edi // invert number - neg ebx - -labSave: - - mov edx, edi - pop esi - - mov eax, [esp+12] - mov [eax], ebx - mov [eax+4], edx - mov ebx, [esp+4] - - jmp short labEnd - -labErr: - xor ebx, ebx - pop ebx - -labEnd: - ret - -end - -procedure coreapi'strtouint - - mov eax, [esp+8] // ; radix - mov esi, [esp+4] // ; get str - - mov ebx, [eax] // ; radix - mov ecx, [esi-elSizeOffset] - and ecx, 0FFFFFh - xor eax, eax - lea ecx, [ecx-1] // ; to skip zero -Lab1: - mov edx, ebx - mul edx - mov edx, eax - xor eax, eax - lodsb - cmp eax, 3Ah - jl short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short Lab2 - cmp eax, ebx - ja short Lab2 - add eax, edx - sub ecx, 1 - jnz short Lab1 - mov edx, eax - mov ebx, [esp+4] - jmp short Lab3 -Lab2: - add esp, 4 - xor ebx, ebx -Lab3: - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'wstrtoint - - mov eax, [esp+8] // ; radix - mov esi, [esp+4] // ; get str - - mov ebx, [eax] // ; radix - mov ecx, [esi-elSizeOffset] - xor edx, edx // ; clear flag - and ecx, 0FFFFFh - cmp byte ptr [esi], 2Dh - lea ecx, [ecx-2] // ; to skip zero - jnz short Lab4 - lodsw - mov edx, 1 // ; set flag - lea ecx, [ecx-2] // ; to skip minus -Lab4: - push edx - xor eax, eax -Lab1: - mov edx, ebx - mul edx - mov edx, eax - xor eax, eax - lodsw - cmp eax, 3Ah - jb short lab11 - sub al, 7 -lab11: - sub al, 30h - jb short Lab2 - cmp ax, bx - ja short Lab2 - add eax, edx - sub ecx, 2 - jnz short Lab1 - nop - pop ebx - test ebx, ebx - jz short Lab5 - neg eax -Lab5: - mov edx, eax - mov ebx, [esp+4] - jmp short Lab3 -Lab2: - xor ebx, ebx -Lab3: - ret - -end - -procedure coreapi'longtostr - - mov ebx, [esp+8] - mov eax, [esp+4] - mov ecx, [ebx] - mov edi, [esp+12] - - push ebp - push [eax+4] - mov ebp, esp - mov edx, [eax] // NLO - mov eax, [eax+4] // NHI - push 0 - or eax, eax - jge short Lab6 - - neg eax - neg edx - sbb eax, 0 - -Lab6: // convert - mov esi, edx // NLO - mov edi, eax // NHI - -Lab1: - test edi, edi - jnz short labConvert - cmp esi, ecx - jb short Lab5 - -labConvert: - mov eax, edi // NHI - xor edx, edx - div ecx - mov ebx, eax - mov eax, esi // NLO - div ecx - mov edi,ebx - mov esi,eax - - push edx - add [ebp-4], 1 - jmp short Lab1 - -Lab5: - push esi - - mov ecx, [ebp-4] - add ecx, 1 - - mov eax, [ebp] - cmp eax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 1 -Lab7: - mov esi, [ebp+20] - mov ebx, 0FFh -Lab2: - pop eax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, ebx - mov byte ptr [esi], al - add esi, 1 - sub ecx, 1 - jnz short Lab2 - mov edx, esi - lea esp, [esp+8] - pop ebp - sub edx, [esp+12] - ret - -end - -procedure coreapi'longtowstr - - mov ebx, [esp+8] - mov eax, [esp+4] - mov ecx, [ebx] - mov edi, [esp+12] - - push edi - push ebp - push [eax+4] - mov ebp, esp - mov edx, [eax] // NLO - mov eax, [eax+4] // NHI - push 0 - or eax, eax - jge short Lab6 - - neg eax - neg edx - sbb eax, 0 - -Lab6: // convert - mov esi, edx // NLO - mov edi, eax // NHI - -Lab1: - test edi, edi - jnz short labConvert - cmp esi, ecx - jb short Lab5 - -labConvert: - mov eax, edi // NHI - xor edx, edx - div ecx - mov ebx, eax - mov eax, esi // NLO - div ecx - mov edi,ebx - mov esi,eax - - push edx - add [ebp-4], 1 - jmp short Lab1 - -Lab5: - push esi - - mov ecx, [ebp-4] - add ecx, 1 - - mov eax, [ebp] - cmp eax, 0 - jns short Lab7 - push 0F6h // to get "-" after adding 0x30 - add ecx, 1 -Lab7: - mov esi, [ebp+20] - mov ebx, 0FFh -Lab2: - pop eax - cmp eax, 0Ah - jb short Lab8 - add eax, 7 -Lab8: - add eax, 30h - and eax, ebx - mov word ptr [esi], ax - add esi, 2 - sub ecx, 1 - jnz short Lab2 - mov edx, esi - lea esp, [esp+8] - pop ebp - sub edx, [esp+12] - ret - -end - -// ; rcopyl (src,tgt) -procedure coreapi'longtoreal - - mov eax, [esp+4] - mov edi, [esp+8] - fild qword ptr [eax] - fstp qword ptr [edi] - ret - -end - -// ; chartostr (char,target, out edx - length) -procedure coreapi'chartostr - - mov eax, [esp+4] - mov edi, [esp+8] - - xor ecx, ecx - mov [edi], ecx - mov [edi+4], ecx - - mov ebx, [eax] - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 0800h - jl short lab2 - cmp ebx, 10000h - jl short lab3 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - shl edx, 24 - mov ecx, edx - - mov edx, ebx - and edx, 0FC0h - shl edx, 10 - add edx, 800000h - or ecx, edx - - mov edx, ebx - and edx, 03F000h - shr edx, 4 - add edx, 08000h - or ecx, edx - - mov edx, ebx - shr edx, 18 - and edx, 03Fh - add edx, 0F0h - or ecx, edx - - mov [edi], ecx - mov edx, 4 - ret - -lab1: - mov [edi], ebx - mov edx, 1 - ret - -lab2: - mov edx, ebx - shr edx, 6 - add edx, 0C0h - mov byte ptr [edi], dl - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [edi+1], bl - - mov edx, 2 - ret - -lab3: - mov edx, ebx - shr edx, 12 - add edx, 0E0h - mov byte ptr [edi], dl - - mov edx, ebx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi+1], dl - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [edi+2], bl - - mov edx, 3 - ret - -end - -// ; chartowstr (char, target, out edx - length) -procedure coreapi'chartowstr - - mov eax, [esp+4] - mov edi, [esp+8] - xor ecx, ecx - mov [edi], ecx - mov [edi+4], ecx - - mov ebx, [eax] - cmp ebx, 010000h - jl short lab1 - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [edi], dx - - mov edx, ebx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [edi+2], dx - mov edx, 2 - ret - -lab1: - mov [edi], ebx - mov edx, 1 - ret - -end - -// ; rcopyl (eax:src, ecx : base, ebx - result) -procedure coreapi'strtoreal - - mov eax, [esp+8] // ; radix - mov esi, [esp+4] // ; get str - mov ecx, [eax] - - sub esp, 12 - xor edx, edx - xor eax, eax - xor ebx, ebx - mov edi, esp - stosd - stosd - mov [edi], eax - -atof1: - lodsb - cmp eax, 32 // " " - jz short atof1 - or eax, eax - jnz short atof2 - -atoflerr: - add esp, 12 - xor ebx, ebx - jmp atoflend - - //---------------------- - // check for leading sign - //---------------------- - -atof2: - - cmp eax, 43 // + - jz short atof3 - cmp eax,45 // - - jnz short integer - mov dh,80h -atof3: - mov byte ptr [edi+1], dh // put sign byte in bcd string - xor edx,edx - lodsb - - //------------------------------------ - // convert the digits to packed decimal - //------------------------------------ -integer: - - cmp eax, 46 // . - jnz short atof4 - test bh, 1 - jnz short atoflerr // only one decimal point allowed - or bh, 1 - lodsb -atof4: - cmp eax, 101 // "e" - jnz short atof5 - cmp cl, 19 - jnz short atof41 - test bh, 4 - jz short atoflerr -atof41: - jmp scient -atof5: - cmp eax,69 // "E" - jnz short atof6 - cmp cl, 19 - jnz short atof51 - test bh, 4 - jz short atoflerr -atof51: - jmp scient -atof6: - or eax,eax - jnz short atof7 - cmp cl, 19 - jnz atof61 - test bh, 4 - jz short atoflerr -atof61: - jmp laststep1 -atof7: - sub eax,48 // "0" - jc short atoflerr // unacceptable character - cmp eax,9 - ja short atoflerr // unacceptable character - or bh,4 // at least 1 numerical character - test bh,1 - jz short atof8 - add bl,1 // bl holds number of decimal digits - jc atoflerr // more than 255 decimal digits -atof8: - test eax, eax - jnz short atof9 - test bh,2 - jnz short atof9 - lodsb - jmp short integer -atof9: - or bh,2 // at least 1 non-zero numerical character - sub ecx, 1 - jnz short atof10 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof91 // if trailing decimal 0 - add ecx, 1 - sub bl, 1 - lodsb - jmp integer -atof91: - jmp atoflerr -atof10: - mov dh,al - -integer1: - lodsb - cmp eax, 46 // "." - jnz short atof20 - test bh,1 - jnz atoflerr // only one decimal point allowed - or bh, 1 // use bh bit0 as the decimal point flag - lodsb -atof20: - cmp eax, 101 // "e" - jnz short atof30 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - jmp scient -atof30: - cmp eax, 69 // "E" - jnz short atof40 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - jmp scient -atof40: - or eax,eax - jnz short atof50 - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - jmp short laststep1 -atof50: - sub eax, 48 // "0" - jc atoflerr // unacceptable character - cmp eax,9 - ja atoflerr // unacceptable character - test bh,1 - jz short atof60 - add bl, 1 // processing decimal digits -atof60: - sub ecx, 1 - jnz short atof70 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof602 - add ecx, 1 - sub bl, 1 - jmp integer1 -atof602: - jmp atoflerr -atof70: - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - sub edi, 1 - lodsb - jmp integer - -laststep1: - cmp cl,19 - jnz short laststep - fldz - jmp short laststep2 - -laststep: - - mov ah, dh -/* - push eax //;reserve space on stack - fstcw word ptr [esp] // ;get current control word - pop eax - or eax,0300h // ;code it for truncating - push eax - fldcw word ptr [esp] // ;change rounding code of FPU to truncate - pop eax -*/ - xor edx, edx - fbld [esp] - sub cl, 1 - add bl,cl - movzx eax,bl - sub edx,eax - - push edx - fild dword ptr [esp] // load the exponent - fldl2t // load log2(10) - fmulp // ->log2(10)*exponent - pop edx - - // at this point, only the log base 2 of the 10^exponent is on the FPU - // the FPU can compute the antilog only with the mantissa - // the characteristic of the logarithm must thus be removed - - fld st(0) // copy the logarithm - frndint // keep only the characteristic - fsub st(1),st(0) // keeps only the mantissa - fxch st(1) // get the mantissa on top - - f2xm1 // ->2^(mantissa)-1 - fld1 - faddp // add 1 back - - // the number must now be readjusted for the characteristic of the logarithm - - fscale // scale it with the characteristic - - // the characteristic is still on the FPU and must be removed - - fstp st(1) // clean-up the register - - fmulp - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc atoflerr // clean-up and return error - -laststep2: - - add esp, 12 - mov edi, [esp+12] - fstp qword ptr[edi] // store result at specified address - jmp short atoflend - -scient: - cmp cl,19 - jnz short atof80 - fldz - jmp short laststep2 - xor edx, edx - -atof80: - xor eax,eax - lodsb - cmp ax, 43 // "+" - jz atof90 - cmp ax, 45 // "-" - jnz short scient1 - stc - rcr eax,1 // keep sign of exponent in most significant bit of EAX - -atof90: - - lodsb // get next digit after sign - -scient1: - push eax - and eax,0ffh - jnz short atof100 // continue if 1st byte of exponent is not terminating 0 - -scienterr: - xor ebx, ebx - jmp atoflerr // no exponent - -atof100: - sub eax,30h - jc short scienterr // unacceptable character - cmp eax,9 - ja short scienterr // unacceptable character - imul edx,10 - add edx,eax - cmp edx,4931h - ja short scienterr // exponent too large - lodsb - or eax,eax - jnz short atof100 - pop eax // retrieve exponent sign flag - rcl eax,1 // is most significant bit set? - jnc short atof200 - neg edx - -atof200: - jmp laststep - -atoflend: - ret - -end - -// ; rcopyl (eax:src, ecx : base, esi - result) -procedure coreapi'wstrtoreal - - mov edi, [esp+12] - mov eax, [esp+8] // ; radix - mov esi, [esp+4] // ; get str - mov ecx, [eax] - - push edi - sub esp, 12 - xor edx, edx - xor eax, eax - xor ebx, ebx - mov edi, esp - stosd - stosd - mov word ptr [edi], ax - mov ecx, 19 - -atof1: - lodsw - cmp eax, 32 // " " - jz short atof1 - or eax, eax - jnz short atof2 - -atoflerr: - add esp, 12 - pop edi - xor esi, esi - jmp atoflend - - //---------------------- - // check for leading sign - //---------------------- - -atof2: - - cmp eax, 43 // + - jz short atof3 - cmp eax,45 // - - jnz short integer - mov dh,80h -atof3: - mov byte ptr [edi+1], dh // put sign byte in bcd string - xor edx,edx - lodsw - - //------------------------------------ - // convert the digits to packed decimal - //------------------------------------ -integer: - - cmp eax, 46 // . - jnz short atof4 - test bh, 1 - jnz short atoflerr // only one decimal point allowed - or bh, 1 - lodsw -atof4: - cmp eax, 101 // "e" - jnz short atof5 - cmp cl, 19 - jnz short atof41 - test bh, 4 - jz short atoflerr -atof41: - jmp scient -atof5: - cmp eax,69 // "E" - jnz short atof6 - cmp cl, 19 - jnz short atof51 - test bh, 4 - jz short atoflerr -atof51: - jmp scient -atof6: - or eax,eax - jnz short atof7 - cmp cl, 19 - jnz atof61 - test bh, 4 - jz short atoflerr -atof61: - jmp laststep1 -atof7: - sub eax,48 // "0" - jc short atoflerr // unacceptable character - cmp eax,9 - ja short atoflerr // unacceptable character - or bh,4 // at least 1 numerical character - test bh,1 - jz short atof8 - add bl,1 // bl holds number of decimal digits - jc atoflerr // more than 255 decimal digits -atof8: - test eax, eax - jnz short atof9 - test bh,2 - jnz short atof9 - lodsw - jmp short integer -atof9: - or bh,2 // at least 1 non-zero numerical character - sub ecx, 1 - jnz short atof10 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof91 // if trailing decimal 0 - add ecx, 1 - sub bl, 1 - lodsw - jmp integer -atof91: - jmp atoflerr -atof10: - mov dh,al - -integer1: - lodsw - cmp eax, 46 // "." - jnz short atof20 - test bh,1 - jnz atoflerr // only one decimal point allowed - or bh, 1 // use bh bit0 as the decimal point flag - lodsw -atof20: - cmp eax, 101 // "e" - jnz short atof30 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - jmp scient -atof30: - cmp eax, 69 // "E" - jnz short atof40 - mov ah, dh - mov al,0 - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - jmp scient -atof40: - or eax,eax - jnz short atof50 - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - jmp short laststep1 -atof50: - sub eax, 48 // "0" - jc atoflerr // unacceptable character - cmp eax,9 - ja atoflerr // unacceptable character - test bh,1 - jz short atof60 - add bl, 1 // processing decimal digits -atof60: - sub ecx, 1 - jnz short atof70 - test bh,1 // check if decimal point - jz atoflerr // error if more than 18 integer digits in number - test eax, eax - jnz short atof602 - add ecx, 1 - sub bl, 1 - jmp integer1 -atof602: - jmp atoflerr -atof70: - mov ah, dh - rol al,4 - ror ax,4 - mov byte ptr [edi],al - mov dh, ah - sub edi, 1 - lodsw - jmp integer - -laststep1: - cmp cl,19 - jnz short laststep - fldz - jmp short laststep2 - -laststep: - mov ah, dh - xor edx, edx - fbld [esp] - sub cl, 1 - add bl,cl - movzx eax,bl - sub edx,eax - - push edx - fild dword ptr [esp] // load the exponent - fldl2t // load log2(10) - fmulp // ->log2(10)*exponent - pop edx - - // at this point, only the log base 2 of the 10^exponent is on the FPU - // the FPU can compute the antilog only with the mantissa - // the characteristic of the logarithm must thus be removed - - fld st(0) // copy the logarithm - frndint // keep only the characteristic - fsub st(1),st(0) // keeps only the mantissa - fxch st(1) // get the mantissa on top - - f2xm1 // ->2^(mantissa)-1 - fld1 - faddp // add 1 back - - // the number must now be readjusted for the characteristic of the logarithm - - fscale // scale it with the characteristic - - // the characteristic is still on the FPU and must be removed - - fstp st(1) // clean-up the register - - fmulp - fstsw ax // retrieve exception flags from FPU - shr al,1 // test for invalid operation - jc atoflerr // clean-up and return error - -laststep2: - - add esp, 12 - pop edi - fstp qword ptr[edi] // store result at specified address - jmp short atoflend - -scient: - cmp cl,19 - jnz short atof80 - fldz - jmp short laststep2 - xor edx, edx - -atof80: - xor eax,eax - lodsw - cmp ax, 43 // "+" - jz atof90 - cmp ax, 45 // "-" - jnz short scient1 - stc - rcr eax,1 // keep sign of exponent in most significant bit of EAX - -atof90: - - lodsw // get next digit after sign - -scient1: - push eax - and eax,0ffh - jnz short atof100 // continue if 1st byte of exponent is not terminating 0 - -scienterr: - pop edi - xor esi, esi - jmp atoflerr // no exponent - -atof100: - sub eax,30h - jc short scienterr // unacceptable character - cmp eax,9 - ja short scienterr // unacceptable character - imul edx,10 - add edx,eax - cmp edx,4931h - ja short scienterr // exponent too large - lodsw - or eax,eax - jnz short atof100 - pop eax // retrieve exponent sign flag - rcl eax,1 // is most significant bit set? - jnc short atof200 - neg edx - -atof200: - jmp laststep - -atoflend: - mov eax, esi - ret - -end - -// ; rcopyl (eax:src, ecx : base, ebx - result) -procedure coreapi'realtostr - - mov edi, [esp+12] - mov esi, [esp+8] // ; radix - mov eax, [esp+4] // ; get str - mov ebx, [esi] - - mov ecx, eax - push ebp - mov ebp, esp - - sub esp, 52 - - push edi - - lea ebx, [ebx-3] // get the number of decimal digits (minus 2 for sign and dot) - cmp ebx, 13 - jbe short ftoa1 - mov ebx, 13 -ftoa1: - xor edx, edx - - //------------------------------------------- - //first examine the value on FPU for validity - //------------------------------------------- - - fld qword ptr [ecx] - fxam // examine value on FPU - fstsw ax // get result - - sahf // transfer to CPU flags - jz short maybezero - jpo srcerr // C3=0 and C2=0 would be NAN or unsupported - jnc short getnumsize // continue if normal finite number - - //-------------------------------- - //value to be converted = INFINITY - //-------------------------------- - - mov al,43 // "+" - test ah,2 // C1 field = sign - jz short ftoa2 - mov al, 45 // "-" -ftoa2: - and eax, 0FFh - stosw - mov eax,4E49h // "NI" - stosw - mov eax,4946h // "IF" - stosw - mov eax,494Eh // "IN" - stosw - mov eax,5954h // "YT" - stosw - jmp finish - - //------------------------- - //value to be converted = 0 - //------------------------- - -maybezero: - jpe short getnumsize // would be denormalized number - fstp st(0) // flush that 0 value off the FPU - mov eax,2E30h // ".0" szstring - stosw // write it - mov eax,30h // "0" szstring - stosb // write it - jmp finish - - //--------------------------- - // get the size of the number - //--------------------------- - -getnumsize: - fldlg2 // log10(2) - fld st(1) // copy Src - fabs // insures a positive value - fyl2x // ->[log2(Src)]*[log10(2)] = log10(Src) - - fstcw word ptr [ebp-4] // get current control word - mov ax, word ptr [ebp-4] - or ax,0C00h // code it for truncating - mov word ptr [ebp-8],ax - fldcw word ptr [ebp-8] // insure rounding code of FPU to truncating - - fist [ebp-12] // store characteristic of logarithm - fldcw word ptr [ebp-4] // load back the former control word - - ftst // test logarithm for its sign - fstsw ax // get result - sahf // transfer to CPU flags - sbb [ebp-12],0 // decrement esize if log is negative - fstp st(0) // get rid of the logarithm - - //----------------------------------------------------------------------- - // get the power of 10 required to generate an integer with the specified - // number of significant digits - //----------------------------------------------------------------------- - - mov eax, [ebp-12] - lea eax, [eax+1] // one digit is required - or eax, eax - js short ftoa21 - cmp eax, 13 - jbe short ftoa20 - mov edx, -1 - mov ebx, 13 - mov ecx, ebx - sub ecx, eax - mov [ebp-16], ecx - jmp short ftoa22 - -ftoa20: - add eax, ebx - cmp eax, 13 - jbe short ftoa21 - sub eax, 13 - sub ebx, eax - -ftoa21: - mov [ebp-16], ebx - -ftoa22: - - //---------------------------------------------------------------------------------------- - // multiply the number by the power of 10 to generate required integer and store it as BCD - //---------------------------------------------------------------------------------------- - - fild dword ptr [ebp-16] - fldl2t - fmulp // ->log2(10)*exponent - fld st(0) - frndint // get the characteristic of the log - fxch st(1) - fsub st(0),st(1) // get only the fractional part but keep the characteristic - f2xm1 // ->2^(fractional part)-1 - fld1 - faddp // add 1 back - fscale // re-adjust the exponent part of the REAL number - fstp st(1) // get rid of the characteristic of the log - fmulp // ->16-digit integer - - fbstp tbyte ptr[ebp-28] // ->TBYTE containing the packed digits - fstsw ax // retrieve exception flags from FPU - shr eax,1 // test for invalid operation - jc srcerr // clean-up and return error - - //------------------------------------------------------------------------------ - // unpack BCD, the 10 bytes returned by the FPU being in the little-endian style - //------------------------------------------------------------------------------ - - lea esi, [ebp-19] // go to the most significant byte (sign byte) - push edi - lea edi,[ebp-52] - mov eax,3020h - movzx ecx,byte ptr[esi] // sign byte - cmp ecx, 00000080h - jnz short ftoa5 - mov al, 45 // insert sign if negative number -ftoa5: - - stosw - mov ecx,9 -ftoa6: - sub esi, 1 - movzx eax,byte ptr[esi] - ror ax,4 - ror ah,4 - add eax,3030h - stosw - sub ecx, 1 - jnz short ftoa6 - - pop edi - lea esi,[ebp-52] - - cmp edx, 0 - jnz short scientific - - //************************ - // REGULAR STRING NOTATION - //************************ - - movsb // insert sign - - cmp byte ptr[esi-1], 20h // test if we insert space - jnz short ftoa60 - lea edi, [edi-1] // erase it - -ftoa60: - mov ecx,1 // at least 1 integer digit - mov eax, [ebp-12] - or eax, eax // is size negative (i.e. number smaller than 1) - js short ftoa61 - add ecx, eax - -ftoa61: - mov eax, ebx - add eax, ecx // ->total number of digits to be displayed - sub eax, 19 - sub esi, eax // address of 1st digit to be displayed - cmp byte ptr[esi-1], 49 // "1" - jnz ftoa8 - sub esi, 1 - add ecx, 1 -ftoa8: - test ecx, ecx - jz short ftoa8End -ftoa8Next: // copy required integer digits - movzx eax, byte ptr [esi] - mov byte ptr [edi], al - lea esi, [esi+1] - lea edi, [edi+1] - sub ecx, 1 - jnz short ftoa8Next -ftoa8End: - mov ecx,ebx - or ecx,ecx - jz short ftoa9 - mov eax,46 // "." - stosb - -ftoa9Next: // copy required decimal digits - movzx eax, byte ptr [esi] - mov byte ptr [edi], al - lea esi, [esi+1] - lea edi, [edi+1] - sub ecx, 1 - jnz short ftoa9Next -ftoa9: - jmp finish - -scientific: - movsb // insert sign - - cmp byte ptr[esi-1], 20h // test if we insert space - jnz short ftoa90 - lea edi, [edi-1] // erase it - -ftoa90: - mov ecx, ebx - mov eax, 18 - sub eax, ecx - add esi, eax - cmp byte ptr[esi-1],49 // "1" - pushfd // save flags for extra "1" - jnz short ftoa10 - sub esi, 1 -ftoa10: - movsb // copy the integer - xor eax, eax - stosb - - mov eax,46 // "." - stosb - -ftoa10Next: // copy the decimal digits - movzx eax, byte ptr [esi] - mov byte ptr [edi], al - lea esi, [esi+1] - lea edi, [edi+1] - sub ecx, 1 - jnz short ftoa10Next - - mov eax,69 // "E" - stosb - mov eax,43 // "+" - mov ecx,[ebp-12] - popfd // retrieve flags for extra "1" - jnz short ftoa11 // no extra "1" - add ecx, 1 // adjust exponent -ftoa11: - or ecx,ecx - jns short ftoa12 - mov eax,45 // "-" - neg ecx // make number positive -ftoa12: - stosb // insert proper sign - -// Note: the absolute value of the size could not exceed 4931 - - xor ebx, ebx - mov eax,ecx - mov cl,100 - div cl // ->thousands & hundreds in al, tens & units in AH - push eax - and eax,0ffh // keep only the thousands & hundreds - mov cl,10 - div cl // ->thousands in al, hundreds in AH - add eax,3030h // convert to characters - mov bl, al // insert them - mov byte ptr [edi], bl - lea edi, [edi+1] - shr eax, 8 - mov bl, al - mov byte ptr [edi], bl - lea edi, [edi+1] - pop eax - shr eax,8 // get the tens & units in al - div cl // tens in al, units in AH - add eax,3030h // convert to characters - - mov bl, al // insert them - mov byte ptr [edi], bl - lea edi, [edi+1] - shr eax, 8 - mov bl, al - mov byte ptr [edi], bl - lea edi, [edi+1] - -finish: - cmp byte ptr [edi-1], 48 // '0' - jnz short finish1 - lea edi, [edi-1] - jmp short finish - -finish1: - cmp byte ptr [edi-1], 46 // '.' - jnz short finish2 - lea edi, [edi+1] - -finish2: - mov ebx, edi - pop edi - add esp, 52 - pop ebp - - sub ebx, edi - mov edx, ebx - - jmp short finish3 - -srcerr: - pop edi - add esp, 52 - pop ebp - xor ebx,ebx -finish3: - -/* -oldcw :-4 (4) -truncw :-8 (4) -esize :-12 (4) -tempdw :-16 (4) -bcdstr :-28 (12) // -20 -unpacked:- (52) // -32 -*/ - - ret -end - -procedure coreapi'realtowstr - - mov edi, [esp+12] - mov esi, [esp+8] // ; radix - mov eax, [esp+4] // ; get str - mov ebx, [esi] - - mov ecx, eax - push ebp - mov ebp, esp - - sub esp, 52 - - push edi - - lea ebx, [ebx-3] // get the number of decimal digits (minus 2 for sign and dot) - cmp ebx, 13 - jbe short ftoa1 - mov ebx, 13 -ftoa1: - xor edx, edx - - //------------------------------------------- - //first examine the value on FPU for validity - //------------------------------------------- - - fld qword ptr [ecx] - fxam // examine value on FPU - fstsw ax // get result - - sahf // transfer to CPU flags - jz short maybezero - jpo srcerr // C3=0 and C2=0 would be NAN or unsupported - jnc short getnumsize // continue if normal finite number - - //-------------------------------- - //value to be converted = INFINITY - //-------------------------------- - - mov al,43 // "+" - test ah,2 // C1 field = sign - jz short ftoa2 - mov al, 45 // "-" -ftoa2: - and eax, 0FFh - stosw - mov eax,4E0049h // "NI" - stosd - mov eax,490046h // "IF" - stosd - mov eax,49004Eh // "IN" - stosd - mov eax,590054h // "YT" - stosd - jmp finish - - //------------------------- - //value to be converted = 0 - //------------------------- - -maybezero: - jpe short getnumsize // would be denormalized number - fstp st(0) // flush that 0 value off the FPU - mov eax,2E0030h // ".0" szstring - stosd // write it - mov eax,30h // "0" szstring - stosw // write it - jmp finish - - //--------------------------- - // get the size of the number - //--------------------------- - -getnumsize: - fldlg2 // log10(2) - fld st(1) // copy Src - fabs // insures a positive value - fyl2x // ->[log2(Src)]*[log10(2)] = log10(Src) - - fstcw word ptr [ebp-4] // get current control word - mov ax, word ptr [ebp-4] - or ax,0C00h // code it for truncating - mov word ptr [ebp-8],ax - fldcw word ptr [ebp-8] // insure rounding code of FPU to truncating - - fist [ebp-12] // store characteristic of logarithm - fldcw word ptr [ebp-4] // load back the former control word - - ftst // test logarithm for its sign - fstsw ax // get result - sahf // transfer to CPU flags - sbb [ebp-12],0 // decrement esize if log is negative - fstp st(0) // get rid of the logarithm - - //----------------------------------------------------------------------- - // get the power of 10 required to generate an integer with the specified - // number of significant digits - //----------------------------------------------------------------------- - - mov eax, [ebp-12] - lea eax, [eax+1] // one digit is required - or eax, eax - js short ftoa21 - cmp eax, 13 - jbe short ftoa20 - mov edx, -1 - mov ebx, 13 - mov ecx, ebx - sub ecx, eax - mov [ebp-16], ecx - jmp short ftoa22 - -ftoa20: - add eax, ebx - cmp eax, 13 - jbe short ftoa21 - sub eax, 13 - sub ebx, eax - -ftoa21: - mov [ebp-16], ebx - -ftoa22: - - //---------------------------------------------------------------------------------------- - // multiply the number by the power of 10 to generate required integer and store it as BCD - //---------------------------------------------------------------------------------------- - - fild dword ptr [ebp-16] - fldl2t - fmulp // ->log2(10)*exponent - fld st(0) - frndint // get the characteristic of the log - fxch st(1) - fsub st(0),st(1) // get only the fractional part but keep the characteristic - f2xm1 // ->2^(fractional part)-1 - fld1 - faddp // add 1 back - fscale // re-adjust the exponent part of the REAL number - fstp st(1) // get rid of the characteristic of the log - fmulp // ->16-digit integer - - fbstp tbyte ptr[ebp-28] // ->TBYTE containing the packed digits - fstsw ax // retrieve exception flags from FPU - shr eax,1 // test for invalid operation - jc srcerr // clean-up and return error - - //------------------------------------------------------------------------------ - // unpack BCD, the 10 bytes returned by the FPU being in the little-endian style - //------------------------------------------------------------------------------ - - lea esi, [ebp-19] // go to the most significant byte (sign byte) - push edi - lea edi,[ebp-52] - mov eax,3020h - movzx ecx,byte ptr[esi] // sign byte - cmp ecx, 00000080h - jnz short ftoa5 - mov al, 45 // insert sign if negative number -ftoa5: - - stosw - mov ecx,9 -ftoa6: - sub esi, 1 - movzx eax,byte ptr[esi] - ror ax,4 - ror ah,4 - add eax,3030h - stosw - sub ecx, 1 - jnz short ftoa6 - - pop edi - lea esi,[ebp-52] - - cmp edx, 0 - jnz short scientific - - //************************ - // REGULAR STRING NOTATION - //************************ - - movsb // insert sign - xor eax, eax - stosb - - cmp byte ptr[esi-1], 20h // test if we insert space - jnz short ftoa60 - lea edi, [edi-2] // erase it - -ftoa60: - mov ecx,1 // at least 1 integer digit - mov eax, [ebp-12] - or eax, eax // is size negative (i.e. number smaller than 1) - js short ftoa61 - add ecx, eax - -ftoa61: - mov eax, ebx - add eax, ecx // ->total number of digits to be displayed - sub eax, 19 - sub esi, eax // address of 1st digit to be displayed - cmp byte ptr[esi-1], 49 // "1" - jnz ftoa8 - sub esi, 1 - add ecx, 1 -ftoa8: - test ecx, ecx - jz short ftoa8End -ftoa8Next: // copy required integer digits - movzx eax, byte ptr [esi] - mov word ptr [edi], ax - lea esi, [esi+1] - lea edi, [edi+2] - sub ecx, 1 - jnz short ftoa8Next -ftoa8End: - mov ecx,ebx - or ecx,ecx - jz short ftoa9 - mov eax,46 // "." - stosw - -ftoa9Next: // copy required decimal digits - movzx eax, byte ptr [esi] - mov word ptr [edi], ax - lea esi, [esi+1] - lea edi, [edi+2] - sub ecx, 1 - jnz short ftoa9Next -ftoa9: - jmp finish - -scientific: - movsb // insert sign - xor eax, eax - stosb - - cmp byte ptr[esi-1], 20h // test if we insert space - jnz short ftoa90 - lea edi, [edi-2] // erase it - -ftoa90: - mov ecx, ebx - mov eax, 18 - sub eax, ecx - add esi, eax - cmp byte ptr[esi-1],49 // "1" - pushfd // save flags for extra "1" - jnz short ftoa10 - sub esi, 1 -ftoa10: - movsb // copy the integer - xor eax, eax - stosb - - mov eax,46 // "." - stosw - -ftoa10Next: // copy the decimal digits - movzx eax, byte ptr [esi] - mov word ptr [edi], ax - lea esi, [esi+1] - lea edi, [edi+2] - sub ecx, 1 - jnz short ftoa10Next - - mov eax,69 // "E" - stosw - mov eax,43 // "+" - mov ecx,[ebp-12] - popfd // retrieve flags for extra "1" - jnz short ftoa11 // no extra "1" - add ecx, 1 // adjust exponent -ftoa11: - or ecx,ecx - jns short ftoa12 - mov eax,45 // "-" - neg ecx // make number positive -ftoa12: - stosw // insert proper sign - -// Note: the absolute value of the size could not exceed 4931 - - xor ebx, ebx - mov eax,ecx - mov cl,100 - div cl // ->thousands & hundreds in al, tens & units in AH - push eax - and eax,0ffh // keep only the thousands & hundreds - mov cl,10 - div cl // ->thousands in al, hundreds in AH - add eax,3030h // convert to characters - mov bl, al // insert them - mov word ptr [edi], bx - lea edi, [edi+2] - shr eax, 8 - mov bl, al - mov word ptr [edi], bx - lea edi, [edi+2] - pop eax - shr eax,8 // get the tens & units in al - div cl // tens in al, units in AH - add eax,3030h // convert to characters - - mov bl, al // insert them - mov word ptr [edi], bx - lea edi, [edi+2] - shr eax, 8 - mov bl, al - mov word ptr [edi], bx - lea edi, [edi+2] - -finish: - cmp word ptr [edi-2], 48 // '0' - jnz short finish1 - lea edi, [edi-2] - jmp short finish - -finish1: - cmp word ptr [edi-2], 46 // '.' - jnz short finish2 - lea edi, [edi+2] - -finish2: - mov ebx, edi - pop edi - add esp, 52 - pop ebp - - sub ebx, edi - mov ecx, ebx - - jmp short finish3 - -srcerr: - pop edi - add esp, 52 - pop ebp - xor eax,eax -finish3: - -/* -oldcw :-4 (4) -truncw :-8 (4) -esize :-12 (4) -tempdw :-16 (4) -bcdstr :-28 (12) // -20 -unpacked:- (52) // -32 -*/ - - ret -end - -procedure coreapi'sequal - - mov edx, [esp+8] // ; s1 - mov esi, [esp+4] // ; s2 - - mov ecx, [edx-elSizeOffset] // s1.length - mov ebx, [esi-elSizeOffset] - and ecx, 0FFFFFh - and ebx, 0FFFFFh - mov eax, 0 - cmp ecx, ebx // compare with s2.length - jnz short Lab1 -Lab2: - mov ebx, [esi] - cmp bl, byte ptr [edx] - jnz short Lab1 - lea esi, [esi+1] - lea edx, [edx+1] - sub ecx, 1 - jnz short Lab2 - mov eax, 1 -Lab1: - mov edx, eax - ret - -end - -procedure coreapi'wequal - - mov edx, [esp+8] // ; s1 - mov esi, [esp+4] // ; s2 - - mov ecx, [edx-elSizeOffset] // s1.length - mov ebx, [esi-elSizeOffset] - and ecx, 0FFFFCh - and ebx, 0FFFFCh - mov eax, 0 - cmp ecx, ebx // compare with s2.length - jnz short Lab1 -Lab2: - mov ebx, [esi] - cmp ebx, [edx] - jnz short Lab1 - lea esi, [esi+4] - lea edx, [edx+4] - sub ecx, 4 - jnz short Lab2 - mov eax, 1 -Lab1: - mov edx, eax - ret - -end - -procedure coreapi'sless - - mov esi, [esp+8] // ; s1 - mov edx, [esp+4] // ; s2 - - mov ecx, [edx-elSizeOffset] // s1 length - mov eax, 0 - and ecx, 0FFFFFh -Lab2: - mov ebx, [edx] // s1[i] - cmp bl, byte ptr [esi] // compare s2[i] with - jb short Lab1 - nop - nop - ja short LabEnd - lea esi, [esi+1] - lea edx, [edx+1] - sub ecx, 1 - jnz short Lab2 - nop - nop - jmp short LabEnd - -Lab1: - mov eax, 1 - -LabEnd: - mov edx, eax - ret - -end - -procedure coreapi'wless - - mov esi, [esp+8] // ; s1 - mov edx, [esp+4] // ; s2 - - mov ecx, [edx-elSizeOffset] // s1 length - mov eax, 0 - and ecx, 0FFFFFh -Lab2: - mov ebx, [edx] // s1[i] - cmp bx, word ptr [esi] // compare s2[i] with - jb short Lab1 - nop - nop - ja short LabEnd - lea esi, [esi+2] - lea edx, [edx+2] - sub ecx, 2 - jnz short Lab2 - nop - nop - jmp short LabEnd - -Lab1: - mov eax, 1 - -LabEnd: - mov edx, eax - ret - -end - -// ; s_encode(index,out length, src, dst, out len2) -procedure coreapi's_encode - - mov ebx, [esp+8] - mov esi, [esp+4] - mov ecx, [ebx] - mov edi, [esp+16] - mov eax, [esp+12] - - push edi - add eax, [esi] - push eax - push ebx - -labNext: - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - cmp ebx, 00000080h - jl lab1 - cmp ebx, 000000C0h - jl err2 - cmp ebx, 000000E0h - jl short lab2 - cmp ebx, 000000F0h - jl lab3 - cmp ebx, 000000F8h - jl lab4 - nop - nop - jmp err2 - -lab2: - sub ecx, 2 - jb short err - mov esi, ebx - mov bl, byte ptr [eax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - shl esi, 6 - add esi, ebx - sub esi, 3080h - jmp labSave - -lab3: - sub ecx, 3 - jb err - mov esi, ebx - mov bl, byte ptr [eax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - cmp esi, 000000E0h - jnz short lab3_1 - cmp ebx, 000000A0h - jl err2 - -lab3_1: - shl esi, 12 - shl ebx, 6 - add esi, ebx - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - add esi, ebx - sub esi, 0E2080h - jmp labSave - -lab4: - sub ecx, 4 - jb short err - mov esi, ebx - mov bl, byte ptr [eax] - add eax, 1 - mov edx, ebx - and edx, 0C0h - cmp edx, 00000080h - jnz err2 - cmp esi, 000000F0h - jnz short lab4_1 - cmp ebx, 00000090h - jl err2 - -lab4_1: - cmp esi, 000000F4h - jnz short lab4_2 - cmp ebx, 00000090h - jae err2 - -lab4_2: - shl esi, 18 - shl ebx, 12 - add esi, ebx - - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - mov edx, ebx - and edx, 000000C0h - cmp edx, 00000080h - jnz err2 - - shl ebx, 6 - add esi, ebx - - xor ebx, ebx - mov bl, byte ptr [eax] - add eax, 1 - mov edx, ebx - and edx, 000000C0h - cmp edx, 00000080h - jnz err2 - - add esi, ebx - sub esi, 3C82080h - jmp labSave - -lab1: - mov esi, ebx - sub ecx, 1 - -labSave: - mov [edi], esi - add edi, 4 - - test ecx, ecx - jnz labNext - -err: - pop ebx - mov edx, eax - pop eax - sub edx, eax - mov ecx, edi - pop edi - sub ecx, edi - shr ecx, 2 - mov eax, [esp+20] - mov [eax], ecx - mov esi, [esp+8] - mov [esi], edx - - ret - -err2: - add esp, 12 - xor ebx, ebx - ret - -end - -procedure coreapi'ws_encode - - mov ebx, [esp+8] - mov esi, [esp+4] - mov ecx, [ebx] - mov edi, [esp+16] - mov eax, [esp+12] - - push edi - add eax, [esi] - push eax - push ebx - -labNext: - mov ebx, dword ptr [eax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0D800h - jl short lab1 - cmp ebx, 0DBFFh - jg short err2 - - sub ecx, 2 - jl short err - - mov esi, ebx - shl esi, 10 - mov ebx, dword ptr [eax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0DC00h - jl short lab2 - cmp ebx, 0DFFFh - jg short err2 - -lab2: - add ebx, esi - sub ebx, 35FDC00h - -lab1: - mov esi, ebx - sub ecx, 2 - -labSave: - mov [edi], esi - add edi, 4 - - test ecx, ecx - jnz labNext - -err: - pop ebx - mov edx, eax - pop eax - sub edx, eax - mov ecx, edi - pop edi - sub ecx, edi - shr ecx, 2 - mov eax, [esp+20] - mov [eax], ecx - mov esi, [esp+8] - mov [esi], edx - - ret - -err2: - add esp, 12 - xor ebx, ebx - ret - -end - -procedure coreapi'ws_encodew - - mov ebx, [esp+8] - mov esi, [esp+4] - mov ecx, [ebx] - mov edi, [esp+16] - shl ecx, 1 - mov eax, [esp+12] - - push edi - add eax, [esi] - add eax, [esi] - push eax - push ebx - -labNext: - mov ebx, dword ptr [eax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0D800h - jl short lab1 - cmp ebx, 0DBFFh - jg short err2 - - sub ecx, 2 - jl short err - - mov esi, ebx - shl esi, 10 - mov ebx, dword ptr [eax] - add eax, 2 - and ebx, 0FFFFh - cmp ebx, 0DC00h - jl short lab2 - cmp ebx, 0DFFFh - jg short err2 - -lab2: - add ebx, esi - sub ebx, 35FDC00h - -lab1: - mov esi, ebx - sub ecx, 2 - -labSave: - mov [edi], esi - add edi, 4 - - test ecx, ecx - jnz labNext - -err: - pop ebx - mov edx, eax - pop eax - sub edx, eax - mov ecx, edi - pop edi - sub ecx, edi - shr ecx, 2 - mov eax, [esp+20] - mov [eax], ecx - - ret - -err2: - add esp, 12 - xor ebx, ebx - ret - -end - -// ; s_decode(index,out length, src, dst, out len2) -procedure coreapi's_decode - - mov ebx, [esp+8] - mov esi, [esp+4] - mov ecx, [ebx] - mov edi, [esp+16] - mov ebx, [esi] - mov eax, [esp+12] - - push edi - lea eax, [eax + ebx * 4] - push eax - push ebx - -labNext: - mov ebx, [eax] - cmp ebx, 00000080h - jl short lab1 - cmp ebx, 0800h - jl short lab2 - cmp ebx, 10000h - jl short lab3 - - sub ecx, 1 - - mov edx, ebx - shr edx, 18 - and edx, 03Fh - add edx, 000000F0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - and edx, 03F000h - shr edx, 12 - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - and edx, 0FC0h - shr edx, 6 - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - jmp labSave - -lab2: - sub ecx, 1 - - mov edx, ebx - shr edx, 6 - add edx, 0C0h - mov byte ptr [edi], dl - add edi, 1 - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [edi], bl - add edi, 1 - jmp labSave - -lab3: - sub ecx, 1 - - mov edx, ebx - shr edx, 12 - add edx, 0E0h - mov byte ptr [edi], dl - add edi, 1 - - mov edx, ebx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi], dl - add edi, 1 - - and ebx, 03Fh - add ebx, 00000080h - mov byte ptr [edi], bl - jmp short labSave - -lab1: - mov byte ptr [edi], bl - add edi, 1 - sub ecx, 1 - -labSave: - add eax, 4 - test ecx, ecx - jnz labNext - -err: - pop ebx - mov edx, eax - pop eax - sub edx, eax - shr edx, 2 - mov ecx, edi - pop edi - sub ecx, edi - mov eax, [esp+20] - mov [eax], ecx - mov esi, [esp+8] - mov [esi], edx - mov ebx, eax - - ret - -end - -procedure coreapi'ws_decode - - mov ebx, [esp+8] - mov esi, [esp+4] - mov ecx, [ebx] - mov edi, [esp+16] - mov ebx, [esi] - mov eax, [esp+12] - - push edi - lea eax, [eax + ebx * 4] - push eax - push ebx - -labNext: - mov ebx, [eax] - cmp ebx, dword ptr 128 - jl short labCH1 - - cmp ebx, 0800h - jl short lab1 - - sub ecx, 2 - jl short err - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [edi], dx - add edi, 2 - - mov edx, ebx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [edi], dx - add edi, 2 - jmp short labSave - -lab1: - mov word ptr [edi], bx - add edi, 2 - sub ecx, 1 - jmp short labSave - -labCH1: - mov word ptr [edi], bx - add edi, 2 - sub ecx, 1 - -labSave: - add eax, 4 - test ecx, ecx - jnz labNext - -err: - pop ebx - mov edx, eax - pop eax - sub edx, eax - shr edx, 2 - mov ecx, edi - pop edi - sub ecx, edi - shr ecx, 1 - mov eax, [esp+20] - mov [eax], ecx - mov esi, [esp+8] - mov [esi], edx - mov ebx, eax - - ret - -err2: - add esp, 12 - xor ebx, ebx - ret - -end - -procedure coreapi'ws_decodew - - mov ebx, [esp+8] - mov esi, [esp+4] - mov ecx, [ebx] - mov edi, [esp+16] - mov ebx, [esi] - mov eax, [esp+12] - - push edi - lea eax, [eax + ebx * 4] - push eax - push ebx - -labNext: - mov ebx, [eax] - cmp ebx, dword ptr 128 - jl short labCH1 - - cmp ebx, 0800h - jl short lab1 - - sub ecx, 2 - jl short err - - mov edx, ebx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [edi], dx - add edi, 2 - - mov edx, ebx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [edi], dx - add edi, 2 - jmp short labSave - -lab1: - mov word ptr [edi], bx - add edi, 2 - sub ecx, 1 - jmp short labSave - -labCH1: - mov word ptr [edi], bx - add edi, 2 - sub ecx, 1 - -labSave: - add eax, 4 - test ecx, ecx - jnz labNext - -err: - pop ebx - mov edx, eax - pop eax - sub edx, eax - shr edx, 2 - mov ecx, edi - pop edi - sub ecx, edi - shr ecx, 1 - mov eax, [esp+20] - mov [eax], ecx - mov esi, [esp+8] - mov [esi], edx - mov ebx, eax - - ret - -err2: - add esp, 12 - xor ebx, ebx - ret - -end - -procedure coreapi'nsubcopy - - mov edi, [esp+4] - mov esi, [esp+12] - mov edx, [esp+4] - mov eax, [esp+16] - mov ecx, [esi] - mov ebx, [edx] - - mov esi, edi - test ecx, ecx - jz short labEnd - -labNext: - mov edx, [eax + ebx * 4] - mov [esi], edx - add ebx, 1 - lea esi, [esi + 4] - sub ecx, 1 - jnz short labNext - -labEnd: - ret - -end - -procedure coreapi'register_critical_exception_handler - - mov [data : % CORE_ET_TABLE], ebx - ret - -end - -// ; rcopyl (eax:char, edi - target) -procedure coreapi'chartoshorts - - mov esi, [esp+4] - mov eax, [esp+8] - mov ecx, [esi] - mov edi, [esp+12] - mov ebx, [eax] - - cmp ecx, 010000h - jl short lab1 - - mov edx, ecx - shr edx, 10 - add edx, 0D7C0h - mov word ptr [edi + ebx * 2], dx - add ebx, 1 - - mov edx, ecx - and edx, 03FFh - add edx, 0DC00h - mov word ptr [edi+ebx * 2], dx - mov edx, 2 - ret - -lab1: - mov [edi + ebx * 2], ecx - mov edx, 1 - ret - -end - -// ; (esi - index, ecx - char, edi - target ; out : ecx : length) -procedure coreapi'chartobytes - - mov esi, [esp+4] - mov eax, [esp+8] - mov ecx, [esi] - mov edi, [esp+12] - mov ebx, [eax] - - cmp ecx, 00000080h - jl short lab1 - cmp ecx, 0800h - jl short lab2 - cmp ecx, 10000h - jl short lab3 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi + ebx], dl - add ebx, 1 - - mov edx, ecx - shr edx, 12 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [edi + ebx], dl - add ebx, 1 - - mov edx, ecx - shr edx, 6 - and edx, 0000003Fh - add edx, 00000080h - mov byte ptr [edi + ebx], dl - add ebx, 1 - - mov edx, ecx - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi + ebx], dl - add ebx, 1 - mov edx, 4 - ret - -lab1: - mov byte ptr [edi + ebx], cl - add ebx, 1 - mov edx, 1 - ret - -lab2: - mov edx, ecx - shr edx, 6 - add edx, 0C0h - mov byte ptr [edi + ebx], dl - add ebx, 1 - - and ecx, 03Fh - add ecx, 00000080h - mov byte ptr [edi+ebx], cl - add ebx, 1 - mov edx, 2 - ret - -lab3: - mov edx, ecx - shr edx, 12 - add edx, 0E0h - mov byte ptr [edi + ebx], dl - add ebx, 1 - - mov edx, ecx - shr edx, 6 - and edx, 03Fh - add edx, 00000080h - mov byte ptr [edi+ebx], dl - add ebx, 1 - - and ecx, 03Fh - add ecx, 00000080h - mov byte ptr [edi+ebx], cl - add ebx, 1 - mov edx, 3 - ret - -end - -procedure coreapi'rpi - - fldpi - fstp qword ptr [ebx] // store result - ret - -end - -procedure coreapi'rsqrt - - mov eax, [esp+4] - fld qword ptr [eax] - fsqrt - fstp qword ptr [ebx] // store result - ret - -end - -procedure coreapi'core_rnd_init - - mov edi, [esp+4] - call code : % INIT_RND - mov [edi], eax - mov [edi+4], edx - mov ebx, eax - ret - -end - -procedure coreapi'core_rnd_next - - mov edi, [esp+4] - mov eax, [esp+12] - mov ebx, [esp+8] - - xor edx, edx - mov ecx, ebx - cmp ecx, edx - jle short labEnd - - push eax - push ebx - - mov ebx, [edi+4] // NUM.RE - mov esi, [edi] // NUM.FR - mov eax, ebx - mov ecx, 15Ah - mov ebx, 4E35h - test eax, eax - jz short Lab1 - mul ebx -Lab1: - xchg eax, ecx - mul esi - add eax, ecx - xchg eax, esi - mul ebx - add edx, esi - add eax, 1 - adc edx, 0 - mov ebx, eax - mov esi, edx - mov ecx, edi - mov [ecx+4], ebx - mov eax, esi - and eax, 7FFFFFFFh - mov [ecx] , esi - cdq - pop ecx - idiv ecx - pop eax -labEnd: - mov [eax], edx - ret - -end - -procedure coreapi'core_rnd_nextint - - mov edi, [esp+4] - mov eax, [esp+8] - - push eax - - mov ebx, [edi+4] // NUM.RE - mov esi, [edi] // NUM.FR - mov eax, ebx - mov ecx, 15Ah - mov ebx, 4E35h - test eax, eax - jz short Lab1 - mul ebx -Lab1: - xchg eax, ecx - imul esi - add eax, ecx - xchg eax, esi - imul ebx - add edx, esi - add eax, 1 - adc edx, 0 - mov ebx, eax - mov esi, edx - mov ecx, edi - mov [ecx+4], ebx - mov eax, esi - and eax, 7FFFFFFFh - mov [ecx], esi - mov edx, eax - pop eax -labEnd: - mov [eax], edx - ret - -end - -// core_utf8hashcode(s,len) -procedure coreapi'core_utf8hashcode - - mov eax, [esp+4] - mov ecx, [esp+8] - - mov edi, 15051505h - mov esi, edi - -labLoop: - cmp ecx, 8 - jb short labSkip - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, [eax] - xor ebx, edx - mov edi, ebx - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - mov edx, [eax+4] - xor ebx, edx - mov esi, ebx - - add eax, 8 - sub ecx, 8 - jmp short labLoop - - add ecx, 8 - and ecx, 7 - -labSkip: - cmp ecx, 4 - jb short labSkip2 - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, [eax] - xor ebx, edx - mov edi, ebx - add eax, 4 - sub ecx, 4 - -labSkip2: - mov ebx, 3 - sub ebx, ecx - shl ebx, 3 - mov ecx, ebx - - mov ebx, 0FFFFFFFFh - shr ebx, cl - mov ecx, [eax] - and ecx, ebx - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - xor ebx, ecx - mov esi, ebx - - mov edx, esi - imul edx, 1566083941 - add edx, edi - mov eax, edx - ret - -end - -// core_utf16hashcode(s,len) -procedure coreapi'core_utf16hashcode - - mov eax, [esp+4] - mov ecx, [esp+8] - - mov edi, 15051505h - mov esi, edi - -labLoop: - cmp ecx, 4 - jb short labSkip - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, [eax] - xor ebx, edx - mov edi, ebx - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - mov edx, [eax+4] - xor ebx, edx - mov esi, ebx - - add eax, 8 - sub ecx, 4 - jmp short labLoop - - add ecx, 4 - and ecx, 7 - -labSkip: - cmp ecx, 2 - jb short labSkip2 - - mov ebx, edi - shl ebx, 5 - mov edx, edi - add ebx, edi - shr edx, 27 - add ebx, edx - mov edx, [eax] - xor ebx, edx - mov edi, ebx - add eax, 4 - sub ecx, 2 - -labSkip2: - mov ecx, [eax] - - mov ebx, esi - shl ebx, 5 - mov edx, esi - add ebx, esi - shr edx, 27 - add ebx, edx - xor ebx, ecx - mov esi, ebx - - mov ebx, esi - imul ebx, 1566083941 - add ebx, edi - ret - -end - -// ; read_vmt (int,class,len,dump) = len -procedure coreapi'core_readvmt - - xor esi, esi - mov edx, [esp+12] - mov eax, [esp+8] - mov ecx, [eax - elVMTSizeOffset] - mov ebx, [esp+4] - mov edi, [esp+16] - sub ecx, ebx - jz labEnd - -labNext: - sub edx, 1 - test edx, edx - jz labEnd - - push edx - mov edx, [eax + ebx * 8] - mov [edi+esi*4], edx - pop edx - add esi, 1 - -labContinue: - add ebx, 1 - sub ecx, 1 - jnz labNext - -labEnd: - mov edx, esi - ret - -end - -procedure coreapi'wstrcharlen - - mov eax, [esp+4] - mov ecx, [esp+8] - push eax - -labNext: - mov edx, dword ptr [eax] - and edx, 0FFFFh - cmp edx, 0D800h - jl short lab1 - - add ebx, 1 - add eax, 4 - sub ecx, 2 - jnz short labNext - pop eax - ret - -lab1: - add ebx, 1 - add eax, 2 - sub ecx, 1 - jnz short labNext - mov edx, ebx - pop eax - ret - -end - -// ; strcharlen(s,len) -procedure coreapi'strcharlen - - mov eax, [esp+4] - mov ecx, [esp+8] - push eax - - xor edx, edx - xor ebx, ebx - -labNext: - mov dl, byte ptr [eax] - cmp edx, 00000080h - jl short lab1 - cmp edx, 000000E0h - jl short lab2 - cmp edx, 000000F0h - jl short lab3 - cmp edx, 000000F5h - jl short lab4 - -lab1: - add ebx, 1 - add eax, 1 - sub ecx, 1 - jnz short labNext - mov edx, ebx - pop eax - ret - -lab2: - add ebx, 1 - add eax, 2 - sub ecx, 2 - jnz short labNext - mov edx, ebx - pop eax - ret - -lab3: - add ebx, 1 - add eax, 3 - sub ecx, 3 - jnz short labNext - mov edx, ebx - pop eax - ret - -lab4: - add ebx, 1 - add eax, 4 - sub ecx, 4 - jnz short labNext - mov edx, ebx - pop ebx - ret - -end - -// ; longtoint(l) -procedure coreapi'longtoint - - mov ebx, [esp+4] - mov ecx, [ebx+4] - cmp ecx, 0 - jl labNegative - nop - jnz labErr - mov edx, [ebx] - ret -labNegative: - cmp ecx, 0FFFFFFFFh - jnz labErr - mov edx, [ebx] - ret - -labErr: - xor ebx, ebx - ret - -end - -// ; resolve_index (index) -procedure coreapi'resolve_index - - mov esi, [esp + 4] - mov ecx, [esi] - mov eax, [stat : "$elena'@referencetable"] - mov ebx, [eax + ecx * 4] - - ret 4 - -end - -procedure coreapi'resolve_index_value - - mov esi, [stat : "$elena'@referencetable"] - mov ebx, [esi + edx * 4] - - ret - -end - -procedure coreapi'alloc_index - - mov ebx, [stat : "$elena'@referencetable"] - - test ebx, ebx - jnz short labStart - - mov edx, 080h - call code : %CALC_SIZE - call code : %GC_ALLOC - mov [ebx-elSizeOffset], 80h - xor edx, edx - mov ecx, 20h -labCopy: - sub ecx, 1 - mov [ebx+ecx*4], edx - test ecx, ecx - jnz short labCopy - - mov [stat : "$elena'@referencetable"], ebx - -labStart: - // ; try to reuse existing slots - call code : %GET_COUNT - mov ecx, edx - xor edx, edx -labNext: - cmp [ebx+edx*4], 0 - jz short labReuse - add edx, 1 - cmp edx, ecx - jb short labNext - - // ; if no place reallocate the reference table - call code : %GET_COUNT - add edx, 10h - - push ebx - call code : %CALC_SIZE - call code : %GC_ALLOC - push ebx - mov ebx, [esp+4] - call code : %GET_COUNT - mov ecx, edx - add edx, 10h - mov edi, edx - pop ebx - - mov [ebx-elSizeOffset], edx - pop eax - - xor edx, edx -labCopy2: - mov esi, [eax+edx*4] - mov [ebx+edx*4], esi - add edx, 1 - cmp edx, ecx - jb short labCopy2 - - mov ecx, edi - xor esi, esi -labFill: - mov [ebx+edx*4], esi - add edx, 1 - cmp edx, ecx - jb short labFill - - mov [stat : "$elena'@referencetable"], ebx - jmp labStart - -labReuse: - mov [ebx + edx * 4], const : "system'nilValue" - - ret - -end - -// ; free_index -procedure coreapi'free_index - - mov ecx, [esp+4] - mov esi, [stat : "$elena'@referencetable"] - mov [esi + ecx * 4], 0 - - ret - -end - -procedure coreapi'default_handler - - // ; exit code - push 0 - call extern 'rt_dlls.Exit - -end - -procedure coreapi'get_seh_handler - - mov edx, data : % CORE_ET_TABLE - ret - -end - -// ; initProcess(frameHeader) -procedure coreapi'initProcess - - finit - lea edx, [esp+8] - mov eax, [esp+4] - mov [eax+4], edx - mov [eax+8], ebp - ret - -end - -// ; initThread(frameHeader) -procedure coreapi'initThread - - lea edx, [esp+8] - mov eax, [esp+4] - mov [eax+4], edx - mov [eax+8], ebp - ret - -end - -procedure coreapi'veh_handler - - push edx - push ebp - mov ebp, esp - mov edx, eax // ; set exception code - mov eax, [data : % CORE_ET_TABLE] - jmp eax - -end - -//procedure coreapi'seh_handler -// -// push ebp -// mov ebp, esp -// // ;** now [EBP+8]=pointer to EXCEPTION_RECORD -// // ;** [EBP+0Ch]=pointer to ERR structure -// // ;** [EBP+10h]=pointer to CONTEXT record -// push ebx -// push edi -// push esi -// mov ebx, [ebp+8] -// test ebx, ebx -// jz short lab5 -// test dword ptr[ebx+4],1h -// jnz lab5 -// test dword ptr[ebx+4],2h -// jz lab2 -// //; ... -// //; ... -// //; ... -// jmp lab5 -//lab2: -// mov esi, [ebp + 10h] -// -// // ; get critical exception handler -// mov eax, [data : % CORE_ET_TABLE] -// mov [esi+0B8h], eax // ; eip -// -// xor eax, eax -// jmp short lab6 -//lab5: -// mov eax, 1 -//lab6: -// pop esi -// pop edi -// pop ebx -// mov esp, ebp -// pop ebp -// ret -//end - -procedure coreapi'thread_default_handler - - // ; exit code - push 0FFFFFFFFh - call extern 'rt_dlls.StopThread - -end - -// tempObject(ptr), eax - vmt, edx - value -procedure coreapi'tempObject - - mov eax, [esp+4] - mov [eax-elVMTOffset], ebx - mov [eax], edx - mov [eax-elSizeOffset], 0800004h - ret - -end diff --git a/asm/x32/corex.asm b/asm/x32/corex.asm deleted file mode 100644 index 0c8e485b23..0000000000 --- a/asm/x32/corex.asm +++ /dev/null @@ -1,654 +0,0 @@ -// --- Predefined References -- -define GC_ALLOC 10001h -define HOOK 10010h -define INVOKER 10011h -define INIT_RND 10012h -define CALC_SIZE 1001Fh -define GET_COUNT 10020h -define THREAD_WAIT 10021h -define GC_ALLOCPERM 10031h - -define CORE_GC_TABLE 20002h -define CORE_STATICROOT 20005h -define CORE_TLS_INDEX 20007h -define THREAD_TABLE 20008h -define CORE_MESSAGE_TABLE 2000Ah -define CORE_ET_TABLE 2000Bh -define SYSTEM_ENV 2000Ch -define VOID 2000Dh -define VOIDPTR 2000Eh - -// GC TABLE OFFSETS -define gc_header 0000h -define gc_start 0004h -define gc_yg_start 0008h -define gc_yg_current 000Ch -define gc_yg_end 0010h -define gc_shadow 0014h -define gc_shadow_end 0018h -define gc_mg_start 001Ch -define gc_mg_current 0020h -define gc_end 0024h -define gc_mg_wbar 0028h -define gc_et_current 002Ch -define gc_stack_frame 0030h -define gc_lock 0034h -define gc_signal 0038h -define tt_ptr 003Ch -define tt_lock 0040h -define gc_rootcount 004Ch -define gc_perm_start 0050h -define gc_perm_end 0054h -define gc_perm_current 0058h - -// SYSTEM_ENV OFFSETS -define se_mgsize 0014h -define se_ygsize 001Ch - -// GCXT TLS TABLE -define tls_et_current 0000h -define tls_stack_frame 0004h -define tls_sync_event 0008h -define tls_flags 000Ch - -// Page Size -define page_size 10h -define page_size_order 4h -define page_size_order_minus2 2h -define page_mask 0FFFFFFF0h -define page_ceil 17h -define struct_mask 800000h -define struct_mask_inv 7FFFFFh - -// Object header fields -define elSizeOffset 0004h -define elSyncOffset 0004h -define elVMTOffset 0008h -define elObjectOffset 0008h - -define elPageSizeOffset 0004h -define elPageVMTOffset 0000h - -// VMT header fields -define elVMTSizeOffset 0004h -define elVMTFlagOffset 000Ch -define elPackageOffset 0010h - -define page_align_mask 000FFFF0h - -define ACTION_ORDER 9 -define ARG_ACTION_MASK 1DFh -define ACTION_MASK 1E0h -define ARG_MASK 01Fh -define ARG_MASK_INV 0FFFFFFE0h - -// --- GC_ALLOC --- -// in: ecx - size ; out: ebx - created object -procedure %GC_ALLOC - - // ; GCXT: set lock -labStart: - mov esi, data : %CORE_GC_TABLE + gc_lock -labWait: - mov edx, 1 - xor eax, eax - lock cmpxchg dword ptr[esi], edx - jnz short labWait - - mov eax, [data : %CORE_GC_TABLE + gc_yg_current] - mov edx, [data : %CORE_GC_TABLE + gc_yg_end] - add ecx, eax - cmp ecx, edx - jae short labYGCollect - mov [data : %CORE_GC_TABLE + gc_yg_current], ecx - - // ; GCXT: clear sync field - mov edx, 0FFFFFFFFh - lea ebx, [eax + elObjectOffset] - - // ; GCXT: free lock - // ; could we use mov [esi], 0 instead? - lock xadd [esi], edx - - ret - -labYGCollect: - // ; restore ecx - sub ecx, eax - - // ; GCXT: find the current thread entry - mov edx, fs:[2Ch] - mov eax, [data : %CORE_TLS_INDEX] - - // ; GCXT: save registers - mov eax, [edx+eax*4] - push ebp - - // ; GCXT: lock stack frame - // ; get current thread event - mov esi, [eax + tls_sync_event] - mov [eax + tls_stack_frame], esp - - push ecx - - // ; === GCXT: safe point === - mov edx, [data : %CORE_GC_TABLE + gc_signal] - // ; if it is a collecting thread, starts the GC - test edx, edx - jz short labConinue - // ; otherwise eax contains the collecting thread event - - // ; signal the collecting thread that it is stopped - push edx - push esi - call extern 'rt_dlls.GCSignalStop - add esp, 4 - - // ; free lock - // ; could we use mov [esi], 0 instead? - mov edi, data : %CORE_GC_TABLE + gc_lock - mov ebx, 0FFFFFFFFh - lock xadd [edi], ebx - - // ; stop until GC is ended - call extern 'rt_dlls.GCWaitForSignal - add esp, 4 - - // ; restore registers and try again - pop ecx - pop ebp - - jmp labStart - -labConinue: - - mov [data : %CORE_GC_TABLE + gc_signal], esi // set the collecting thread signal - mov ebp, esp - - // ; === thread synchronization === - - // ; create list of threads need to be stopped - mov eax, esi - // ; get tls entry address - mov esi, data : %THREAD_TABLE - mov edi, [esi - 4] -labNext: - mov edx, [esi] - test edx, edx - jz short labSkipTT - cmp eax, [edx + tls_sync_event] - setz cl - or ecx, [edx + tls_flags] - test ecx, 1 - // ; skip current thread signal / thread in safe region from wait list - jnz short labSkipSave - push [edx + tls_sync_event] -labSkipSave: - - // ; reset all signal events - push [edx + tls_sync_event] - call extern 'rt_dlls.GCSignalClear - add esp, 4 - - lea esi, [esi+4] - mov eax, [data : %CORE_GC_TABLE + gc_signal] -labSkipTT: - sub edi, 1 - jnz short labNext - - mov esi, data : %CORE_GC_TABLE + gc_lock - mov edx, 0FFFFFFFFh - mov ebx, ebp - - // ; free lock - // ; could we use mov [esi], 0 instead? - lock xadd [esi], edx - - mov ecx, esp - sub ebx, esp - jz short labSkipWait - - // ; wait until they all stopped - shr ebx, 2 - push ecx - push ebx - call extern 'rt_dlls.GCWaitForSignals - -labSkipWait: - // ; remove list - mov esp, ebp - - // ==== GCXT end ============== - - // ; create set of roots - mov ebp, esp - xor ecx, ecx - push ecx // ; reserve place - push ecx - push ecx - - // ; save static roots - mov esi, data : %CORE_STATICROOT - mov ecx, [data : %CORE_GC_TABLE + gc_rootcount] - push esi - push ecx - - // ; == GCXT: save frames == - mov eax, data : %THREAD_TABLE - mov ebx, [eax - 4] - -labYGNextThread: - sub ebx, 1 - mov eax, data : %THREAD_TABLE - - // ; get tls entry address - mov esi, [eax+ebx*4] - test esi, esi - jz short labYGNextThreadSkip - - // ; get the top frame pointer - mov eax, [esi + tls_stack_frame] - mov ecx, eax - -labYGNextFrame: - mov esi, eax - mov eax, [esi] - test eax, eax - jnz short labYGNextFrame - - push ecx - sub ecx, esi - neg ecx - push ecx - - mov eax, [esi + 4] - test eax, eax - mov ecx, eax - jnz short labYGNextFrame - nop - nop - -labYGNextThreadSkip: - test ebx, ebx - jnz short labYGNextThread - // ; == GCXT: end == - - // === Minor collection === - mov [ebp-4], esp // ; save position for roots - - mov ebx, [ebp] - mov eax, esp - - // ; restore rbp to correctly display a call stack - mov edx, ebp - mov ebp, [edx+4] - - push edx - push ebx - push eax - call extern 'rt_dlls.GCCollect - - mov edi, eax - add esp, 8 - pop ebp - - // ; GCXT: signal the collecting thread that GC is ended - // ; should it be placed into critical section? - xor ecx, ecx - mov esi, [data : %CORE_GC_TABLE + gc_signal] - // ; clear thread signal var - mov [data : %CORE_GC_TABLE + gc_signal], ecx - push esi - call extern 'rt_dlls.GCSignalStop - - mov ebx, edi - - mov esp, ebp - pop ecx - pop ebp - - ret - -end - -// --- GC_ALLOCPERM --- -// in: ecx - size ; out: ebx - created object -procedure %GC_ALLOCPERM - - // ; GCXT: set lock -labStart: - mov esi, data : %CORE_GC_TABLE + gc_lock -labWait: - mov edx, 1 - xor eax, eax - lock cmpxchg dword ptr[esi], edx - jnz short labWait - - mov eax, [data : %CORE_GC_TABLE + gc_perm_current] - mov edx, [data : %CORE_GC_TABLE + gc_perm_end] - add ecx, eax - cmp ecx, edx - jae short labPERMCollect - mov [data : %CORE_GC_TABLE + gc_perm_current], ecx - - // ; GCXT: clear sync field - mov edx, 0FFFFFFFFh - lea ebx, [eax + elObjectOffset] - - // ; GCXT: free lock - // ; could we use mov [esi], 0 instead? - lock xadd [esi], edx - - ret - -labPERMCollect: - // ; restore ecx - sub ecx, eax - - // ; GCXT: find the current thread entry - mov edx, fs:[2Ch] - mov eax, [data : %CORE_TLS_INDEX] - - // ; GCXT: save registers - mov eax, [edx+eax*4] - - // ; GCXT: lock stack frame - // ; get current thread event - mov esi, [eax + tls_sync_event] - mov [eax + tls_stack_frame], esp - - push ecx - - // ; === GCXT: safe point === - mov edx, [data : %CORE_GC_TABLE + gc_signal] - // ; if it is a collecting thread, starts the GC - test edx, edx - jz short labConinue - // ; otherwise eax contains the collecting thread event - - // ; signal the collecting thread that it is stopped - push edx - push esi - call extern 'rt_dlls.GCSignalStop - add esp, 4 - - // ; free lock - // ; could we use mov [esi], 0 instead? - mov edi, data : %CORE_GC_TABLE + gc_lock - mov ebx, 0FFFFFFFFh - lock xadd [edi], ebx - - // ; stop until GC is ended - call extern 'rt_dlls.GCWaitForSignal - add esp, 4 - - // ; restore registers and try again - pop ecx - - jmp labStart - -labConinue: - - push ebp - mov [data : %CORE_GC_TABLE + gc_signal], esi // set the collecting thread signal - mov ebp, esp - - // ; === thread synchronization === - - // ; create list of threads need to be stopped - mov eax, esi - // ; get tls entry address - mov esi, data : %THREAD_TABLE - mov edi, [esi - 4] -labNext: - mov edx, [esi] - test edx, edx - jz short labSkipTT - cmp eax, [edx + tls_sync_event] - setz cl - or ecx, [edx + tls_flags] - test ecx, 1 - // ; skip current thread signal / thread in safe region from wait list - jnz short labSkipSave - push [edx + tls_sync_event] -labSkipSave: - - // ; reset all signal events - push [edx + tls_sync_event] - call extern 'rt_dlls.GCSignalClear - add esp, 4 - - lea esi, [esi+4] - mov eax, [data : %CORE_GC_TABLE + gc_signal] -labSkipTT: - sub edi, 1 - jnz short labNext - - mov esi, data : %CORE_GC_TABLE + gc_lock - mov edx, 0FFFFFFFFh - mov ebx, ebp - - // ; free lock - // ; could we use mov [esi], 0 instead? - lock xadd [esi], edx - - mov ecx, esp - sub ebx, esp - jz short labSkipWait - - // ; wait until they all stopped - shr ebx, 2 - push ecx - push ebx - call extern 'rt_dlls.GCWaitForSignals - -labSkipWait: - // ; remove list - mov esp, ebp - pop ebp - - // ==== GCXT end ============== - - call extern 'rt_dlls.GCCollectPerm - - mov edi, eax - add esp, 4 - - // ; GCXT: signal the collecting thread that GC is ended - // ; should it be placed into critical section? - xor ecx, ecx - mov esi, [data : %CORE_GC_TABLE + gc_signal] - // ; clear thread signal var - mov [data : %CORE_GC_TABLE + gc_signal], ecx - push esi - call extern 'rt_dlls.GCSignalStop - - mov ebx, edi - - ret - -end - -// --- THREAD_WAIT --- -// GCXT: it is presumed that gc lock is on, edx - contains the collecting thread event handle - -procedure % THREAD_WAIT - - push ebx - push ebp - mov edi, esp - - push edx // hHandle - - // ; set lock - mov ebx, data : %CORE_GC_TABLE + gc_lock -labWait: - mov edx, 1 - xor eax, eax - lock cmpxchg dword ptr[ebx], edx - jnz short labWait - - // ; find the current thread entry - mov edx, fs:[2Ch] - mov eax, [data : %CORE_TLS_INDEX] - mov eax, [edx+eax*4] - - mov esi, [eax+tls_sync_event] // ; get current thread event - mov [eax+tls_stack_frame], edi // ; lock stack frame - - // ; signal the collecting thread that it is stopped - push esi - mov edi, data : %CORE_GC_TABLE + gc_lock - - // ; signal the collecting thread that it is stopped - call extern 'rt_dlls.GCSignalStop - add esp, 4 - - // ; free lock - // ; could we use mov [esi], 0 instead? - mov ebx, 0FFFFFFFFh - lock xadd [edi], ebx - - // ; stop until GC is ended - call extern 'rt_dlls.GCWaitForSignal - - add esp, 8 - pop ebx - - ret - -end - -// ; ==== Command Set == - -// ; snop -inline % 4 - - // ; safe point - mov edx, [data : %CORE_GC_TABLE + gc_signal] - test edx, edx // ; if it is a collecting thread, waits - jz short labConinue // ; otherwise goes on - - nop - nop - call code : %THREAD_WAIT // ; waits until the GC is stopped - -labConinue: - -end - -// ; throw -inline % 7 - - // ; GCXT: get current thread frame - mov esi, [data : %CORE_TLS_INDEX] - mov eax, fs:[2Ch] - mov esi, [eax+esi*4] - mov eax, [esi + tls_et_current] - - jmp [eax] - -end - -// ; unhook -inline % 1Dh - - // ; GCXT: get current thread frame - mov eax, [data : %CORE_TLS_INDEX] - mov esi, fs:[2Ch] - mov eax, [esi+eax*4] - - mov esi, [eax + tls_et_current] - - mov esp, [esi + 4] - mov ebp, [esi + 8] - pop esi - mov [eax + tls_et_current], esi - -end - -// ; include -inline % 25h - - add esp, 4 - mov ecx, fs:[2Ch] - mov eax, [data : %CORE_TLS_INDEX] - mov esi, [ecx+eax*4] - mov [esi + tls_flags], 0 - -end - -// ; exclude -inline % 26h - - mov ecx, fs:[2Ch] - mov eax, [data : %CORE_TLS_INDEX] - mov esi, [ecx+eax*4] - mov [esi + tls_flags], 1 - push ebp - mov [esi + tls_stack_frame], esp - -end - -// ; trylock -inline % 27h - - // ; GCXT: try to lock - mov esi, [esp] - xor eax, eax - mov ebx, 1 - lock cmpxchg byte ptr[esi - elSyncOffset], bl - mov edx, eax - mov ebx, esi - -end - -// ; freelock -inline % 28h - - mov ecx, -1 - - // ; free lock - lock xadd byte ptr [ebx - elSyncOffset], cl - -end - -// ; rethrow -inline % 29h - - // ; GCXT: get current thread frame - mov esi, [data : %CORE_TLS_INDEX] - mov ecx, fs:[2Ch] - mov ecx, [ecx+esi*4] - - mov esi, [ecx + tls_et_current] - mov esi, [esi + 4] - mov esi, [esi] - mov [ecx + tls_et_current], esi - - jmp [ecx + tls_et_current] - -end - -// ; hook label (ecx - offset) -// ; NOTE : hook calling should be the first opcode - -inline % 0A6h - - call code : %HOOK - - // ; GCXT: get current thread frame - mov eax, [data : %CORE_TLS_INDEX] - mov edi, fs:[2Ch] - mov eax, [edi+eax*4] - - push [eax + tls_et_current] - - mov esi, esp - push ebp - push esi - push ecx - - mov [eax + tls_et_current], esp - -end diff --git a/bin/elc.cfg b/bin/elc.cfg deleted file mode 100644 index 5085259e93..0000000000 --- a/bin/elc.cfg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - KERNEL32 - USER32 - GDI32 - WS2_32 - - - KERNEL32 - USER32 - - diff --git a/bin/elc.config b/bin/elc.config deleted file mode 100644 index 7f174c3a2b..0000000000 --- a/bin/elc.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - libc.so.6 - libdl.so.2 - /usr/lib/elena/libelenasm.so - - diff --git a/bin/elc60.cfg b/bin/elc60.cfg index 5d6b72813d..d42762be34 100644 --- a/bin/elc60.cfg +++ b/bin/elc60.cfg @@ -26,6 +26,7 @@ + diff --git a/bin/elenart.cfg b/bin/elenart.cfg deleted file mode 100644 index 736d14f402..0000000000 --- a/bin/elenart.cfg +++ /dev/null @@ -1,5 +0,0 @@ - - - ..\lib50 - - \ No newline at end of file diff --git a/bin/elenart.config b/bin/elenart.config deleted file mode 100644 index 507d7805fb..0000000000 --- a/bin/elenart.config +++ /dev/null @@ -1,5 +0,0 @@ - - - /usr/lib/elena/lib50 - - \ No newline at end of file diff --git a/bin/elt60.es b/bin/elt60.es index 97c00845fc..aa6de97eaf 100644 --- a/bin/elt60.es +++ b/bin/elt60.es @@ -4,5 +4,6 @@ #set preloaded preloadedSymbols #postfix " ^ ""safeEval[1]"" " - #start; + + #terminal ]] \ No newline at end of file diff --git a/bin/scripts/grammar60.es b/bin/scripts/grammar60.es index 2475461f7a..3cbedd864b 100644 --- a/bin/scripts/grammar60.es +++ b/bin/scripts/grammar60.es @@ -344,7 +344,7 @@ #define object ::= <= - system'dynamic'expressions'SymbolExpression ( + system'dynamic'expressions'LazySymbolExpression ( => "reference" "=" ref_quote <= diff --git a/bin/templates/lib60.cfg b/bin/templates/lib60.cfg index a6ad6fda61..e22db3aa39 100644 --- a/bin/templates/lib60.cfg +++ b/bin/templates/lib60.cfg @@ -17,13 +17,13 @@ import system; - #load system'operations'advanced'statementTemplates; + #load system'operations'advanced'statements; - system'attributes'attributeSymbols - system'predefined'predefinedSymbols - system'predefined'aliasTypes - system'operations'statementTemplates + system'attributes'attributes + system'predefined'defaults + system'predefined'aliases + system'operations'statements system'Object system'nilValue system'IntNumber diff --git a/bin/templates/lib60.config b/bin/templates/lib60.config index 5c497be541..5b322a3ae3 100644 --- a/bin/templates/lib60.config +++ b/bin/templates/lib60.config @@ -21,13 +21,13 @@ import system; - #load system'operations'advanced'statementTemplates; + #load system'operations'advanced'statements; - system'attributes'attributeSymbols - system'predefined'predefinedSymbols - system'predefined'aliasTypes - system'operations'statementTemplates + system'attributes'attributes + system'predefined'defaults + system'predefined'aliases + system'operations'statements system'Object system'nilValue system'IntNumber diff --git a/install/aarch64/build_package_arm64.script b/build/aarch64/build_package_arm64.script similarity index 96% rename from install/aarch64/build_package_arm64.script rename to build/aarch64/build_package_arm64.script index 631bd9dde3..053c1e0904 100755 --- a/install/aarch64/build_package_arm64.script +++ b/build/aarch64/build_package_arm64.script @@ -1,5 +1,5 @@ #!/bin/bash -RELEASE=elena-6.0.7.aarch64-linux +RELEASE=elena-6.0.9.aarch64-linux mkdir -p /usr/share/elena mkdir -p /etc/elena/ @@ -115,6 +115,16 @@ fi echo . fi + ../../bin/elena64-cli ../../src60/ltests/ltests.project + ret=$? + if [ $ret -eq 2 ] + then + echo "Failure" >&2 + exit 1 + else + echo . + fi + ../../bin/elena64-cli ../../tests60/system_tests/system_tests.project ret=$? if [ $ret -eq 2 ] diff --git a/install/aarch64/control b/build/aarch64/control similarity index 96% rename from install/aarch64/control rename to build/aarch64/control index 8d30593630..dbefcb3128 100644 --- a/install/aarch64/control +++ b/build/aarch64/control @@ -1,5 +1,5 @@ Package: elena-lang -Version: 6.0.8 +Version: 6.0.9 Architecture: aarch64 Maintainer: Alex Rakov Depends: libc6 (>= 2.1) diff --git a/install/amd64/build_package_amd64.script b/build/amd64/build_package_amd64.script similarity index 96% rename from install/amd64/build_package_amd64.script rename to build/amd64/build_package_amd64.script index 1c7455dabd..fdcf518a30 100755 --- a/install/amd64/build_package_amd64.script +++ b/build/amd64/build_package_amd64.script @@ -1,5 +1,5 @@ #!/bin/bash -RELEASE=elena-6.0.7.amd64-linux +RELEASE=elena-6.0.9.amd64-linux mkdir -p /usr/share/elena mkdir -p /etc/elena/ @@ -127,6 +127,16 @@ fi echo . fi + ../../bin/elena64-cli ../../src60/ltests/ltests.project + ret=$? + if [ $ret -eq 2 ] + then + echo "Failure" >&2 + exit 1 + else + echo . + fi + ../../bin/elena64-cli ../../tests60/system_tests/system_tests.project ret=$? if [ $ret -eq 2 ] diff --git a/install/amd64/control b/build/amd64/control similarity index 96% rename from install/amd64/control rename to build/amd64/control index cda42cb504..46232edc74 100644 --- a/install/amd64/control +++ b/build/amd64/control @@ -1,5 +1,5 @@ Package: elena-lang -Version: 6.0.8 +Version: 6.0.9 Architecture: amd64 Maintainer: Alex Rakov Depends: libc6 (>= 2.1) diff --git a/build/create_package_x64.bat b/build/create_package_x64.bat new file mode 100644 index 0000000000..b82079f98e --- /dev/null +++ b/build/create_package_x64.bat @@ -0,0 +1,223 @@ +@echo off + +ECHO =========== Compiling ELENA files ================== + +md %~dp0\x86 +md %~dp0\x64\bin +md %~dp0\x64\bin\templates +md %~dp0\x64\bin\scripts +md %~dp0\x64\bin\amd64 +md %~dp0\x64\doc +md %~dp0\x64\examples60 +md %~dp0\x64\examples60\console +md %~dp0\x64\examples60\console\helloworld +md %~dp0\x64\examples60\console\sum +md %~dp0\x64\examples60\console\words +md %~dp0\x64\examples60\console\binary +md %~dp0\x64\examples60\console\bsort +md %~dp0\x64\examples60\console\datetime +md %~dp0\x64\examples60\console\goods +md %~dp0\x64\examples60\console\replace +md %~dp0\x64\examples60\rosetta\accumulator +md %~dp0\x64\examples60\rosetta\ackermann +md %~dp0\x64\examples60\rosetta\addfield +md %~dp0\x64\examples60\rosetta\anonymrec +md %~dp0\x64\examples60\rosetta\aplusb +md %~dp0\x64\examples60\rosetta\applycallback +md %~dp0\x64\examples60\rosetta\arithmeticint +md %~dp0\x64\examples60\rosetta\arithmeval +md %~dp0\x64\examples60\rosetta\arithmmean +md %~dp0\x64\examples60\rosetta\arrayconcat +md %~dp0\x64\examples60\rosetta\arraymode +md %~dp0\x64\examples60\rosetta\arrays +md %~dp0\x64\examples60\rosetta\associativearrays +md %~dp0\x64\examples60\rosetta\bestshuffle +md %~dp0\x64\examples60\rosetta\binary +md %~dp0\x64\examples60\rosetta\bitwise +md %~dp0\x64\examples60\rosetta\brackets +md %~dp0\x64\examples60\rosetta\bullscows +md %~dp0\x64\examples60\rosetta\caesar +md %~dp0\x64\examples60\rosetta\calendar +md %~dp0\x64\examples60\rosetta\charmatch +md %~dp0\x64\examples60\rosetta\combinations +md %~dp0\x64\examples60\rosetta\doors +md %~dp0\x64\examples60\rosetta\evolutionary +md %~dp0\x64\examples60\rosetta\firstclass +md %~dp0\x64\examples60\rosetta\loop_multiple_arrays +md %~dp0\x64\examples60\rosetta\median +md %~dp0\x64\examples60\rosetta\ninetynine +md %~dp0\x64\examples60\rosetta\reverse_words_in_string +md %~dp0\x64\examples60\rosetta\smavg +md %~dp0\x64\examples60\rosetta\string_append + +copy %~dp0\..\bin\asm64-cli.exe %~dp0\x64\bin +copy %~dp0\..\bin\elena64-cli.exe %~dp0\x64\bin +copy %~dp0\..\bin\elena64-ide.exe %~dp0\x64\bin +copy %~dp0\..\bin\sg64-cli.exe %~dp0\x64\bin +copy %~dp0\..\bin\og64-cli.exe %~dp0\x64\bin +copy %~dp0\..\bin\ecv64-cli.exe %~dp0\x64\bin +copy %~dp0\..\bin\elenart60_64.dll %~dp0\x64\bin +copy %~dp0\..\bin\winstub.ex_ %~dp0\x64\bin +copy %~dp0\..\bin\elc60.cfg %~dp0\x64\bin +copy %~dp0\..\bin\elenart60.cfg %~dp0\x64\bin +copy %~dp0\..\bin\elenavm60.cfg %~dp0\x64\bin + +copy %~dp0\..\bin\amd64\core60.bin %~dp0\x64\bin\amd64 +copy %~dp0\..\bin\amd64\core60_win.bin %~dp0\x64\bin\amd64 +copy %~dp0\..\bin\amd64\corex60.bin %~dp0\x64\bin\amd64 + +copy %~dp0\..\bin\templates\*.cfg %~dp0\x64\bin\templates\ +copy %~dp0\..\bin\scripts\*.es %~dp0\x64\bin\scripts\ + +copy %~dp0\..\doc\license %~dp0\x64\doc\ +copy %~dp0\..\doc\contributors %~dp0\x64\doc\ +copy %~dp0\..\readme.md %~dp0\x64\ + +md %~dp0\x64\src60\system +xcopy %~dp0\..\src60\system\*.l %~dp0\x64\src60\system /s +xcopy %~dp0\..\src60\system\*.prj %~dp0\x64\src60\system /s + +md %~dp0\x64\src60\extensions +xcopy %~dp0\..\src60\extensions\*.l %~dp0\x64\src60\extensions /s +xcopy %~dp0\..\src60\extensions\*.prj %~dp0\x64\src60\extensions /s + +md %~dp0\x64\src60\algorithms +xcopy %~dp0\..\src60\algorithms\*.l %~dp0\x64\src60\algorithms /s +xcopy %~dp0\..\src60\algorithms\*.prj %~dp0\x64\src60\algorithms /s + +md %~dp0\x64\src60\cellular +xcopy %~dp0\..\src60\cellular\*.l %~dp0\x64\src60\cellular /s +xcopy %~dp0\..\src60\cellular\*.prj %~dp0\x64\src60\cellular /s + +md %~dp0\x64\src60\sqlite +xcopy %~dp0\..\src60\sqlite\*.l %~dp0\x64\src60\sqlite /s +xcopy %~dp0\..\src60\sqlite\*.prj %~dp0\x64\src60\sqlite /s + +md %~dp0\x64\src60\forms +xcopy %~dp0\..\src60\forms\*.l %~dp0\x64\src60\forms /s +xcopy %~dp0\..\src60\forms\*.prj %~dp0\x64\src60\forms /s + +md %~dp0\x64\src60\ltests +xcopy %~dp0\..\src60\ltests\*.l %~dp0\x64\src60\ltests /s +xcopy %~dp0\..\src60\ltests\*.prj %~dp0\x64\src60\ltests /s + +%~dp0\..\bin\sg64-cli.exe %~dp0\..\dat\sg\syntax60.txt +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +move %~dp0..\dat\sg\syntax60.dat %~dp0\x64\bin\ + +%~dp0\..\bin\og64-cli %~dp0\..\dat\og\bc_rules60.txt +%~dp0\..\bin\og64-cli -s %~dp0\..\dat\og\bt_rules60.txt + +move %~dp0..\dat\og\bt_rules60.dat %~dp0\x64\bin\ +move %~dp0..\dat\og\bc_rules60.dat %~dp0\x64\bin\ + +md %~dp0\lib60_64 + +%~dp0\..\bin\asm64-cli -bc64 %~dp0\..\src60\core\system.core_routines.esm %~dp0\x64\lib60_64 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\..\bin\asm64-cli -bc64 %~dp0\..\src60\core\system.win_core_routines.esm %~dp0\x64\lib60_64 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x64\bin\elena64-cli %~dp0\x64\src60\system\system.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x64\bin\elena64-cli %~dp0\x64\src60\extensions\extensions.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x64\bin\elena64-cli %~dp0\x64\src60\cellular\cellular.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x64\bin\elena64-cli %~dp0\x64\src60\algorithms\algorithms.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x64\bin\elena64-cli %~dp0\x64\src60\sqlite\sqlite.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x64\bin\elena64-cli %~dp0\x64\src60\forms\forms.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\..\bin\asm64-cli -amd64 %~dp0\..\asm\amd64\core60.asm bin\amd64 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\..\bin\asm64-cli -amd64 %~dp0\..\asm\amd64\core60_win.asm bin\amd64 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +copy %~dp0\..\examples60\console\helloworld\*.l %~dp0\x64\examples60\console\helloworld +copy %~dp0\..\examples60\console\helloworld\*.prj %~dp0\x64\examples60\console\helloworld + +copy %~dp0\..\examples60\console\sum\*.l %~dp0\x64\examples60\console\sum +copy %~dp0\..\examples60\console\sum\*.prj %~dp0\x64\examples60\console\sum + +copy %~dp0\..\examples60\console\words\*.l %~dp0\x64\examples60\console\words +copy %~dp0\..\examples60\console\binary\*.l %~dp0\x64\examples60\console\binary +copy %~dp0\..\examples60\console\bsort\*.l %~dp0\x64\examples60\console\bsort +copy %~dp0\..\examples60\console\datetime\*.l %~dp0\x64\examples60\console\datetime +copy %~dp0\..\examples60\console\datetime\*.prj %~dp0\x64\examples60\console\datetime +copy %~dp0\..\examples60\console\goods\*.l %~dp0\x64\examples60\console\goods +copy %~dp0\..\examples60\console\goods\*.txt %~dp0\x64\examples60\console\goods +copy %~dp0\..\examples60\console\replace\*.l %~dp0\x64\examples60\console\replace + +copy %~dp0\..\examples60\rosetta\accumulator\*.l %~dp0\x64\examples60\rosetta\accumulator +copy %~dp0\..\examples60\rosetta\ackermann\*.l %~dp0\x64\examples60\rosetta\ackermann +copy %~dp0\..\examples60\rosetta\addfield\*.l %~dp0\x64\examples60\rosetta\addfield +copy %~dp0\..\examples60\rosetta\anonymrec\*.l %~dp0\x64\examples60\rosetta\anonymrec +copy %~dp0\..\examples60\rosetta\aplusb\*.l %~dp0\x64\examples60\rosetta\aplusb +copy %~dp0\..\examples60\rosetta\applycallback\*.l %~dp0\x64\examples60\rosetta\applycallback +copy %~dp0\..\examples60\rosetta\arithmeticint\*.l %~dp0\x64\examples60\rosetta\arithmeticint +copy %~dp0\..\examples60\rosetta\arithmeval\*.l %~dp0\x64\examples60\rosetta\arithmeval +copy %~dp0\..\examples60\rosetta\arithmmean\*.l %~dp0\x64\examples60\rosetta\arithmmean +copy %~dp0\..\examples60\rosetta\arrayconcat\*.l %~dp0\x64\examples60\rosetta\arrayconcat +copy %~dp0\..\examples60\rosetta\arraymode\*.l %~dp0\x64\examples60\rosetta\arraymode +copy %~dp0\..\examples60\rosetta\arrays\*.l %~dp0\x64\examples60\rosetta\arrays + +copy %~dp0\..\examples60\rosetta\associativearrays\*.l %~dp0\x64\examples60\rosetta\associativearrays +copy %~dp0\..\examples60\rosetta\bestshuffle\*.l %~dp0\x64\examples60\rosetta\bestshuffle +copy %~dp0\..\examples60\rosetta\binary\*.l %~dp0\x64\examples60\rosetta\binary +copy %~dp0\..\examples60\rosetta\bitwise\*.l %~dp0\x64\examples60\rosetta\bitwise +copy %~dp0\..\examples60\rosetta\brackets\*.l %~dp0\x64\examples60\rosetta\brackets +copy %~dp0\..\examples60\rosetta\bullscows\*.l %~dp0\x64\examples60\rosetta\bullscows +copy %~dp0\..\examples60\rosetta\caesar\*.l %~dp0\x64\examples60\rosetta\caesar +copy %~dp0\..\examples60\rosetta\calendar\*.l %~dp0\x64\examples60\rosetta\calendar +copy %~dp0\..\examples60\rosetta\charmatch\*.l %~dp0\x64\examples60\rosetta\charmatch +copy %~dp0\..\examples60\rosetta\combinations\*.l %~dp0\x64\examples60\rosetta\combinations +copy %~dp0\..\examples60\rosetta\doors\*.l %~dp0\x64\examples60\rosetta\doors +copy %~dp0\..\examples60\rosetta\evolutionary\*.l %~dp0\x64\examples60\rosetta\evolutionary +copy %~dp0\..\examples60\rosetta\firstclass\*.l %~dp0\x64\examples60\rosetta\firstclass +copy %~dp0\..\examples60\rosetta\loop_multiple_arrays\*.l %~dp0\x64\examples60\rosetta\loop_multiple_arrays +copy %~dp0\..\examples60\rosetta\median\*.l %~dp0\x64\examples60\rosetta\median +copy %~dp0\..\examples60\rosetta\ninetynine\*.l %~dp0\x64\examples60\rosetta\ninetynine +copy %~dp0\..\examples60\rosetta\reverse_words_in_string\*.l %~dp0\x64\examples60\rosetta\reverse_words_in_string +copy %~dp0\..\examples60\rosetta\smavg\*.l %~dp0\x64\examples60\rosetta\smavg +copy %~dp0\..\examples60\rosetta\string_append\*.l %~dp0\x64\examples60\rosetta\string_append +copy %~dp0\..\examples60\rosetta\twentyfour\*.l %~dp0\x64\examples60\rosetta\twentyfour + +goto:eof +::ERRORS +::--------------------- +:CompilerError +echo The MSBuild returns error %ERRORLEVEL% +goto:eof diff --git a/build/create_package_x86.bat b/build/create_package_x86.bat new file mode 100644 index 0000000000..ed8ae77976 --- /dev/null +++ b/build/create_package_x86.bat @@ -0,0 +1,318 @@ +@echo off + +ECHO =========== Compiling ELENA files ================== + +md %~dp0\x86 +md %~dp0\x86\bin +md %~dp0\x86\bin\templates +md %~dp0\x86\bin\scripts +md %~dp0\x86\bin\x32 +md %~dp0\x86\doc +md %~dp0\x86\examples60 +md %~dp0\x86\examples60\console +md %~dp0\x86\examples60\console\helloworld +md %~dp0\x86\examples60\console\sum +md %~dp0\x86\examples60\console\words +md %~dp0\x86\examples60\console\binary +md %~dp0\x86\examples60\console\bsort +md %~dp0\x86\examples60\console\datetime +md %~dp0\x86\examples60\console\goods +md %~dp0\x86\examples60\console\replace +md %~dp0\x86\examples60\console\pi +md %~dp0\x86\examples60\console\matrix +md %~dp0\x86\examples60\console\random +md %~dp0\x86\examples60\files +md %~dp0\x86\examples60\files\textdb +md %~dp0\x86\examples60\files\textfile +md %~dp0\x86\examples60\scripts\calc +md %~dp0\x86\examples60\scripts\interpreter +md %~dp0\x86\examples60\scripts\js +md %~dp0\x86\examples60\scripts\ls +md %~dp0\x86\examples60\rosetta\accumulator +md %~dp0\x86\examples60\rosetta\ackermann +md %~dp0\x86\examples60\rosetta\addfield +md %~dp0\x86\examples60\rosetta\anonymrec +md %~dp0\x86\examples60\rosetta\aplusb +md %~dp0\x86\examples60\rosetta\applycallback +md %~dp0\x86\examples60\rosetta\arithmeticint +md %~dp0\x86\examples60\rosetta\arithmeval +md %~dp0\x86\examples60\rosetta\arithmmean +md %~dp0\x86\examples60\rosetta\arrayconcat +md %~dp0\x86\examples60\rosetta\arraymode +md %~dp0\x86\examples60\rosetta\arrays +md %~dp0\x86\examples60\rosetta\associativearrays +md %~dp0\x86\examples60\rosetta\bestshuffle +md %~dp0\x86\examples60\rosetta\binary +md %~dp0\x86\examples60\rosetta\bitwise +md %~dp0\x86\examples60\rosetta\brackets +md %~dp0\x86\examples60\rosetta\bullscows +md %~dp0\x86\examples60\rosetta\caesar +md %~dp0\x86\examples60\rosetta\calendar +md %~dp0\x86\examples60\rosetta\charmatch +md %~dp0\x86\examples60\rosetta\combinations +md %~dp0\x86\examples60\rosetta\doors +md %~dp0\x86\examples60\rosetta\evolutionary +md %~dp0\x86\examples60\rosetta\firstclass +md %~dp0\x86\examples60\rosetta\loop_multiple_arrays +md %~dp0\x86\examples60\rosetta\median +md %~dp0\x86\examples60\rosetta\ninetynine +md %~dp0\x86\examples60\rosetta\reverse_words_in_string +md %~dp0\x86\examples60\rosetta\smavg +md %~dp0\x86\examples60\rosetta\string_append + +md %~dp0\x86\examples60\gui\c_a_g +md %~dp0\x86\examples60\gui\c_a_g\formulas +md %~dp0\x86\examples60\gui\c_a_g\formulas\Circulo +md %~dp0\x86\examples60\gui\c_a_g\formulas\Paralelogramos +md %~dp0\x86\examples60\gui\c_a_g\formulas\Trapezio +md %~dp0\x86\examples60\gui\c_a_g\formulas\Triangulos + +md %~dp0\x86\examples60\gui\agenda +md %~dp0\x86\examples60\gui\graphs +md %~dp0\x86\examples60\gui\helloworld + +md %~dp0\x86\examples60\db +md %~dp0\x86\examples60\db\sqlite + +copy %~dp0\..\bin\asm-cli.exe %~dp0\x86\bin +copy %~dp0\..\bin\elena-cli.exe %~dp0\x86\bin +copy %~dp0\..\bin\elena-ide.exe %~dp0\x86\bin +copy %~dp0\..\bin\sg-cli.exe %~dp0\x86\bin +copy %~dp0\..\bin\og-cli.exe %~dp0\x86\bin +copy %~dp0\..\bin\ecv-cli.exe %~dp0\x86\bin +copy %~dp0\..\bin\elt-cli.exe %~dp0\x86\bin +copy %~dp0\..\bin\elenart60.dll %~dp0\x86\bin +copy %~dp0\..\bin\elenasm60.dll %~dp0\x86\bin +copy %~dp0\..\bin\elenavm60.dll %~dp0\x86\bin +copy %~dp0\..\bin\winstub.ex_ %~dp0\x86\bin +copy %~dp0\..\bin\elc60.cfg %~dp0\x86\bin +copy %~dp0\..\bin\elenart60.cfg %~dp0\x86\bin +copy %~dp0\..\bin\elenavm60.cfg %~dp0\x86\bin +copy %~dp0\..\bin\elt60.es %~dp0\x86\bin +copy %~dp0\..\bin\command60.es %~dp0\x86\bin + +copy %~dp0\..\bin\x86\core60.bin %~dp0\x86\bin\x86\ +copy %~dp0\..\bin\x86\core60_win.bin %~dp0\x86\bin\x86\ +copy %~dp0\..\bin\x86\core60_win.bin %~dp0\x86\bin\x86\ +copy %~dp0\..\bin\x86\core60_win_client.bin %~dp0\x86\bin\x86\ +copy %~dp0\..\bin\x86\corex60.bin %~dp0\x86\bin\x86\ + +copy %~dp0\..\bin\templates\*.cfg %~dp0\x86\bin\templates\ +copy %~dp0\..\bin\scripts\*.es %~dp0\x86\bin\scripts\ + +copy %~dp0\..\doc\license %~dp0\x86\doc\ +copy %~dp0\..\doc\contributors %~dp0\x86\doc\ +copy %~dp0\..\readme.md %~dp0\x86\ +copy %~dp0\..\CHANGELOG.md %~dp0\x86\ + +md %~dp0\x86\src60\system +xcopy %~dp0\..\src60\system\*.l %~dp0\x86\src60\system /s +xcopy %~dp0\..\src60\system\*.prj %~dp0\x86\src60\system /s + +md %~dp0\x86\src60\extensions +xcopy %~dp0\..\src60\extensions\*.l %~dp0\x86\src60\extensions /s +xcopy %~dp0\..\src60\extensions\*.prj %~dp0\x86\src60\extensions /s + +md %~dp0\x86\src60\algorithms +xcopy %~dp0\..\src60\algorithms\*.l %~dp0\x86\src60\algorithms /s +xcopy %~dp0\..\src60\algorithms\*.prj %~dp0\x86\src60\algorithms /s + +md %~dp0\x86\src60\cellular +xcopy %~dp0\..\src60\cellular\*.l %~dp0\x86\src60\cellular /s +xcopy %~dp0\..\src60\cellular\*.prj %~dp0\x86\src60\cellular /s + +md %~dp0\x86\src60\sqlite +xcopy %~dp0\..\src60\sqlite\*.l %~dp0\x86\src60\sqlite /s +xcopy %~dp0\..\src60\sqlite\*.prj %~dp0\x86\src60\sqlite /s + +md %~dp0\x86\src60\forms +xcopy %~dp0\..\src60\forms\*.l %~dp0\x86\src60\forms /s +xcopy %~dp0\..\src60\forms\*.prj %~dp0\x86\src60\forms /s + +md %~dp0\x86\src60\xforms +xcopy %~dp0\..\src60\xforms\*.l %~dp0\x86\src60\xforms /s +xcopy %~dp0\..\src60\xforms\*.prj %~dp0\x86\src60\xforms /s + +md %~dp0\x86\src60\ltests +xcopy %~dp0\..\src60\ltests\*.l %~dp0\x86\src60\ltests /s +xcopy %~dp0\..\src60\ltests\*.prj %~dp0\x86\src60\ltests /s + +%~dp0\..\bin\sg-cli.exe %~dp0\..\dat\sg\syntax60.txt +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +move %~dp0..\dat\sg\syntax60.dat %~dp0\x86\bin\ + +%~dp0\..\bin\og-cli %~dp0\..\dat\og\bc_rules60.txt +%~dp0\..\bin\og-cli -s %~dp0\..\dat\og\bt_rules60.txt + +move %~dp0..\dat\og\bt_rules60.dat %~dp0\x86\bin\ +move %~dp0..\dat\og\bc_rules60.dat %~dp0\x86\bin\ + +md %~dp0\lib60 + +%~dp0\..\bin\asm-cli -bc32 %~dp0\..\src60\core\system.core_routines.esm %~dp0\x86\lib60 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\..\bin\asm-cli -bc32 %~dp0\..\src60\core\system.win_core_routines.esm %~dp0\x86\lib60 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\system\system.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\extensions\extensions.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\cellular\cellular.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\algorithms\algorithms.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\ltests\ltests.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\sqlite\sqlite.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\forms\forms.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\x86\bin\elena-cli %~dp0\x86\src60\xforms\xforms.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\..\bin\asm-cli -x86 %~dp0\..\asm\x86\core60.asm bin\x32 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +%~dp0\..\bin\asm-cli -x86 %~dp0\..\asm\x86\core60_win.asm bin\x32 +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +copy %~dp0\..\examples60\console\helloworld\*.l %~dp0\x86\examples60\console\helloworld +copy %~dp0\..\examples60\console\helloworld\*.prj %~dp0\x86\examples60\console\helloworld + +copy %~dp0\..\examples60\console\sum\*.l %~dp0\x86\examples60\console\sum +copy %~dp0\..\examples60\console\sum\*.prj %~dp0\x86\examples60\console\sum + +copy %~dp0\..\examples60\console\words\*.l %~dp0\x86\examples60\console\words +copy %~dp0\..\examples60\console\binary\*.l %~dp0\x86\examples60\console\binary +copy %~dp0\..\examples60\console\bsort\*.l %~dp0\x86\examples60\console\bsort +copy %~dp0\..\examples60\console\datetime\*.l %~dp0\x86\examples60\console\datetime +copy %~dp0\..\examples60\console\datetime\*.prj %~dp0\x86\examples60\console\datetime +copy %~dp0\..\examples60\console\goods\*.l %~dp0\x86\examples60\console\goods +copy %~dp0\..\examples60\console\goods\*.txt %~dp0\x86\examples60\console\goods +copy %~dp0\..\examples60\console\replace\*.l %~dp0\x86\examples60\console\replace +copy %~dp0\..\examples60\console\pi\*.l %~dp0\x86\examples60\console\pi +copy %~dp0\..\examples60\console\matrix\*.l %~dp0\x86\examples60\console\matrix +copy %~dp0\..\examples60\console\matrix\*.prj %~dp0\x86\examples60\console\matrix +copy %~dp0\..\examples60\console\random\*.l %~dp0\x86\examples60\console\random + +copy %~dp0\..\examples60\scripts\calc\*.l %~dp0\x86\examples60\scripts\calc +copy %~dp0\..\examples60\scripts\calc\*.es %~dp0\x86\examples60\scripts\calc +copy %~dp0\..\examples60\scripts\calc\*.prj %~dp0\x86\examples60\scripts\calc + +copy %~dp0\..\examples60\scripts\interpreter\*.l %~dp0\x86\examples60\scripts\interpreter +copy %~dp0\..\examples60\scripts\interpreter\*.es %~dp0\x86\examples60\scripts\interpreter +copy %~dp0\..\examples60\scripts\interpreter\*.prj %~dp0\x86\examples60\scripts\interpreter +copy %~dp0\..\examples60\scripts\interpreter\*.txt %~dp0\x86\examples60\scripts\interpreter + +copy %~dp0\..\examples60\scripts\js\*.l %~dp0\x86\examples60\scripts\js +copy %~dp0\..\examples60\scripts\js\*.js %~dp0\x86\examples60\scripts\js +copy %~dp0\..\examples60\scripts\js\*.prj %~dp0\x86\examples60\scripts\js + +copy %~dp0\..\examples60\scripts\ls\*.l %~dp0\x86\examples60\scripts\ls +copy %~dp0\..\examples60\scripts\ls\*.ls %~dp0\x86\examples60\scripts\ls +copy %~dp0\..\examples60\scripts\ls\*.prj %~dp0\x86\examples60\scripts\ls + +copy %~dp0\..\examples60\rosetta\accumulator\*.l %~dp0\x86\examples60\rosetta\accumulator +copy %~dp0\..\examples60\rosetta\ackermann\*.l %~dp0\x86\examples60\rosetta\ackermann +copy %~dp0\..\examples60\rosetta\addfield\*.l %~dp0\x86\examples60\rosetta\addfield +copy %~dp0\..\examples60\rosetta\anonymrec\*.l %~dp0\x86\examples60\rosetta\anonymrec +copy %~dp0\..\examples60\rosetta\aplusb\*.l %~dp0\x86\examples60\rosetta\aplusb +copy %~dp0\..\examples60\rosetta\applycallback\*.l %~dp0\x86\examples60\rosetta\applycallback +copy %~dp0\..\examples60\rosetta\arithmeticint\*.l %~dp0\x86\examples60\rosetta\arithmeticint +copy %~dp0\..\examples60\rosetta\arithmeval\*.l %~dp0\x86\examples60\rosetta\arithmeval +copy %~dp0\..\examples60\rosetta\arithmmean\*.l %~dp0\x86\examples60\rosetta\arithmmean +copy %~dp0\..\examples60\rosetta\arrayconcat\*.l %~dp0\x86\examples60\rosetta\arrayconcat +copy %~dp0\..\examples60\rosetta\arraymode\*.l %~dp0\x86\examples60\rosetta\arraymode +copy %~dp0\..\examples60\rosetta\arrays\*.l %~dp0\x86\examples60\rosetta\arrays + +copy %~dp0\..\examples60\rosetta\associativearrays\*.l %~dp0\x86\examples60\rosetta\associativearrays +copy %~dp0\..\examples60\rosetta\bestshuffle\*.l %~dp0\x86\examples60\rosetta\bestshuffle +copy %~dp0\..\examples60\rosetta\binary\*.l %~dp0\x86\examples60\rosetta\binary +copy %~dp0\..\examples60\rosetta\bitwise\*.l %~dp0\x86\examples60\rosetta\bitwise +copy %~dp0\..\examples60\rosetta\brackets\*.l %~dp0\x86\examples60\rosetta\brackets +copy %~dp0\..\examples60\rosetta\bullscows\*.l %~dp0\x86\examples60\rosetta\bullscows +copy %~dp0\..\examples60\rosetta\caesar\*.l %~dp0\x86\examples60\rosetta\caesar +copy %~dp0\..\examples60\rosetta\calendar\*.l %~dp0\x86\examples60\rosetta\calendar +copy %~dp0\..\examples60\rosetta\charmatch\*.l %~dp0\x86\examples60\rosetta\charmatch +copy %~dp0\..\examples60\rosetta\combinations\*.l %~dp0\x86\examples60\rosetta\combinations +copy %~dp0\..\examples60\rosetta\doors\*.l %~dp0\x86\examples60\rosetta\doors +copy %~dp0\..\examples60\rosetta\evolutionary\*.l %~dp0\x86\examples60\rosetta\evolutionary +copy %~dp0\..\examples60\rosetta\firstclass\*.l %~dp0\x86\examples60\rosetta\firstclass +copy %~dp0\..\examples60\rosetta\loop_multiple_arrays\*.l %~dp0\x86\examples60\rosetta\loop_multiple_arrays +copy %~dp0\..\examples60\rosetta\median\*.l %~dp0\x86\examples60\rosetta\median +copy %~dp0\..\examples60\rosetta\ninetynine\*.l %~dp0\x86\examples60\rosetta\ninetynine +copy %~dp0\..\examples60\rosetta\reverse_words_in_string\*.l %~dp0\x86\examples60\rosetta\reverse_words_in_string +copy %~dp0\..\examples60\rosetta\smavg\*.l %~dp0\x86\examples60\rosetta\smavg +copy %~dp0\..\examples60\rosetta\string_append\*.l %~dp0\x86\examples60\rosetta\string_append +copy %~dp0\..\examples60\rosetta\twentyfour\*.l %~dp0\x86\examples60\rosetta\twentyfour + +copy %~dp0\..\examples60\gui\c_a_g\*.l %~dp0\x86\examples60\gui\c_a_g +copy %~dp0\..\examples60\gui\c_a_g\*.prj %~dp0\x86\examples60\gui\c_a_g + +copy %~dp0\..\examples60\gui\c_a_g\formulas\Circulo\*.bmp %~dp0\x86\examples60\gui\c_a_g\formulas\Circulo +copy %~dp0\..\examples60\gui\c_a_g\formulas\Paralelogramos\*.bmp %~dp0\x86\examples60\gui\c_a_g\formulas\Paralelogramos +copy %~dp0\..\examples60\gui\c_a_g\formulas\Trapezio\*.bmp %~dp0\x86\examples60\gui\c_a_g\formulas\Trapezio +copy %~dp0\..\examples60\gui\c_a_g\formulas\Triangulos\*.bmp %~dp0\x86\examples60\gui\c_a_g\formulas\Triangulos + +copy %~dp0\..\examples60\gui\agenda\*.l %~dp0\x86\examples60\gui\agenda +copy %~dp0\..\examples60\gui\agenda\*.prj %~dp0\x86\examples60\gui\agenda + +copy %~dp0\..\examples60\gui\graphs\*.l %~dp0\x86\examples60\gui\graphs +copy %~dp0\..\examples60\gui\graphs\*.prj %~dp0\x86\examples60\gui\graphs + +copy %~dp0\..\examples60\gui\helloworld\*.l %~dp0\x86\examples60\gui\helloworld +copy %~dp0\..\examples60\gui\helloworld\*.prj %~dp0\x86\examples60\gui\helloworld +copy %~dp0\..\examples60\gui\helloworld\*.xs %~dp0\x86\examples60\gui\helloworld + +copy %~dp0\..\examples60\db\sqlite\*.l %~dp0\x86\examples60\db\sqlite +copy %~dp0\..\examples60\db\sqlite\*.prj %~dp0\x86\examples60\db\sqlite + +copy %~dp0\..\examples60\files\textdb\*.l %~dp0\x86\examples60\files\textdb +copy %~dp0\..\examples60\files\textdb\*.prj %~dp0\x86\examples60\files\textdb +copy %~dp0\..\examples60\files\textdb\*.txt %~dp0\x86\examples60\files\textdb + +copy %~dp0\..\examples60\files\textfile\*.l %~dp0\x86\examples60\files\textfile +copy %~dp0\..\examples60\files\textfile\*.txt %~dp0\x86\examples60\files\textfile + +goto:eof +::ERRORS +::--------------------- +:CompilerError +echo The MSBuild returns error %ERRORLEVEL% +goto:eof diff --git a/install/elena_inno.iss b/build/elena_inno.iss similarity index 88% rename from install/elena_inno.iss rename to build/elena_inno.iss index 29171c46a6..7deb21bea4 100644 --- a/install/elena_inno.iss +++ b/build/elena_inno.iss @@ -7,7 +7,7 @@ ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{3CAA69D3-0F98-44B1-A73E-E864BA51D5BD} AppName=ELENA Programming Language -AppVersion=6.0.0 +AppVersion=6.0.9 ;AppVerName=ELENA Programming Language 5.0.0 AppPublisher=Alexey Rakov AppPublisherURL=http://github.com/ELENA-LANG/elena-lang @@ -18,7 +18,7 @@ DefaultGroupName=ELENA Programming Language AllowNoIcons=yes LicenseFile=..\doc\license InfoAfterFile=..\CHANGELOG.md -OutputBaseFilename=elena-lang-6.0.8.x86-setup +OutputBaseFilename=elena-lang-6.0.9.x86-setup Compression=lzma SolidCompression=yes ChangesEnvironment=yes @@ -32,14 +32,14 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 [Files] -Source: "output32\bin\*"; DestDir: "{app}\bin"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "output32\doc\*"; DestDir: "{app}\doc"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "output32\examples60\*"; DestDir: "{app}\examples60"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "output32\lib60\*"; DestDir: "{app}\lib60"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "x86\bin\*"; DestDir: "{app}\bin"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "x86\doc\*"; DestDir: "{app}\doc"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "x86\examples60\*"; DestDir: "{app}\examples60"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "x86\src60\*"; DestDir: "{app}\src60"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "x86\lib60\*"; DestDir: "{app}\lib60"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\doc\license"; DestDir: "{app}"; Source: "..\readme.md"; DestDir: "{app}"; Flags: isreadme Source: "..\CHANGELOG.md"; DestDir: "{app}"; -Source: "..\rebuild_lib60.bat"; DestDir: "{app}"; Source: "redist\VC_redist.x86.exe"; DestDir: "{app}"; Flags: deleteafterinstall ; NOTE: Don't use "Flags: ignoreversion" on any shared system files diff --git a/install/i386/build_package_i386.script b/build/i386/build_package_i386.script similarity index 96% rename from install/i386/build_package_i386.script rename to build/i386/build_package_i386.script index d933e7fbde..251767181c 100755 --- a/install/i386/build_package_i386.script +++ b/build/i386/build_package_i386.script @@ -1,5 +1,5 @@ #!/bin/bash -RELEASE=elena-6.0.7.i386-linux +RELEASE=elena-6.0.9.i386-linux mkdir -p /usr/share/elena mkdir -p /etc/elena/ @@ -127,6 +127,16 @@ echo compiling lib60 files echo . fi + ../../bin/elena-cli ../../src60/ltests/ltests.project + ret=$? + if [ $ret -eq 2 ] + then + echo "Failure" >&2 + exit 1 + else + echo . + fi + ../../bin/elena-cli ../../tests60/system_tests/system_tests.project ret=$? if [ $ret -eq 2 ] diff --git a/install/i386/control b/build/i386/control similarity index 96% rename from install/i386/control rename to build/i386/control index 0377ed9c54..193babd676 100644 --- a/install/i386/control +++ b/build/i386/control @@ -1,5 +1,5 @@ Package: elena-lang -Version: 6.0.8 +Version: 6.0.9 Architecture: i386 Maintainer: Alex Rakov Depends: libc6 (>= 2.1) diff --git a/install/ppc64le/build_package_ppc64le.script b/build/ppc64le/build_package_ppc64le.script similarity index 96% rename from install/ppc64le/build_package_ppc64le.script rename to build/ppc64le/build_package_ppc64le.script index b9ad091f09..c92ba7560d 100755 --- a/install/ppc64le/build_package_ppc64le.script +++ b/build/ppc64le/build_package_ppc64le.script @@ -1,5 +1,5 @@ #!/bin/bash -RELEASE=elena-6.0.7.ppc64le-linux +RELEASE=elena-6.0.9.ppc64le-linux mkdir -p /usr/share/elena mkdir -p /etc/elena/ @@ -115,6 +115,16 @@ fi echo . fi + ../../bin/elena64-cli ../../src60/ltests/ltests.project + ret=$? + if [ $ret -eq 2 ] + then + echo "Failure" >&2 + exit 1 + else + echo . + fi + ../../bin/elena64-cli ../../tests60/system_tests/system_tests.project ret=$? if [ $ret -eq 2 ] diff --git a/install/ppc64le/control b/build/ppc64le/control similarity index 96% rename from install/ppc64le/control rename to build/ppc64le/control index 3ae595a678..64dcb0917b 100644 --- a/install/ppc64le/control +++ b/build/ppc64le/control @@ -1,5 +1,5 @@ Package: elena-lang -Version: 6.0.8 +Version: 6.0.9 Architecture: ppc64le Maintainer: Alex Rakov Depends: libc6 (>= 2.1) diff --git a/build/rebuild_lib60_x64.bat b/build/rebuild_lib60_x64.bat new file mode 100644 index 0000000000..5135d4883a --- /dev/null +++ b/build/rebuild_lib60_x64.bat @@ -0,0 +1,115 @@ +REM NOTE : the script MUST be called from the root folder + +bin\sg64-cli dat\sg\syntax60.txt +@echo off +if %ERRORLEVEL% EQU -1 GOTO Asm2BinError +@echo on + +move dat\sg\syntax60.dat bin + +bin\og64-cli dat\og\bc_rules60.txt +@echo off +if %ERRORLEVEL% EQU -1 GOTO Asm2BinError +@echo on +move dat\og\bc_rules60.dat bin + +bin\og64-cli -s dat\og\bt_rules60.txt +@echo off +if %ERRORLEVEL% EQU -1 GOTO Asm2BinError +@echo on +move dat\og\bt_rules60.dat bin + +bin\asm64-cli -amd64 asm\amd64\core60.asm bin\amd64 +@echo off +if %ERRORLEVEL% EQU -1 GOTO Asm2BinError +@echo on + +bin\asm64-cli -amd64 asm\amd64\core60_win.asm bin\amd64 +@echo off +if %ERRORLEVEL% EQU -1 GOTO Asm2BinError +@echo on + +bin\asm64-cli -bc64 src60\core\system.core_routines.esm lib60_64 +@echo off +if %ERRORLEVEL% EQU -1 GOTO Asm2BinError +@echo on + +bin\asm64-cli -bc64 src60\core\system.win_core_routines.esm lib60_64 +@echo off +if %ERRORLEVEL% EQU -1 GOTO Asm2BinError +@echo on + +bin\elena64-cli src60\system\system.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +bin\elena64-cli src60\extensions\extensions.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +bin\elena64-cli src60\cellular\cellular.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +bin\elena64-cli src60\algorithms\algorithms.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +bin\elena64-cli src60\ltests\ltests.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +bin\elena64-cli src60\sqlite\sqlite.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +bin\elena64-cli src60\forms\forms.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +bin\elena64-cli tests60\system_tests\system_tests.prj +@echo off +if %ERRORLEVEL% EQU -2 GOTO CompilerError +@echo on + +echo system api test for amd64 +copy bin\elenart60_64.dll tests60\system_tests\ +copy bin\elenasm60_64.dll tests60\system_tests\ + +tests60\system_tests\system_tests64.exe +@echo off +if %ERRORLEVEL% NEQ 0 GOTO TestError +@echo on + +@echo off +echo === Done === +@echo on + +@echo off +goto:eof +@echo on + +:Asm2BinError +echo ASM2BINX returns error %ERRORLEVEL% +@echo off +goto:eof +@echo on + +:CompilerError +echo ELC returns error %ERRORLEVEL% +@echo off +goto:eof +@echo on + +:TestError +echo System tests fail %ERRORLEVEL% +@echo off +goto:eof +@echo on diff --git a/rebuild_lib60.bat b/build/rebuild_lib60_x86.bat similarity index 67% rename from rebuild_lib60.bat rename to build/rebuild_lib60_x86.bat index 731f2a88e8..d0fa165749 100644 --- a/rebuild_lib60.bat +++ b/build/rebuild_lib60_x86.bat @@ -1,4 +1,6 @@ -bin\sg-cli dat\sg\syntax60.txt +REM NOTE : the script MUST be called from the root folder + +.\bin\sg-cli dat\sg\syntax60.txt @echo off if %ERRORLEVEL% EQU -1 GOTO Asm2BinError @echo on @@ -37,16 +39,6 @@ bin\asm-cli -x86 asm\x32\core60_win_client.asm bin\x32 if %ERRORLEVEL% EQU -1 GOTO Asm2BinError @echo on -bin\asm-cli -amd64 asm\amd64\core60.asm bin\amd64 -@echo off -if %ERRORLEVEL% EQU -1 GOTO Asm2BinError -@echo on - -bin\asm-cli -amd64 asm\amd64\core60_win.asm bin\amd64 -@echo off -if %ERRORLEVEL% EQU -1 GOTO Asm2BinError -@echo on - bin\asm-cli -bc32 src60\core\system.core_routines.esm lib60 @echo off if %ERRORLEVEL% EQU -1 GOTO Asm2BinError @@ -77,57 +69,22 @@ bin\elena-cli src60\algorithms\algorithms.prj if %ERRORLEVEL% EQU -2 GOTO CompilerError @echo on -bin\elena-cli src60\sqlite\sqlite.prj -@echo off -if %ERRORLEVEL% EQU -2 GOTO CompilerError -@echo on - -bin\elena-cli src60\forms\forms.prj -@echo off -if %ERRORLEVEL% EQU -2 GOTO CompilerError -@echo on - -bin\elena-cli src60\xforms\xforms.prj -@echo off -if %ERRORLEVEL% EQU -2 GOTO CompilerError -@echo on - -bin\asm-cli -bc64 src60\core\system.core_routines.esm lib60_64 -@echo off -if %ERRORLEVEL% EQU -1 GOTO Asm2BinError -@echo on - -bin\asm-cli -bc64 src60\core\system.win_core_routines.esm lib60_64 -@echo off -if %ERRORLEVEL% EQU -1 GOTO Asm2BinError -@echo on - -bin\elena64-cli src60\system\system.prj -@echo off -if %ERRORLEVEL% EQU -2 GOTO CompilerError -@echo on - -bin\elena64-cli src60\extensions\extensions.prj -@echo off -if %ERRORLEVEL% EQU -2 GOTO CompilerError -@echo on - -bin\elena64-cli src60\cellular\cellular.prj +bin\elena-cli src60\ltests\ltests.prj @echo off if %ERRORLEVEL% EQU -2 GOTO CompilerError @echo on -bin\elena64-cli src60\algorithms\algorithms.prj +bin\elena-cli src60\sqlite\sqlite.prj @echo off if %ERRORLEVEL% EQU -2 GOTO CompilerError @echo on -bin\elena64-cli src60\sqlite\sqlite.prj +bin\elena-cli src60\forms\forms.prj @echo off if %ERRORLEVEL% EQU -2 GOTO CompilerError @echo on -bin\elena64-cli src60\forms\forms.prj +bin\elena-cli src60\xforms\xforms.prj @echo off if %ERRORLEVEL% EQU -2 GOTO CompilerError @echo on @@ -151,19 +108,11 @@ bin\elena-cli tests60\system_tests\system_tests.prj if %ERRORLEVEL% EQU -2 GOTO CompilerError @echo on -bin\elena64-cli tests60\system_tests\system_tests.prj -@echo off -if %ERRORLEVEL% EQU -2 GOTO CompilerError -@echo on - echo system api test for x86 -tests60\system_tests\system_tests.exe -@echo off -if %ERRORLEVEL% NEQ 0 GOTO TestError -@echo on +copy bin\elenart60.dll tests60\system_tests\ +copy bin\elenasm60.dll tests60\system_tests\ -echo system api test for amd64 -tests60\system_tests\system_tests64.exe +tests60\system_tests\system_tests.exe @echo off if %ERRORLEVEL% NEQ 0 GOTO TestError @echo on diff --git a/dat/api2html/api2html.bat b/dat/api2html/api2html.bat index 4e83da357a..9291b1bb94 100644 --- a/dat/api2html/api2html.bat +++ b/dat/api2html/api2html.bat @@ -1,10 +1,12 @@ ..\..\bin\ldoc system ..\..\bin\ldoc system'routines ..\..\bin\ldoc system'runtime +..\..\bin\ldoc system'runtime'stex ..\..\bin\ldoc system'threading ..\..\bin\ldoc system'dynamic ..\..\bin\ldoc system'drawing ..\..\bin\ldoc system'winforms +..\..\bin\ldoc system'net ..\..\bin\ldoc extensions ..\..\bin\ldoc extensions'routines ..\..\bin\ldoc extensions'scripting @@ -13,5 +15,7 @@ ..\..\bin\ldoc algorithms ..\..\bin\ldoc sqlite ..\..\bin\ldoc forms +..\..\bin\ldoc ltests +..\..\bin\ldoc net copy *.html ..\..\doc\api diff --git a/dat/sg/syntax60.txt b/dat/sg/syntax60.txt index 103a1df6d5..1779e71568 100644 --- a/dat/sg/syntax60.txt +++ b/dat/sg/syntax60.txt @@ -24,6 +24,7 @@ __define META_STATEMENT 4129; __define INCLUDE_STATEMENT 4130; __define LOAD_STATEMENT 4131; __define CLEAR_STATEMENT 4132; +__define SHARED_DICTIONARY 4133; __define OBJECT 4145; __define TEMPLATE_TYPE 4146; __define ARRAY_TYPE 4147; @@ -127,6 +128,7 @@ START ::= META_DECLARATION ::= "#new" DICTIONARY DECLARATION_END + | "#share" SHARED_DICTIONARY DECLARATION_END | "#let" META_STATEMENT DECLARATION_END | "#load" LOAD_STATEMENT DECLARATION_END | "#clear" CLEAR_STATEMENT DECLARATION_END; @@ -190,6 +192,7 @@ STATEMENT ::= | "#include" INCLUDE_STATEMENT | "#let" META_STATEMENT | "#new" DICTIONARY + | "#share" SHARED_DICTIONARY | "{" BLOCK; NEXT_STATEMENT ::= @@ -1113,6 +1116,9 @@ DIMENSION ::= DICTIONARY ::= identifier+; +SHARED_DICTIONARY ::= + identifier+; + LOAD_STATEMENT ::= { reference | identifier }; @@ -1147,7 +1153,7 @@ POSTFIXES ::= POSTFIX ::= identifier { - "(" MESSAGE_PARAMETER { "," MESSAGE_PARAMETER }* ")" ^ INLINE + "(" { MESSAGE_PARAMETER { "," MESSAGE_PARAMETER }* }? ")" ^ INLINE | TEMPLATE_BRACKETS ^ TEMPLATE_TYPE | eps }; diff --git a/doc/api/algorithms-summary.html b/doc/api/algorithms-summary.html new file mode 100644 index 0000000000..ff7e8acc55 --- /dev/null +++ b/doc/api/algorithms-summary.html @@ -0,0 +1,112 @@ + + + + +ELENA Standard Library 6.0: Module algorithms + + + + + +
+ +
+ +ELENA Standard Library
6.0 +
+
+
+
+

+Module algorithms +

+
+
+
+
+
+
    +
  • + +
    +Class Summary +
    + + + + + + + + +
    Class nameDescription
    +QuickSortAlgorithm + +
    +public singleton QuickSortAlgorithm
    +
    +
  • +
  • + +
    +Extended Class Summary +
    + + + + + + + + + + + + + + + + +
    Symbol nameDescription
    +ArrayList + +
    +public class ArrayList
    +
    +Indexable + +
    +public class Indexable
    +
    +Object + +
    +public class Object
    +
    +
  • +
+
+
+ +
+ +ELENA Standard Library
6.0 +
+
+
+ + diff --git a/doc/api/algorithms.html b/doc/api/algorithms.html new file mode 100644 index 0000000000..a6d4b7c110 --- /dev/null +++ b/doc/api/algorithms.html @@ -0,0 +1,235 @@ + + + + +ELENA Standard Library 6.0: Module algorithms + + + + + +
+ +
+ +ELENA Standard Library
6.0 +
+
+
+ + + +
+
+algorithms'
+

QuickSortAlgorithm

+
+
+
+
+
+
+public singleton QuickSortAlgorithm
+
+
+ + + +
+
+ + + +
+
+system'collections'
+

ArrayList

+
+
+
+
+
+
+public class ArrayList
+
+
+ +
    +
  • +

    Extension Summary

    + + + + + + + + + + + + + +
    Modifier and TypeExtension Method
    + + +quickSort(Func2 compf) + +
    + + +quickSort() + +
    +
  • +
+
+
+ + + +
+
+system'
+

Indexable

+
+
+
+
+
+
+public class Indexable
+
+
+ +
    +
  • +

    Extension Summary

    + + + + + + + + + + + + + +
    Modifier and TypeExtension Method
    + + +quickSort(IntNumber length, Func2 compf) + +
    + + +quickSort(IntNumber length) + +
    +
  • +
+
+
+ + + +
+
+system'
+

Object

+
+
+
+
+
+
+public class Object
+
+
+ +
    +
  • +

    Extension Summary

    + + + + + + + + + + + + + +
    Modifier and TypeExtension Method
    + + +quickSort(Func2 compf) + +
    + + +quickSort() + +
    +
  • +
+
+
+
+ +
+ +ELENA Standard Library
6.0 +
+
+
+ + diff --git a/doc/api/cellular.html b/doc/api/cellular.html index 8ee7c48973..e4360dbaf4 100644 --- a/doc/api/cellular.html +++ b/doc/api/cellular.html @@ -45,7 +45,7 @@

IntMatrixSpace