Put common x86 platform logic in a shared folder to reduce duplicate code
This commit is contained in:
parent
49c8b5b87d
commit
4916fb9385
|
@ -3,9 +3,9 @@ set -ex
|
|||
# Build the test
|
||||
bin/M2-Planet test/test0/cc500.c test/test0/cc0.M1 || exit 1
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/test0/x86_defs.M1 -f test/test0/libc.M1 -f test/test0/cc0.M1 --LittleEndian --Architecture 1 -o test/test0/cc0.hex2 || exit 2
|
||||
M1 -f test/common_x86/x86_defs.M1 -f test/common_x86/libc.M1 -f test/test0/cc0.M1 --LittleEndian --Architecture 1 -o test/test0/cc0.hex2 || exit 2
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test0/ELF-i386.hex2 -f test/test0/cc0.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test0-binary --exec_enable || exit 3
|
||||
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test0/cc0.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test0-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine)" = "x86_64" ]
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
### This file is part of stage0.
|
||||
###
|
||||
### stage0 is free software: you an 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.
|
||||
###
|
||||
### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
### elf32.hex2: 32 bit elf header in hex2
|
||||
|
||||
## ELF Header
|
||||
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||
|
||||
01 # e_ident[EI_CLASS] Indicating 32 bit
|
||||
01 # e_ident[EI_DATA] Indicating little endianness
|
||||
01 # e_ident[EI_VERSION] Indicating original elf
|
||||
|
||||
00 # e_ident[EI_OSABI] Set at 0 because none cares
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
02 00 # e_type Indicating Executable
|
||||
03 00 # e_machine Indicating 32bit x86
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
54 80 04 08 # e_entry Address of the entry point
|
||||
34 00 00 00 # e_phoff Address of program header table
|
||||
00 00 00 00 # e_shoff Address of section header table
|
||||
|
||||
00 00 00 00 # e_flags
|
||||
34 00 # e_ehsize Indicating our 52 Byte header
|
||||
|
||||
20 00 # e_phentsize size of a program header table
|
||||
01 00 # e_phnum number of entries in program table
|
||||
|
||||
00 00 # e_shentsize size of a section header table
|
||||
00 00 # e_shnum number of entries in section table
|
||||
|
||||
00 00 # e_shstrndx index of the section names
|
||||
|
||||
## Program Header
|
||||
01 00 00 00 # p_type
|
||||
00 00 00 00 # p_offset
|
||||
|
||||
00 80 04 08 # p_vaddr
|
||||
00 80 04 08 # p_physaddr
|
||||
|
||||
2A 36 00 00 # p_filesz
|
||||
2A 36 00 00 # p_memsz
|
||||
|
||||
07 00 00 00 # p_flags
|
||||
01 00 00 00 # alignmen
|
|
@ -3,9 +3,9 @@ set -ex
|
|||
# Build the test
|
||||
bin/M2-Planet test/test1/for.c test/test1/for.M1 || exit 1
|
||||
# Macro assemble with libc written in M1-Macro
|
||||
M1 -f test/test1/x86_defs.M1 -f test/test1/libc.M1 -f test/test1/for.M1 --LittleEndian --Architecture 1 -o test/test1/for.hex2 || exit 2
|
||||
M1 -f test/common_x86/x86_defs.M1 -f test/common_x86/libc.M1 -f test/test1/for.M1 --LittleEndian --Architecture 1 -o test/test1/for.hex2 || exit 2
|
||||
# Resolve all linkages
|
||||
hex2 -f test/test1/ELF-i386.hex2 -f test/test1/for.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test1-binary --exec_enable || exit 3
|
||||
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test1/for.hex2 --LittleEndian --Architecture 1 --BaseAddress 0x8048000 -o test/results/test1-binary --exec_enable || exit 3
|
||||
|
||||
# Ensure binary works if host machine supports test
|
||||
if [ "$(get_machine)" = "x86_64" ]
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
## Copyright (C) 2016 Jeremiah Orians
|
||||
## This file is part of stage0.
|
||||
##
|
||||
## stage0 is free software: you an 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.
|
||||
##
|
||||
## stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
:_start
|
||||
CALL_IMMEDIATE %FUNCTION_main
|
||||
COPY_eax_to_ebx
|
||||
LOAD_IMMEDIATE_eax %1
|
||||
INT_80
|
||||
|
||||
:FUNCTION_exit
|
||||
POP_ebx
|
||||
POP_ebx
|
||||
LOAD_IMMEDIATE_eax %1
|
||||
INT_80
|
||||
|
||||
:FUNCTION_getchar
|
||||
LOAD_IMMEDIATE_eax %3
|
||||
LOAD_IMMEDIATE_ebx %0
|
||||
PUSH_ebx
|
||||
COPY_esp_to_ecx
|
||||
LOAD_IMMEDIATE_edx %1
|
||||
INT_80
|
||||
TEST
|
||||
POP_eax
|
||||
JUMP_NE8 !FUNCTION_getchar_Done
|
||||
LOAD_IMMEDIATE_eax %-1
|
||||
:FUNCTION_getchar_Done
|
||||
RETURN
|
||||
|
||||
:FUNCTION_malloc
|
||||
STORE_eax_into_ESP_IMMEDIATE8 !4
|
||||
PUSH_eax
|
||||
LOAD_IMMEDIATE_eax %45
|
||||
LOAD_IMMEDIATE_ebx %0
|
||||
INT_80
|
||||
POP_ebx
|
||||
ADD_eax_to_ebx
|
||||
PUSH_eax
|
||||
PUSH_ebx
|
||||
LOAD_IMMEDIATE_eax %45
|
||||
INT_80
|
||||
POP_ebx
|
||||
CMP
|
||||
POP_eax
|
||||
JUMP_EQ8 !FUNCTION_malloc_Done
|
||||
LOAD_IMMEDIATE_eax %-1
|
||||
:FUNCTION_malloc_Done
|
||||
RETURN
|
||||
|
||||
:FUNCTION_putchar
|
||||
LOAD_IMMEDIATE_eax %4
|
||||
LOAD_IMMEDIATE_ebx %1
|
||||
LOAD_EFFECTIVE_ADDRESS_ecx !4
|
||||
COPY_ebx_to_edx
|
||||
INT_80
|
||||
RETURN
|
|
@ -1,64 +0,0 @@
|
|||
## Copyright (C) 2016 Jeremiah Orians
|
||||
## This file is part of stage0.
|
||||
##
|
||||
## stage0 is free software: you an 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.
|
||||
##
|
||||
## stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
DEFINE ADD_ebx_to_eax 01D8
|
||||
DEFINE ADD_eax_to_ebx 01C3
|
||||
DEFINE AND_eax_ebx 21D8
|
||||
DEFINE CALL_IMMEDIATE E8
|
||||
DEFINE CALL_eax FFD0
|
||||
DEFINE CALL_IMMEDIATE E8
|
||||
DEFINE CMP 39C3
|
||||
DEFINE COPY_eax_to_ebx 89C3
|
||||
DEFINE COPY_eax_to_ecx 89C1
|
||||
DEFINE COPY_ebx_to_edx 89DA
|
||||
DEFINE COPY_esp_to_ecx 89E1
|
||||
DEFINE INT_80 CD80
|
||||
DEFINE JUMP E9
|
||||
DEFINE JUMP_EQ 0F84
|
||||
DEFINE JUMP_EQ8 74
|
||||
DEFINE JUMP_NE8 75
|
||||
DEFINE LOAD_BYTE 0FBE00
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS 8D8424
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_ecx 8D4C24
|
||||
DEFINE LOAD_ESP_IMMEDIATE_into_eax 8B8424
|
||||
DEFINE LOAD_IMMEDIATE_eax B8
|
||||
DEFINE LOAD_IMMEDIATE_ebx BB
|
||||
DEFINE LOAD_IMMEDIATE_edx BA
|
||||
DEFINE LOAD_INTEGER 8B00
|
||||
DEFINE MOVEZBL 0FB6C0
|
||||
DEFINE MOVE_ebx_to_eax 89D8
|
||||
DEFINE NOP 00000000
|
||||
DEFINE OR_eax_ebx 09D8
|
||||
DEFINE POP_eax 58
|
||||
DEFINE POP_ebx 5B
|
||||
DEFINE PUSH_eax 50
|
||||
DEFINE PUSH_ebx 53
|
||||
DEFINE RETURN C3
|
||||
DEFINE SAL_eax_Immediate8 C1E0
|
||||
DEFINE SAL_eax_cl D3E0
|
||||
DEFINE SAR_eax_cl D3F8
|
||||
DEFINE SETE 0F94C0
|
||||
DEFINE SETLE 0F9EC0
|
||||
DEFINE SETL 0F9CC0
|
||||
DEFINE SETGE 0F9DC0
|
||||
DEFINE SETG 0F9FC0
|
||||
DEFINE SETNE 0F95C0
|
||||
DEFINE STORE_CHAR 8803
|
||||
DEFINE STORE_eax_into_ESP_IMMEDIATE8 8B4424
|
||||
DEFINE STORE_INTEGER 8903
|
||||
DEFINE SUBTRACT_eax_from_ebx_into_ebx 29C3
|
||||
DEFINE MOVE_ebx_to_eax 89D8
|
||||
DEFINE TEST 85C0
|
Loading…
Reference in New Issue