我是汇编的新手,我正在尝试制作一个输出用户字符串后缀的程序。我也想在任何时候用户输入内容时都这样做,它会以随机颜色输出反转的字符串。但我不知道该怎么做。有人可以为我做这个代码或告诉我在哪里修改代码?非常感谢你。
INCLUDE Irvine32.inc
.data
stringInput byte 50 dup(0)
promptIn byte "Enter the string: ",0
.code
swaping MACRO a,b
XOR a,b
XOR b,a
XOR a,b
ENDM
strlen proc
push ebp
mov ebp, esp
push ebx
mov eax, 0
mov ebx, [ebp+8]
Counter:
cmp byte ptr [ebx + eax], 0
je Done
inc eax
jmp counter
Done:
pop ebx
mov esp, ebp
pop ebp
ret TYPE ebp
strlen endp
strrev proc
Push ebp
MOV ebp, esp
Push eax
Push ebx
Push ecx
Mov ebx, [ebp+8]
Mov ecx, [ebp+8]
push ebx
call strlen
ADD ecx, eax
SHR al,1
count: CMP al,0
JZ finished
MOV ah, byte PTR [ebx]
swaping ah, byte ptr [ecx-1]
MOV BYTE PTR [ebx], ah
INC ebx
DEC ecx
DEC al
JMP count
finished: POP ecx
POP ebx
POP eax
MOV esp, ebp
POP ebp
RET (TYPE ebp)*4
strrev ENDP
main proc
mov eax, 0
mov edx, offset promptIn
call writeString
mov edx, offset stringInput
mov ecx, 51
call readString
push edx
call strrev
call crlf
call writestring
call crlf
exit
main endp
end main