On Saturday, 3 February 2018 at 15:38:19 UTC, Basile B. wrote:
On Saturday, 3 February 2018 at 15:30:10 UTC, Basile B. wrote:
[...]
okay solved:
module runnable;
__gshared static msg = "betterC\n";
__gshared static len = 8;
extern(C) int main(int argc, char** args)
{
asm
{
naked;
mov EDX, len ;//message length
mov ECX, [msg + 4] ;//message to write
mov EBX, 1 ;//file descriptor (stdout)
mov EAX, 4 ;//system call number (sys_write)
int 0x80 ;//call kernel
mov EBX, 0 ;//process' exit code
mov EAX, 1 ;//system call number (sys_exit)
int 0x80 ;//call kernel - this interrupt won't
return
}
}
the pointer to the string data is 4 bytes later...
[msg] contains the length of the string, so there's no need of
your len variable. Just saying.