2015年5月13日 星期三

[Linux Coding] Assembly language and C language use together

Install nasm on ArchLinux
pacman -S nasm

According ref [1]
Fix Makefile to compile on the i686 machine
LD              = ld -m elf_i386
CFLAGS          = -c -m32

Type make to compile
Execute command
[vagrant@vagrant-archlinux b]$ ./foobar 
the 2nd one

[vagrant@vagrant-archlinux b]$ xxd -u -a -g 1 -c 16 -l 80 foobar 

0000000: 7F 45 4C 46 01 01 01 00 00 00 00 00 00 00 00 00  .ELF............
0000010: 02 00 03 00 01 00 00 00 A0 80 04 08 34 00 00 00  ............4...
0000020: CC 01 00 00 00 00 00 00 34 00 20 00 03 00 28 00  ........4. ...(.
0000030: 07 00 06 00 01 00 00 00 00 00 00 00 00 80 04 08  ................
0000040: 00 80 04 08 64 01 00 00 64 01 00 00 05 00 00 00  ....d...d.......

Reference:
  1. Assembly language and C language use together

0 意見:

張貼留言