tinycc: scaffold/main.c: running tcc-compiled binary #3.

* scaffold/main.c (main): Remove asm.
This commit is contained in:
Jan Nieuwenhuizen 2017-09-03 10:43:02 +02:00
parent 9555d90174
commit 7e6408534f
2 changed files with 12 additions and 89 deletions

View file

@ -326,17 +326,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.hex2))
;; (add-target (check "scaffold/main.mini-guile" #:exit 42))
(add-target (bin.mescc "scaffold/main.c" #:libc mini-libc-mes.hex2))
(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"))

View file

@ -18,91 +18,14 @@
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
// #if __i386__
// #define main _start
// #endif
int
main (int argc, char *argv[])
{
#if 0
#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 184"); //mov $1,%eax
asm (".byte 42");
asm (".byte 0");
asm (".byte 0");
asm (".byte 0");
asm (".byte 201"); // leave
asm (".byte 195"); // ret
#if 0
asm (".byte 187"); // mov $42,%ebx
asm (".byte 42");
asm (".byte 0");
asm (".byte 0");
asm (".byte 0");
asm (".byte 184"); //mov $1,%eax
asm (".byte 1");
asm (".byte 0");
asm (".byte 0");
asm (".byte 0");
asm (".byte 201"); // leave
asm (".byte 195"); // ret
asm (".byte 205"); //int $0x80
asm (".byte 128");
asm (".byte 137"); //%eax,-0x4(%ebp)
asm (".byte 69");
asm (".byte 252");
asm (".byte 244"); //hlt
// asm (".byte 201");
// asm (".byte 195");
#endif
int a = 40;
int b = 2;
return a + b;
#else
asm ("mov $42,%eax");
asm ("leave");
asm ("ret");
// 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");
asm ("hlt");
#else
#error "platform not supported"
#endif
// not reached
#endif
return 42;
#endif
}