AT&T Assembly for Linux and Mac (sys_write)

时间:2022-05-21 06:09:17

Write() in C : (sys_write.c)

#include <stdio.h>

int main(void)
{
printf("Hello Landpack\n");
return ;
}

AT&T Assembly for Linux and Mac (sys_write)

Write() in AT&T for Linux:(sys_write.s)

.section .data

_data:  .ascii "Hello Landpack\n"

        len = .-_data

.section .text

.globl  _start

_start:

        movl    $,     %eax    #for write
movl $_data, %ecx #The address of data
movl $len, %edx #The len of string
movl $, %ebx #exit with
int $0x80 movl $, %eax #sys_exit
movl $, %ebx #exit with
int $0x80

AT&T Assembly for Linux and Mac (sys_write)

Write() in AT&T for Mac: (sys_write.s):

.globl _main

_main:

    pushq   %rbp
#movq %rsp, %rbp
leaq _data(%rip),%rdi
callq _puts
xorl %eax, %eax
popq %rbp
ret .section _TEXT,_cstring,cstring_literals _data: .ascii "Hello Landpack"

AT&T Assembly for Linux and Mac (sys_write)