.section .data myvalue: .byte 67,68,69,70,0 mygs: .asciz "%c\n" mygss: .asciz "%s\n" .section .text .globl main main: #以下为传数值 #深未来技术,http://deepfuture.iteye.com #基地址(偏移地址[必须为寄存器],数据元素变址,数据元素长度[必须为寄存器],) #基地址+偏移地址+数据元素变址*数据元素长度 movl $2,%ecx movl myvalue(,%ecx,1),%ebx #将myvalue的变址为2,长度为1的数据值移到ebx中 push %ebx push $mygs call printf #以下为传地址 movl $2,%ecx movl $myvalue,%ebx#传myvalue的地址,变量前加上$ push %ebx push $mygss call printf #以下为传数值 movl $2,%ecx movl myvalue,%ebx#传myvalue第一个内存位置的数值 push %ebx push $mygs call printf #以下为传地址,mov %eax,(%ebx)表示把eax值复制到寄存器ebx所代表内存位置中,寄存器中存放着地址 movl $71,%edx movl $myvalue,%eax; movb %dl,2(%eax)#eax指向位置后的第2个字节,将69改为71 movl $myvalue,%ebx push %ebx push $mygss call printf push $0 call exit
deepfuture@deepfuture-laptop:~/private/mytest$ gcc -o test12 test12.s
test12.s: Assembler messages:
test12.s:0: Warning: end of file not at end of a line; newline inserted
deepfuture@deepfuture-laptop:~/private/mytest$ ./test12
E
CDEF
C
CDGF
deepfuture@deepfuture-laptop:~/private/mytest$