M2-Planet/test/common_armv7l/libc-core.M1

46 lines
1.6 KiB
Plaintext

## Copyright (C) 2016 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/>.
:_start
'0' SP BP NO_SHIFT MOVE_ALWAYS ; Setup Base Pointer
;; Prepare argv
!4 R0 ADD BP ARITH_ALWAYS ; ARGV_address = EBP + 4
{R0} PUSH_ALWAYS ; Put argv on the stack
;; Prepare envp
'0' BP R0 NO_SHIFT MOVE_ALWAYS ; Address we need to load from
!0 R0 LOAD32 R0 MEMORY ; Get ARGC
!2 R0 ADD R0 ARITH_ALWAYS ; OFFSET = ARGC + 2
'0' R0 R0 '1' MOVE_ALWAYS ; OFFSET = OFFSET * WORDSIZE
'0' R0 R0 ADD BP ARITH2_ALWAYS ; ENVP_address = EBP + OFFSET
{R0} PUSH_ALWAYS ; Put envp on the stack
;; Stack offset
!4 BP ADD BP ARITH_ALWAYS ; Fix ebp
^~FUNCTION_main CALL_ALWAYS ; Jump right into main
!1 R7 LOADI8_ALWAYS ; Setup for final exit
SYSCALL_ALWAYS ; Exit
# Stub that simply returns
:divide
'0' R14 R15 NO_SHIFT MOVE_ALWAYS
# Stub that simply returns
:modulus
'0' R14 R15 NO_SHIFT MOVE_ALWAYS