tinycc: scaffold/main.c: first running tcc-compiled binary.
* scaffold/main.c (_start): Exit 42 using asm.
This commit is contained in:
parent
3560ee6c95
commit
9aa8d8bd9d
16
make.scm
16
make.scm
|
@ -253,17 +253,17 @@ exec ${GUILE-guile} --no-auto-compile -L . -L guile -C . -C guile -s "$0" ${1+"$
|
|||
|
||||
;;(add-target (group "check-scaffold" #:dependencies (filter (target-prefix? "check-scaffold") %targets)))
|
||||
|
||||
(add-target (bin.gcc "scaffold/main.c"))
|
||||
(add-target (check "scaffold/main.gcc" #:exit 42))
|
||||
;; (add-target (bin.gcc "scaffold/main.c"))
|
||||
;; (add-target (check "scaffold/main.gcc" #:exit 42))
|
||||
|
||||
(add-target (bin.gcc "scaffold/main.c" #:libc #f))
|
||||
(add-target (check "scaffold/main.mlibc-gcc" #:exit 42))
|
||||
;; (add-target (bin.gcc "scaffold/main.c" #:libc #f))
|
||||
;; (add-target (check "scaffold/main.mlibc-gcc" #:exit 42))
|
||||
|
||||
(add-target (bin.mescc "scaffold/main.c" #:libc mini-libc-mes.E))
|
||||
(add-target (check "scaffold/main.mini-guile" #:exit 42))
|
||||
;; (add-target (bin.mescc "scaffold/main.c" #:libc mini-libc-mes.E))
|
||||
;; (add-target (check "scaffold/main.mini-guile" #:exit 42))
|
||||
|
||||
(add-target (bin.mescc "scaffold/main.c"))
|
||||
(add-target (check "scaffold/main.guile" #:exit 42))
|
||||
;; (add-target (bin.mescc "scaffold/main.c"))
|
||||
;; (add-target (check "scaffold/main.guile" #:exit 42))
|
||||
|
||||
|
||||
(add-target (bin.gcc "scaffold/hello.c"))
|
||||
|
|
|
@ -18,8 +18,59 @@
|
|||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if __i386__
|
||||
#define main _start
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
#if __MESC__
|
||||
asm ("mov____$i32,%ebx !42");
|
||||
asm ("mov____$i32,%eax !1");
|
||||
asm ("int____$0x80");
|
||||
#elif __i386__
|
||||
asm (".byte 144");
|
||||
asm (".byte 144");
|
||||
asm (".byte 144");
|
||||
#if 1 //MESC_TCC
|
||||
asm (".byte 187");
|
||||
asm (".byte 42");
|
||||
asm (".byte 0");
|
||||
asm (".byte 0");
|
||||
asm (".byte 0");
|
||||
|
||||
asm (".byte 184");
|
||||
asm (".byte 1");
|
||||
asm (".byte 0");
|
||||
asm (".byte 0");
|
||||
asm (".byte 0");
|
||||
|
||||
asm (".byte 205");
|
||||
asm (".byte 128");
|
||||
|
||||
asm (".byte 137");
|
||||
asm (".byte 69");
|
||||
asm (".byte 252");
|
||||
|
||||
#else
|
||||
asm ("mov $42,%ebx");
|
||||
asm ("mov $1,%eax");
|
||||
asm ("int $128");
|
||||
#endif
|
||||
|
||||
asm (".byte 144");
|
||||
asm (".byte 144");
|
||||
asm (".byte 144");
|
||||
|
||||
#elif __x86_64__
|
||||
asm (".byte 144");
|
||||
asm ("mov $42,%rbx");
|
||||
asm ("mov $1,%rax");
|
||||
asm ("int $128");
|
||||
#else
|
||||
#error "platform not supported"
|
||||
#endif
|
||||
// not reached
|
||||
return 42;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue