.section .data
space:
.ascii " "
.section .bss
.lcomm buffer, 256
.section .text
.global _start
_start:
nop
leal space, %esi
leal buffer, %edi
movl $256, %ecx
cld
lodsb
rep stosb
movl $1, %eax
movl $0, %ebx
int $0x80
... ...
(gdb) print/x $eax
$1 = 0x20
... ...
(gdb) x/10b &buffer
0x80490a0 <buffer>: 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20
0x80490a8 <buffer+8>: 0x20 0x20
.section .data
string1:
.asciz "This is a TEST, of the conversion program!\n"
length:
.int 43
.section .text
.global _start
_start:
nop
leal string1, %esi
movl %esi, %edi
movl length, %ecx
cld
loop1: #如果是小写字母则转换为大写字母,否则忽略
lodsb
cmpb $'a', %al
jl skip
cmpb $'z', %al
jg skip
subb $0x20, %al
skip:
stosb
loop loop1
end:
pushl $string1
call printf
addl $4, %esp
pushl $0
call exit
$ as -gstabs -o convert.o convert.s
$ ld -dynamic-linker /lib/ld-linux.so.2 -o convert -lc convert.o
$ ./convert
THIS IS A TEST, OF THE CONVERSION PROGRAM!
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |