0
好的,所以我需要向後打印一個字符串。如果ebx是一個指向字符串數組開頭的指針,爲什麼我不能只添加一個到數組中的下一個字節,這是字符串中的第二個字符?在程序集中移動字符
PROMPT:
.ascii "Enter the string to evaluate \0"
FMT_STR:
.ascii "%s\0"
FMT_INT:
.ascii "%d\0"
FMT_CHR:
.ascii "%c\0"
.globl _main
_main:
pushl %ebp # save old frame ptr
movl %esp,%ebp # set new frame ptr & save local var space
//create local variable space
subl $100,%esp
pushl $PROMPT
call _printf
leal -4(%ebp),%ebx
pushl %ebx
call _gets
call _rprint
leave
ret
_rprint:
pushl %ebp
movl %esp,%ebp
pushl -1(%ebx)
pushl $FMT_CHR
call _printf
leave
ret
編輯:我重讀我的筆記,並意識到我需要增加8去字符串中的下一個字符。
您的筆記或您的閱讀內容有誤。 –
我知道,我認爲教授是錯的,因爲ascii是每個字符1個字節。 –