ELF-arm.hex2
This commit is contained in:
parent
4ec0b8787c
commit
f1f32e6376
|
@ -0,0 +1,74 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
### 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/>.
|
||||
|
||||
### stage0's hex2 format
|
||||
### !<label> 1 byte relative
|
||||
### $<label> 2 byte address
|
||||
### @<label> 2 byte relative
|
||||
### &<label> 4 byte address
|
||||
### %<label> 4 byte relative
|
||||
|
||||
### if you wish to use this header, you need to add :ELF_end to the end of your
|
||||
### M1 or hex2 files.
|
||||
|
||||
## ELF Header
|
||||
|
||||
:ELF_base
|
||||
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
|
||||
|
||||
03 # e_ident[EI_OSABI] Set at 3 because FreeBSD is strict
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
|
||||
02 00 # e_type Indicating Executable
|
||||
28 00 # e_machine Indicating 32bit ARM
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
&_start # e_entry Address of the entry point
|
||||
%ELF_program_headers>ELF_base # e_phoff Address of program header table
|
||||
%ELF_section_headers>ELF_base # e_shoff Address of section header table
|
||||
|
||||
00 02 00 05 # 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
|
||||
|
||||
28 00 # e_shentsize size of a section header table
|
||||
05 00 # e_shnum number of entries in section table
|
||||
|
||||
02 00 # e_shstrndx index of the section names
|
||||
|
||||
|
||||
:ELF_program_headers
|
||||
:ELF_program_header__text
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
00 00 00 00 # ph_offset
|
||||
&ELF_base # ph_vaddr
|
||||
&ELF_base # ph_physaddr
|
||||
%ELF_end>ELF_base # ph_filesz
|
||||
%ELF_end>ELF_base # ph_memsz
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
00 00 01 00 # ph_alignment
|
||||
|
||||
:ELF_text
|
|
@ -0,0 +1,117 @@
|
|||
## Copyright (C) 2016 Jeremiah Orians
|
||||
## This file is part of stage0.
|
||||
##
|
||||
## stage0 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.
|
||||
##
|
||||
## 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/>.
|
||||
|
||||
# M2-Planet standards
|
||||
DEFINE NULL 00000000
|
||||
|
||||
# Registers
|
||||
DEFINE R0 0
|
||||
DEFINE R1 1
|
||||
DEFINE R2 2
|
||||
DEFINE R3 3
|
||||
DEFINE R4 4
|
||||
DEFINE R5 5
|
||||
DEFINE R6 6
|
||||
DEFINE R7 7
|
||||
DEFINE R8 8
|
||||
DEFINE R9 9
|
||||
DEFINE R10 A
|
||||
DEFINE R11 B
|
||||
DEFINE R12 C
|
||||
DEFINE BP C
|
||||
DEFINE R13 D
|
||||
DEFINE SP D
|
||||
DEFINE R14 E
|
||||
DEFINE LR E
|
||||
DEFINE R15 F
|
||||
DEFINE PC F
|
||||
|
||||
# Register masks for push/pop16
|
||||
DEFINE {R0} 0100
|
||||
DEFINE {R1} 0200
|
||||
DEFINE {R2} 0400
|
||||
DEFINE {R3} 0800
|
||||
DEFINE {R4} 1000
|
||||
DEFINE {R11} 0008
|
||||
DEFINE {BP} 0010
|
||||
DEFINE {LR} 0040
|
||||
|
||||
# Bitshift constants
|
||||
DEFINE NO_SHIFT 0
|
||||
DEFINE LEFT 1
|
||||
DEFINE RIGHT 3
|
||||
DEFINE ARITH_RIGHT 5
|
||||
|
||||
# LOAD/STORE
|
||||
DEFINE MEMORY E5
|
||||
DEFINE STORE32 08
|
||||
DEFINE STORE8 0C
|
||||
DEFINE LOAD32 09
|
||||
DEFINE LOAD8 0D
|
||||
DEFINE LOADI8_ALWAYS 0A0E3
|
||||
DEFINE LOADI8_G 0A0C3
|
||||
DEFINE LOADI8_GE 0A0A3
|
||||
DEFINE LOADI8_EQUAL 0A003
|
||||
DEFINE LOADI8_NE 0A013
|
||||
DEFINE LOADI8_LE 0A0D3
|
||||
DEFINE LOADI8_L 0A0B3
|
||||
DEFINE LOADI8_HI 0A083
|
||||
DEFINE LOADI8_HS 0A023
|
||||
DEFINE LOADI8_LS 0A093
|
||||
DEFINE LOADI8_LO 0A033
|
||||
|
||||
# JUMP/BRANCH
|
||||
DEFINE JUMP_ALWAYS EA
|
||||
DEFINE JUMP_EQUAL 0A
|
||||
DEFINE JUMP_NE 1A
|
||||
DEFINE CALL_ALWAYS EB
|
||||
DEFINE CALL_REG_ALWAYS FF2FE1
|
||||
DEFINE RETURN FF2FE1
|
||||
|
||||
# Data movement
|
||||
DEFINE MOVE_ALWAYS A0E1
|
||||
DEFINE MVN_ALWAYS 0E0E1
|
||||
DEFINE MVN_LT 0E0B1
|
||||
DEFINE MVNI8_EQUAL 0E003
|
||||
DEFINE PUSH_ALWAYS 2DE9
|
||||
DEFINE POP_ALWAYS BDE8
|
||||
|
||||
# Arithmetic/logic
|
||||
DEFINE AUX_ALWAYS E1
|
||||
DEFINE IMM_ALWAYS E3
|
||||
DEFINE ARITH_ALWAYS E2
|
||||
DEFINE ARITH_GE A2
|
||||
DEFINE ARITH_LT B2
|
||||
DEFINE ARITH_NE 12
|
||||
DEFINE ARITH2_ALWAYS E0
|
||||
DEFINE ARITH2_GE A0
|
||||
DEFINE ADC 0A
|
||||
DEFINE ADCS 0B
|
||||
DEFINE ADD 08
|
||||
DEFINE ADDS 09
|
||||
DEFINE AND 00
|
||||
DEFINE CMP 005
|
||||
DEFINE CMPI8 005
|
||||
DEFINE MUL 0
|
||||
DEFINE MULS 1
|
||||
DEFINE OR 08
|
||||
DEFINE SHIFT A0
|
||||
DEFINE SUB 04
|
||||
DEFINE RSUB 06
|
||||
DEFINE XOR 02
|
||||
|
||||
# SYSCALL
|
||||
DEFINE SYSCALL_ALWAYS 000000EF
|
Loading…
Reference in New Issue