Files
linguist/samples/Terra/asm.t
2016-01-28 11:22:27 +07:00

28 lines
505 B
Perl

local a = ...
if not a then
--force MCJIT
os.execute("../terra -m asm.t true")
return
end
C = terralib.includec("stdio.h")
struct Vendor {
maxV : int;
b : int;
c : int;
d : int;
}
terra foo()
var r = terralib.asm(Vendor,"cpuid","={eax},={ebx},={ecx},={edx},{eax},~{dirflag},~{fpsr},~{flags}",false,0)
r.c,r.d = r.d,r.c
C.printf("%.12s\n", &r.b)
end
foo()
terra addone(a : int)
return terralib.asm(int,"addl $$1,$1","=r,0",true,a)
end
assert(addone(3) == 4)