tinycc: scaffold/main.c: running tcc-compiled binary #2.
* scaffold/main.c (main)[__i386__]: Rename from _start.
This commit is contained in:
parent
7619190d5c
commit
2896ce46c4
|
@ -18,13 +18,16 @@
|
||||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if __i386__
|
// #if __i386__
|
||||||
#define main _start
|
// #define main _start
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
|
||||||
#if __MESC__
|
#if __MESC__
|
||||||
asm ("mov____$i32,%ebx !42");
|
asm ("mov____$i32,%ebx !42");
|
||||||
asm ("mov____$i32,%eax !1");
|
asm ("mov____$i32,%eax !1");
|
||||||
|
@ -34,29 +37,54 @@ main (int argc, char *argv[])
|
||||||
asm (".byte 144");
|
asm (".byte 144");
|
||||||
asm (".byte 144");
|
asm (".byte 144");
|
||||||
#if 1 //MESC_TCC
|
#if 1 //MESC_TCC
|
||||||
asm (".byte 187");
|
asm (".byte 184"); //mov $1,%eax
|
||||||
asm (".byte 42");
|
asm (".byte 42");
|
||||||
asm (".byte 0");
|
asm (".byte 0");
|
||||||
asm (".byte 0");
|
asm (".byte 0");
|
||||||
asm (".byte 0");
|
asm (".byte 0");
|
||||||
|
|
||||||
asm (".byte 184");
|
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 1");
|
||||||
asm (".byte 0");
|
asm (".byte 0");
|
||||||
asm (".byte 0");
|
asm (".byte 0");
|
||||||
asm (".byte 0");
|
asm (".byte 0");
|
||||||
|
|
||||||
asm (".byte 205");
|
asm (".byte 201"); // leave
|
||||||
|
asm (".byte 195"); // ret
|
||||||
|
|
||||||
|
|
||||||
|
asm (".byte 205"); //int $0x80
|
||||||
asm (".byte 128");
|
asm (".byte 128");
|
||||||
|
|
||||||
asm (".byte 137");
|
asm (".byte 137"); //%eax,-0x4(%ebp)
|
||||||
asm (".byte 69");
|
asm (".byte 69");
|
||||||
asm (".byte 252");
|
asm (".byte 252");
|
||||||
|
|
||||||
|
asm (".byte 244"); //hlt
|
||||||
|
|
||||||
|
// asm (".byte 201");
|
||||||
|
// asm (".byte 195");
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
asm ("mov $42,%ebx");
|
asm ("mov $42,%eax");
|
||||||
asm ("mov $1,%eax");
|
asm ("leave");
|
||||||
asm ("int $128");
|
asm ("ret");
|
||||||
|
|
||||||
|
// asm ("mov $42,%ebx");
|
||||||
|
// asm ("mov $1,%eax");
|
||||||
|
// asm ("int $128");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
asm (".byte 144");
|
asm (".byte 144");
|
||||||
|
@ -68,9 +96,13 @@ main (int argc, char *argv[])
|
||||||
asm ("mov $42,%rbx");
|
asm ("mov $42,%rbx");
|
||||||
asm ("mov $1,%rax");
|
asm ("mov $1,%rax");
|
||||||
asm ("int $128");
|
asm ("int $128");
|
||||||
|
asm ("hlt");
|
||||||
#else
|
#else
|
||||||
#error "platform not supported"
|
#error "platform not supported"
|
||||||
#endif
|
#endif
|
||||||
// not reached
|
// not reached
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue