第五章movetest3.s例子

在macOS Terminal中輸入

cc -arch i386 -Wl,-no_pie movetest3.s
./a.out

輸出

The value is 10
The value is 15
The value is 20
The value is 25
The value is 30
The value is 35
The value is 40
The value is 45
The value is 50
The value is 55
The value is 60

代碼如下

# cc -arch i386 -Wl,-no_pie movetest3.s

    .data
values:
    .long 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60

    .cstring
output:
    .asciz "The value is %d\n"

    .text
    .globl _main
    .p2align 2
_main:
    pushl %ebp

    movl $0, %edi
loop:
    movl values(,%edi,4), %eax
    pushl %eax
    pushl $output
    call _printf
    addl $8, %esp
    incl %edi
    cmpl $11, %edi
    jne loop

    xorl %eax, %eax
    popl %ebp
    retl
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章