试图找到字符的字符串中的数量和不顾一切‘’空格字符忽略一个字符串空格字符ASM
我有一个C++部分是通过琴弦ASM,这里是我的ASM 工作得很好,唯一的事情就是太空人物也被计算在内。
stringLength PROC PUBLIC
PUSH ebp ; save caller base pointer
MOV ebp, esp ; set our base pointer
SUB esp, (1 * 4) ; allocate uint32_t local vars
PUSH edi
PUSH esi
; end prologue
MOV esi, [ebp+8] ;gets the string
xor ebx, ebx
COMPARE:
MOV al, [esi + ebx]
CMP al, 0 ;compare character of string with 0
JE FINALE ;if = to 0 go to end
INC ebx ;counter
CMP al, ' ' ;compare with sapce
JE SPACE ;go get rid of the space and keep going
INC al ;otherwise inc al to next character and repeat
JMP COMPARE
SPACE:
DEC ebx ;get rid of the extra space
INC al
JMP COMPARE ;goes back to compare
FINALE:
MOV eax,ebx ; bring back the counter
ADD esp, (2 * 4) ; clear the stack
POP esi
POP edi
MOV esp, ebp ; deallocate locals
POP ebp ; restore caller base pointer
RET
stringLength ENDP ; end the procedure
END stringLength
上面的代码计算字符串中的字符数。如果你想计算不考虑空格的字符数量,那么你至少需要先尝试一下。*** Stackoverflow不是一个“为我写作业”的服务。 –
我知道,对不起,如果我以“请做”类人的身份出现。我可以在正确的方向得到一个点吗?我在球场中的一般方式是什么? – Ryan
提示:当你的代码反映出混淆时,清理你的'al'和'ebx'的使用和意图 –