back to AT&T syntax for assembly

this reverts 5c04730534.

sadly the quality of the intel dialect in llvm's assembly
parser has many frustrating bugs, and generally has unfortunate
syntax.

the plan is to use AT&T for now since it at least works,
and eventually zig will have its own assembly parser for
x86 and it will be as close to NASM as possible.
This commit is contained in:
Andrew Kelley
2017-04-30 11:28:11 -04:00
parent cbfe4b4bae
commit 29defd705d
6 changed files with 17 additions and 37 deletions

View File

@@ -420,20 +420,20 @@ pub const F_GETOWN_EX = 16;
pub const F_GETOWNER_UIDS = 17;
pub inline fn syscall0(number: usize) -> usize {
asm volatile ("int 80h"
asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize)
: [number] "{eax}" (number))
}
pub inline fn syscall1(number: usize, arg1: usize) -> usize {
asm volatile ("int 80h"
asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize)
: [number] "{eax}" (number),
[arg1] "{ebx}" (arg1))
}
pub inline fn syscall2(number: usize, arg1: usize, arg2: usize) -> usize {
asm volatile ("int 80h"
asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize)
: [number] "{eax}" (number),
[arg1] "{ebx}" (arg1),
@@ -441,7 +441,7 @@ pub inline fn syscall2(number: usize, arg1: usize, arg2: usize) -> usize {
}
pub inline fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) -> usize {
asm volatile ("int 80h"
asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize)
: [number] "{eax}" (number),
[arg1] "{ebx}" (arg1),
@@ -450,7 +450,7 @@ pub inline fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) ->
}
pub inline fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> usize {
asm volatile ("int 80h"
asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize)
: [number] "{eax}" (number),
[arg1] "{ebx}" (arg1),
@@ -462,7 +462,7 @@ pub inline fn syscall4(number: usize, arg1: usize, arg2: usize, arg3: usize, arg
pub inline fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize,
arg4: usize, arg5: usize) -> usize
{
asm volatile ("int 80h"
asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize)
: [number] "{eax}" (number),
[arg1] "{ebx}" (arg1),
@@ -475,7 +475,7 @@ pub inline fn syscall5(number: usize, arg1: usize, arg2: usize, arg3: usize,
pub inline fn syscall6(number: usize, arg1: usize, arg2: usize, arg3: usize,
arg4: usize, arg5: usize, arg6: usize) -> usize
{
asm volatile ("int 80h"
asm volatile ("int $0x80"
: [ret] "={eax}" (-> usize)
: [number] "{eax}" (number),
[arg1] "{ebx}" (arg1),

View File

@@ -19,10 +19,10 @@ export nakedcc fn _start() -> noreturn {
switch (@compileVar("arch")) {
Arch.x86_64 => {
argc_ptr = asm("lea %[argc], [rsp]": [argc] "=r" (-> &usize));
argc_ptr = asm("lea (%%rsp), %[argc]": [argc] "=r" (-> &usize));
},
Arch.i386 => {
argc_ptr = asm("lea %[argc], [esp]": [argc] "=r" (-> &usize));
argc_ptr = asm("lea (%%esp), %[argc]": [argc] "=r" (-> &usize));
},
else => @compileError("unsupported arch"),
}