-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(hsp3) | ||
|
||
# ソースファイルの設定 | ||
set(SOURCES | ||
hsp3.cpp | ||
hsp3code.cpp | ||
hsp3debug.cpp | ||
hsp3int.cpp | ||
hspvar_core.cpp | ||
hspvar_double.cpp | ||
hspvar_int.cpp | ||
hsp3crypt.cpp | ||
hsp3utfcnv.cpp | ||
filepack.cpp | ||
hspvar_label.cpp | ||
hspvar_str.cpp | ||
hspvar_struct.cpp | ||
stack.cpp | ||
strbuf.cpp | ||
strnote.cpp | ||
dpmread.cpp | ||
linux/main.cpp | ||
linux/supio_linux.cpp | ||
linux/hsp3cl.cpp | ||
linux/hsp3ext_linux.cpp | ||
linux/hsp3gr_linux.cpp | ||
linux/hsp3ext_sock.cpp | ||
) | ||
|
||
# 実行ファイルの生成 | ||
add_executable(hsp3 ${SOURCES}) | ||
|
||
# コンパイル定義の設定 | ||
target_compile_definitions(hsp3 PRIVATE HSPLINUX $<$<CONFIG:Debug>:HSPDEBUG>) | ||
target_compile_options(hsp3 PRIVATE -UDEVCTRL_IO) | ||
|
||
# コンパイルオプションの設定 | ||
#target_compile_options(hsp3 PRIVATE -Wall --input-charset=utf-8 --exec-charset=cp932) | ||
|
||
# リンクオプションの設定(リリースビルドで-stripオプションを追加) | ||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13") | ||
target_link_options(hsp3 PRIVATE $<$<CONFIG:Release>:-s>) | ||
else() | ||
set_target_properties(hsp3 PROPERTIES LINK_FLAGS "$<$<CONFIG:Release>:-s>") | ||
endif() | ||
|
||
# リンクライブラリの設定 | ||
target_link_libraries(hsp3 m stdc++) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
; 64-bit 'CallFunc' | ||
; | ||
; LICENCE: Public domain | ||
|
||
OPTION CASEMAP: NONE | ||
|
||
PUBLIC CallFunc64 | ||
|
||
.CODE | ||
|
||
; [CallFunc64] | ||
; | ||
; The 'CallFunc64' function calls the sppecified function with the specified array as arguments. | ||
; | ||
; [Syntax] | ||
; | ||
; INT_PTR CallFunc64(INT_PTR const *arguments, FARPROC external_function, int number_Of_arguments); | ||
; INT32 CallFunc64(INT_PTR const *arguments, FARPROC external_function, int number_Of_arguments); | ||
; double CallFunc64(INT_PTR const *arguments, FARPROC external_function, int number_of_arguments); | ||
; | ||
; [Parameters] | ||
; | ||
; INT_PTR const *arguments [in, optional] | ||
; Points to the array used as arguments to the function of 'externalFunction'. If 'numberOfArguments' is set to a negative value or zero, the function makes no use of the parameter. | ||
; | ||
; FARPROC external_function [in] | ||
; Points to the function to call with the array of 'arguments' as arguments. | ||
; | ||
; int number_of_arguments [in] | ||
; Represents the number of elements in the array of 'arguments'. | ||
; | ||
; [Return value] | ||
; | ||
; The return value is directly from the function of 'externalFunction'. | ||
; | ||
; [Remarks] | ||
; | ||
; If 'numberOfParameters' is set to a negative value, the behavior is the same as when the parameter is set to zero; the function of 'externalFunction' is then assumed not to receive any parameter. | ||
; The behavior is undefined if the array of 'arguments' is not proper as arguments for the function of 'externalFunction'. | ||
|
||
CallFunc64 PROC FRAME | ||
|
||
mov rax, rdx ; Save the value of 'external_function' to rax | ||
|
||
; Directly go to the function of 'external_function' if it does not receive any parameter | ||
|
||
mov edx, r8d | ||
test edx, edx | ||
jg short @has_args | ||
|
||
jmp rax | ||
|
||
@has_args: | ||
|
||
push rbp | ||
.PUSHREG rbp | ||
|
||
mov rbp, rsp | ||
.SETFRAME rbp, 0 | ||
|
||
.ENDPROLOG | ||
|
||
sal edx, 3 ; edx = number_of_arguments * sizeof(INT_PTR) | ||
|
||
; Align the stack to 16 bytes and allocate at least 32 bytes | ||
|
||
sub edx, 8 * 4 | ||
@if00: | ||
jge short @else00 | ||
|
||
neg edx | ||
jmp short @end_if00 | ||
|
||
@else00: | ||
|
||
and edx, 8 | ||
|
||
@end_if00: | ||
|
||
sub rsp, rdx | ||
|
||
; Prepare arguments | ||
|
||
@do00: | ||
|
||
dec r8d | ||
push qword ptr [rcx + r8 * 8] | ||
|
||
jg @do00 | ||
|
||
@until00: | ||
|
||
pop rcx | ||
pop rdx | ||
pop r8 | ||
pop r9 | ||
|
||
movd xmm0, rcx | ||
movd xmm1, rdx | ||
movd xmm2, r8 | ||
movd xmm3, r9 | ||
|
||
; cmp rsp, rbp | ||
|
||
; Call the function of 'external_function' | ||
|
||
sub rsp, 8 * 4 | ||
call rax | ||
|
||
leave | ||
ret | ||
|
||
CallFunc64 ENDP | ||
|
||
END |