x86_64: build: Cater for M2-Planet.
* build-aux/cflags.sh: Set cc_cpu.
* build-aux/config.sh.in (cc_cpu): Export.
* build-aux/export.make (cc_cpu): Likewise.
* kaem.arm (cc_cpu): New variable.
* kaem.x86 (cc_cpu): New variable.
* kaem.run (cc_cpu): New variable. Define __<cc_cpu>__.
* scaffold/argv.kaem (cc_cpu): Likewise. Define __linux__
* scaffold/global-array.kaem (cc_cpu): Likewise.
* scaffold/hello.kaem (cc_cpu): Likewise.
* scaffold/local-array.kaem (cc_cpu): Likewise.
* scaffold/local-static-array.kaem (cc_cpu): Likewise.
* scaffold/main.kaem (cc_cpu): Likewise.
* scaffold/read.kaem (cc_cpu): Likewise.
* kaem.x86_64: New file.
lib/m2/x86_64/ELF-x86_64.hex2,
lib/m2/x86_64/x86_64_defs.M1: New files, imported from M2Libc.
lib/linux/x86_64-mes-m2/_exit.c,
lib/linux/x86_64-mes-m2/_write.c,
lib/linux/x86_64-mes-m2/crt1.M1,
lib/linux/x86_64-mes-m2/crt1.c,
lib/linux/x86_64-mes-m2/syscall.c: New files, adapted for M2-Planet
calling convention from ...
* lib/linux/x86_64-mes-mescc: ... here.
* build-aux/build.sh.in: Also allow kaem build for x86_64.
* include/mes/lib-mini.h[__M2__]: Define as sizeof (void*).
* include/mes/mes.h[__M2__](M2_CELL_SIZE): Define as sizeof (struct scm).
* lib/x86_64-mes/x86_64.M1 (add____$i8,%rbp, mov____%rdi,%rbp): New
defines.
* src/posix.c (TIME_UNITS_PER_SECOND): Cater for 64bit M2-Planet.
2022-11-17 21:48:28 +00:00
|
|
|
## Copyright (C) 2017 Jeremiah Orians
|
|
|
|
## This file is part of M2-Planet.
|
|
|
|
##
|
|
|
|
## M2-Planet is free software: you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation, either version 3 of the License, or
|
|
|
|
## (at your option) any later version.
|
|
|
|
##
|
|
|
|
## M2-Planet is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE ADD_IMMEDIATE_to_rax 4805
|
|
|
|
DEFINE ADD_IMMEDIATE_to_rbp 4881C5
|
|
|
|
DEFINE ADD_rax_to_rbx 4801C3
|
|
|
|
DEFINE ADD_rbp_to_rax 4801E8
|
|
|
|
DEFINE ADD_rbx_to_rax 4801D8
|
|
|
|
DEFINE AND_rax_rbx 4821D8
|
|
|
|
DEFINE CALL_IMMEDIATE E8
|
|
|
|
DEFINE CALL_rax FFD0
|
|
|
|
DEFINE CMP 4839C3
|
|
|
|
DEFINE COPY_rax_to_rcx 4889C1
|
|
|
|
DEFINE COPY_rax_to_rdi 4889C7
|
|
|
|
DEFINE COPY_rbx_to_rax 4889D8
|
|
|
|
DEFINE COPY_rbp_to_rax 4889E8
|
|
|
|
DEFINE COPY_rbx_to_rdi 4889DF
|
|
|
|
DEFINE COPY_rdi_to_rbp 4889FD
|
|
|
|
DEFINE COPY_rsp_to_rbp 4889E5
|
|
|
|
DEFINE COPY_RSP_to_RDI 4889E7
|
|
|
|
DEFINE CQTO 4899
|
|
|
|
DEFINE DIVIDE_rax_by_rbx_into_rax 48F7F3
|
|
|
|
DEFINE DIVIDES_rax_by_rbx_into_rax 48F7FB
|
|
|
|
DEFINE JUMP E9
|
|
|
|
DEFINE JUMP_EQ 0F84
|
|
|
|
DEFINE JUMP_NE 0F85
|
|
|
|
DEFINE LOAD_BASE_ADDRESS_rax 488D85
|
|
|
|
DEFINE LOAD_BYTE 480FBE00
|
|
|
|
DEFINE LOAD_BYTE_rbx 480FBE1B
|
|
|
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rax 488D8424
|
|
|
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rdi 488DBC24
|
|
|
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rdx 488D9424
|
|
|
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rsi 488DB424
|
|
|
|
DEFINE LOAD_IMMEDIATE_r10 48C7C2
|
|
|
|
DEFINE LOAD_IMMEDIATE_rax 48C7C0
|
|
|
|
DEFINE LOAD_IMMEDIATE_rbx 48C7C3
|
|
|
|
DEFINE LOAD_IMMEDIATE_rdi 48C7C7
|
|
|
|
DEFINE LOAD_IMMEDIATE_rdx 48C7C2
|
|
|
|
DEFINE LOAD_IMMEDIATE_rsi 48C7C6
|
|
|
|
DEFINE LOAD_INTEGER 488B00
|
|
|
|
DEFINE LOAD_INTEGER_rbx 488B1B
|
|
|
|
DEFINE LOAD_INTEGER_rdi 488B3F
|
|
|
|
DEFINE LOAD_INTEGER_rdx 488B12
|
|
|
|
DEFINE LOAD_INTEGER_rsi 488B36
|
|
|
|
DEFINE LOAD_RSP_IMMEDIATE_into_rax 488B8424
|
|
|
|
DEFINE MODULUS_rax_from_rbx_into_rbx 48F7F3
|
|
|
|
DEFINE MODULUSS_rax_from_rbx_into_rbx 48F7FB
|
|
|
|
DEFINE MOVE_rbx_to_rax 4889D8
|
|
|
|
DEFINE MOVE_rdx_to_rax 4889D0
|
|
|
|
DEFINE MOVEZX 480FB6C0
|
|
|
|
DEFINE MOVESX 4863C0
|
|
|
|
DEFINE MULTIPLY_rax_by_rbx_into_rax 48F7EB
|
|
|
|
DEFINE MULTIPLYS_rax_by_rbx_into_rax 48F7E3
|
|
|
|
DEFINE NULL 0000000000000000
|
|
|
|
DEFINE NOT_rax 48F7D0
|
|
|
|
DEFINE OR_rax_rbx 4809D8
|
|
|
|
DEFINE POP_RAX 58
|
|
|
|
DEFINE POP_RBP 5D
|
|
|
|
DEFINE POP_RBX 5B
|
|
|
|
DEFINE POP_RDI 5F
|
|
|
|
DEFINE PUSH_RAX 50
|
|
|
|
DEFINE PUSH_RBP 55
|
|
|
|
DEFINE PUSH_RBX 53
|
|
|
|
DEFINE PUSH_RDI 57
|
|
|
|
DEFINE RETURN C3
|
|
|
|
DEFINE SAL_rax_Immediate8 48C1E0
|
|
|
|
DEFINE SHL_rax_cl 48D3E0
|
|
|
|
DEFINE SAL_rax_cl 48D3F0
|
|
|
|
DEFINE SHR_rax_cl 48D3E8
|
|
|
|
DEFINE SAR_rax_cl 48D3F8
|
|
|
|
DEFINE SETA 0F97C0
|
|
|
|
DEFINE SETAE 0F93C0
|
|
|
|
DEFINE SETB 0F92C0
|
|
|
|
DEFINE SETBE 0F96C0
|
|
|
|
DEFINE SETE 0F94C0
|
|
|
|
DEFINE SETG 0F9FC0
|
|
|
|
DEFINE SETGE 0F9DC0
|
|
|
|
DEFINE SETL 0F9CC0
|
|
|
|
DEFINE SETLE 0F9EC0
|
|
|
|
DEFINE SETNE 0F95C0
|
|
|
|
DEFINE STORE_CHAR 8803
|
|
|
|
DEFINE STORE_INTEGER 488903
|
|
|
|
DEFINE SUBTRACT_rax_from_rbx_into_rbx 4829C3
|
|
|
|
DEFINE SYSCALL 0F05
|
|
|
|
DEFINE TEST 4885C0
|
|
|
|
DEFINE XCHG_rax_rbx 4893
|
|
|
|
DEFINE XOR_rbx_rax_into_rax 4831D8
|
2023-04-30 12:27:35 +00:00
|
|
|
|
|
|
|
DEFINE add_rax, 4805
|
|
|
|
DEFINE add_rbp, 4881C5
|
|
|
|
DEFINE add_rax,rbx 4801D8
|
|
|
|
DEFINE add_rax,rbp 4801E8
|
|
|
|
DEFINE add_rbx,rax 4801C3
|
|
|
|
DEFINE and_rax,rbx 4821D8
|
|
|
|
DEFINE call E8
|
|
|
|
DEFINE call_rax FFD0
|
|
|
|
DEFINE cmp_rbx,rax 4839C3
|
|
|
|
DEFINE cqo 4899
|
|
|
|
DEFINE div_rbx 48F7F3
|
|
|
|
DEFINE idiv_rbx 48F7FB
|
|
|
|
DEFINE jmp E9
|
|
|
|
DEFINE je 0F84
|
|
|
|
DEFINE jne 0F85
|
|
|
|
DEFINE lea_rax,[rbp+DWORD] 488D85
|
|
|
|
DEFINE lea_rax,[rip+DWORD] 488D05
|
|
|
|
DEFINE lea_rax,[rsp+DWORD] 488D8424
|
|
|
|
DEFINE lea_rdi,[rsp+DWORD] 488DBC24
|
|
|
|
DEFINE lea_rdx,[rsp+DWORD] 488D9424
|
|
|
|
DEFINE lea_rsi,[rsp+DWORD] 488DB424
|
|
|
|
DEFINE mov_rax, 48C7C0
|
|
|
|
DEFINE mov_rbx, 48C7C3
|
|
|
|
DEFINE mov_rdi, 48C7C7
|
|
|
|
DEFINE mov_rdx, 48C7C2
|
|
|
|
DEFINE mov_rsi, 48C7C6
|
|
|
|
DEFINE mov_r10, 49C7C2
|
|
|
|
DEFINE mov_rax,rdx 4889D0
|
|
|
|
DEFINE mov_rax,rbx 4889D8
|
|
|
|
DEFINE mov_rax,rbp 4889E8
|
|
|
|
DEFINE mov_rbp,rdi 4889FD
|
|
|
|
DEFINE mov_rbp,rsp 4889E5
|
|
|
|
DEFINE mov_rcx,rax 4889C1
|
|
|
|
DEFINE mov_rdi,rax 4889C7
|
|
|
|
DEFINE mov_rdi,rbx 4889DF
|
|
|
|
DEFINE mov_rdi,rsp 4889E7
|
|
|
|
DEFINE mov_[rbx],al 8803
|
|
|
|
DEFINE mov_[rbx],rax 488903
|
|
|
|
DEFINE mov_rax,[rax] 488B00
|
|
|
|
DEFINE mov_rbx,[rbx] 488B1B
|
|
|
|
DEFINE mov_rdi,[rdi] 488B3F
|
|
|
|
DEFINE mov_rdx,[rdx] 488B12
|
|
|
|
DEFINE mov_rsi,[rsi] 488B36
|
|
|
|
DEFINE mov_rax,[rsp+DWORD] 488B8424
|
|
|
|
DEFINE movzx_rax,al 480FB6C0
|
|
|
|
DEFINE movsxd_rax,eax 4863C0
|
|
|
|
DEFINE movsx_rax,BYTE_PTR_[rax] 480FBE00
|
|
|
|
DEFINE movsx_rbx,BYTE_PTR_[rbx] 480FBE1B
|
|
|
|
DEFINE imul_rbx 48F7EB
|
|
|
|
DEFINE mul_rbx 48F7E3
|
|
|
|
DEFINE NULL 0000000000000000
|
|
|
|
DEFINE not_rax 48F7D0
|
|
|
|
DEFINE or_rax,rbx 4809D8
|
|
|
|
DEFINE pop_rax 58
|
|
|
|
DEFINE pop_rbp 5D
|
|
|
|
DEFINE pop_rbx 5B
|
|
|
|
DEFINE pop_rdi 5F
|
|
|
|
DEFINE push_rax 50
|
|
|
|
DEFINE push_rbp 55
|
|
|
|
DEFINE push_rbx 53
|
|
|
|
DEFINE push_rdi 57
|
|
|
|
DEFINE ret C3
|
|
|
|
DEFINE sal_rax, 48C1E0
|
|
|
|
DEFINE shl_rax,cl 48D3E0
|
|
|
|
DEFINE sal_rax,cl 48D3F0
|
|
|
|
DEFINE shr_rax,cl 48D3E8
|
|
|
|
DEFINE sar_rax,cl 48D3F8
|
|
|
|
DEFINE seta_al 0F97C0
|
|
|
|
DEFINE setae_al 0F93C0
|
|
|
|
DEFINE setb_al 0F92C0
|
|
|
|
DEFINE setbe_al 0F96C0
|
|
|
|
DEFINE sete_al 0F94C0
|
|
|
|
DEFINE setg_al 0F9FC0
|
|
|
|
DEFINE setge_al 0F9DC0
|
|
|
|
DEFINE setl_al 0F9CC0
|
|
|
|
DEFINE setle_al 0F9EC0
|
|
|
|
DEFINE setne_al 0F95C0
|
|
|
|
DEFINE sub_rbx,rax 4829C3
|
|
|
|
DEFINE syscall 0F05
|
|
|
|
DEFINE test_rax,rax 4885C0
|
|
|
|
DEFINE xchg_rbx,rax 4893
|
|
|
|
DEFINE xor_rax,rbx 4831D8
|