### GNU Mes --- Maxwell Equations of Software ### Copyright (C) 2016 Jeremiah Orians ### Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen ### ### This file is part of GNU Mes. ### ### GNU Mes 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. ### ### GNU Mes 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 GNU Mes. If not, see . :UNUSED_start push___%rbp mov____%rsp,%rbp sub____$i32,%rsp %0x10a4 mov____$i8,%rax !0 movl___%eax,0x32 &GLOBAL___stdin mov____$i8,%rax !1 movl___%eax,0x32 &GLOBAL___stdout mov____$i8,%rax !2 movl___%eax,0x32 &GLOBAL___stderr mov____%rbp,%rax add____$i8,%rax !8 mov____(%rax),%rax add____$i8,%rax !0x03 shl____$i8,%rax !0x03 add____%rbp,%rax mov____%rax,0x32 &GLOBAL_environ ;; push___%rax ;M2-Planet pushes forward mov____%rbp,%rax ;argc add____$i8,%rax !8 mov____(%rax),%rax push___%rax mov____%rbp,%rax ;argv add____$i8,%rax !16 push___%rax mov____0x32,%rax &GLOBAL_environ push___%rax ;env mov____%rdi,%rbp ;M2-Planet calling convention add____$i8,%rbp !8 call32 %FUNCTION_main add____$i8,%rsp !0x0 test___%rax,%rax mov____%rax,%rdi mov____$i32,%rax %0x3c syscall hlt mov____%rbp,%rsp pop____%rbp ret :_start COPY_rsp_to_rbp ; Protect rsp ;; Prepare argv LOAD_BASE_ADDRESS_rax %8 ; ARGV_address = RBP + 8 PUSH_RAX ; Put argv on the stack ;; Prepare envp COPY_rbp_to_rax ; Address we need to load from LOAD_INTEGER ; Get ARGC ADD_IMMEDIATE_to_rax %2 ; OFFSET = ARGC + 2 SAL_rax_Immediate8 !3 ; OFFSET = OFFSET * WORDSIZE ADD_rbp_to_rax ; ENVP_address = RSP + OFFSET PUSH_RAX ; Put envp on the stack ;; mes c lib environ mov____%rax,0x32 &GLOBAL_environ ;; mes c lib io mov____$i8,%rax !0 movl___%eax,0x32 &GLOBAL___stdin mov____$i8,%rax !1 movl___%eax,0x32 &GLOBAL___stdout mov____$i8,%rax !2 movl___%eax,0x32 &GLOBAL___stderr LOAD_IMMEDIATE_rax &GLOBAL___stdin PUSH_RAX #_common_recursion LOAD_IMMEDIATE_rax %0 POP_RBX # _common_recursion STORE_INTEGER LOAD_IMMEDIATE_rax &GLOBAL___stdout PUSH_RAX #_common_recursion LOAD_IMMEDIATE_rax %1 POP_RBX # _common_recursion STORE_INTEGER LOAD_IMMEDIATE_rax &GLOBAL___stderr PUSH_RAX #_common_recursion LOAD_IMMEDIATE_rax %2 POP_RBX # _common_recursion STORE_INTEGER ;; Stack offset ADD_IMMEDIATE_to_rbp %8 ; Fix rbp ;; Perform the main loop CALL_IMMEDIATE %FUNCTION_main mov____%rax,%rdi mov____$i32,%rax SYS_exit syscall