# An example - Listing command line parameters (查看命令行参数)
#
# Linux系统为要执行的程序在内存中创建一个区域。分配给程序的内存区域可以位于系统
# 物理内存的任何位置。为了简化,每个程序都被分配相同的虚拟内存地址。
# 虚拟内存地址由操作系统映射到物理内存地址。
#
# 在LINUX中,分配给程序运行的虚拟内存地址从地址0x80480000开始,到地址0xbfffffff结束。
# 系统按照专门的格式把程序存放在虚拟内存地址中。
.section .data
output1:
.asciz "There are 0x%08x parameters:\n"
output2:
.asciz "%s\n"
.section .text
.globl main
main:
movl (%esp), %ecx
push %ecx
push $output1
call printf
addl $4, %esp
pop %ecx
movl %esp, %ebp
addl $4, %ebp
loop1:
push %ecx
push (%ebp)
push $output2
call printf
addl $8, %esp
pop %ecx
addl $4, %ebp
loop loop1
push $0
call exit
# gcc -g -o 04 04-command-parameter.s
# ./04 test 1 2 3 4
#