标签:
1 ; nasm -f macho hello32.asm -o ../bin/hello32.o && ld -macosx_version_min 10.7.0 -o ../bin/hello32 ../bin/hello32.o && ../bin/hello32 2 3 4 global start 5 6 7 section .text 8 start: 9 push dword msg.len 10 push dword msg 11 push dword 1 12 mov eax, 4 ; sys_write 13 sub esp, 4 14 int 0x80 15 add esp, 16 16 17 18 push dword 0 19 mov eax, 1 ; sys_exit 20 push eax 21 int 0x80 22 23 24 section .data 25 msg: db "Hello, world!", 10 26 .len: equ $ - msg
00222700000i[CPU0 ] EFER = 0x00000000 00222700000i[CPU0 ] | EAX=00000116 EBX=00000000 ECX=00090034 EDX=00000000 00222700000i[CPU0 ] | ESP=0000050e EBP=0000003d ESI=000e0000 EDI=00000034 00222700000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf SF zf af pf CF 00222700000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D 00222700000i[CPU0 ] | CS:f000( 0004| 0| 0) 000f0000 0000ffff 0 0 00222700000i[CPU0 ] | DS:0040( 0005| 0| 0) 00000400 0000ffff 0 0 00222700000i[CPU0 ] | SS:8e81( 0005| 0| 0) 0008e810 0000ffff 0 0 00222700000i[CPU0 ] | ES:8da3( 0005| 0| 0) 0008da30 0000ffff 0 0 00222700000i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0 00222700000i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0 00222700000i[CPU0 ] | EIP=00005008 (00005008) 00222700000i[CPU0 ] | CR0=0x60000010 CR2=0x00000000 00222700000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000 00222700000i[CPU0 ] 0x0000000000005008>> push bp : 55
每个寄存器的都输出
#!/bin/sh # this sets up the compile for MacOS X # # To support plugins on macosx, you must have "dlcompat" installed. You can # get dlcompat by installing the fink package "dlcompat-devel". On the SF # compile farm, dlcompat is in /sw/include and /sw/lib, so we have added # those paths to the environment variables. set echo CC=‘clang -Wno-error=unused-command-line-argument-hard-error-in-future‘ #CFLAGS="-pipe -O3 -I/sw/include -fomit-frame-pointer -finline-functions -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-labels=16 -falign-loops-max-skip=15 -falign-jumps-max-skip=15 -fprefetch-loop-arrays $CFLAGS" CPATH="/sw/include" CPPFLAGS="" CXXFLAGS="$CFLAGS" LDFLAGS="-L/sw/lib" export CC export CFLAGS export CPATH export CPPFLAGS export CXXFLAGS export LDFLAGS ./configure --enable-sb16 --enable-ne2000 --enable-all-optimizations --enable-cpu-level=6 --enable-x86-64 --enable-vmx=2 --enable-pci --enable-clgd54xx --enable-voodoo --enable-usb --enable-usb-ohci --enable-usb-xhci --enable-es1370 --enable-e1000 --enable-plugins --with-sdl --enable-disasm --enable-debugger ${CONFIGURE_ARGS}
1 ; DOS下的hello,COM format 2 ; nasm.exe hello32win.asm -o hello32win.com 3 ; macOS下 4 ; nasm hello32win.asm -o hello32.com && cp hello32.com "/Volumes/NO NAME/" 5 6 7 org 0100H ; COM need 8 9 10 jmp _start 11 section .text 12 _start: 13 mov edx, hello ; hello的地址 14 mov ah, 9 ; write code 9 for print 15 int 21h 16 17 18 mov ah,04ch ; ‘exit‘ system call 19 int 21h ; call the kernel 20 21 22 section .data 23 hello db ‘Hello world!‘,13,10,‘$‘ ; int21h的字符串需要$结尾
标签:
原文地址:http://www.cnblogs.com/shifting/p/4548115.html