我一直在努力学习如何从一些旧的来源创建一个汇编程序的IRC机器人。除了前缀问题,我的学习一切都很顺利。
机器人的前缀是:
CommandPrefix equ "^^"
前缀的长度加上:
add eax, 2d
我想将前缀更改为“^”,但我无法弄清楚应该更改“添加eax”以使其工作。或者即使这是最好的方法。任何帮助都将不胜感激。
以下是原始代码的想法:
include "win32ax.inc"
entry Bot
CommandPrefix equ "^^"
section '.code' code readable executable
Bot:
invoke WSAStartup,0101h,WSAData
cmp eax, 0
jne Exit
invoke socket,AF_INET,SOCK_STREAM,0
cmp eax, -1
je Exit
mov dword [SocketDesc], eax
invoke inet_addr,IRCServer
mov dword [SockAddr_IP], eax
invoke htons,IRCPort
mov word [SockAddr_Port], ax
invoke connect,dword [SocketDesc],SockAddr,16d
cmp eax, 0
jne Exit
call GenerateNickname
invoke lstrcpy,SendBuffer,"NICK "
invoke lstrcat,SendBuffer,Nickname
call SendLine
invoke lstrcpy,SendBuffer,"USER "
invoke lstrcat,SendBuffer,Nickname
invoke lstrcat,SendBuffer," 8 * :"
invoke lstrcat,SendBuffer,Nickname
call SendLine
GetMotd:
call RecvLine
call HandlePing
mov ecx, 0
IsMotd:
cmp dword [ReturnBuffer + ecx], "MOTD"
je HaveMotd
cmp byte [ReturnBuffer + ecx], 0d
je GetMotd
inc ecx
jmp IsMotd
HaveMotd:
invoke lstrcpy,SendBuffer,"JOIN "
invoke lstrcat,SendBuffer,Channel
invoke lstrcat,SendBuffer," "
call SendLine
RecvCommand:
call RecvLine
call HandlePing
mov ecx, 0
IsCommand:
cmp word [ReturnBuffer + ecx], CommandPrefix
je HaveCommand
cmp byte [ReturnBuffer + ecx], 0
je RecvCommand
inc ecx
jmp IsCommand
HaveCommand:
mov ebx, ReturnBuffer
add ebx, ecx
add ebx, 2d ;add length of command prefix
invoke lstrcpy,CommandBuffer,ebx
call ExecuteCommand
jmp RecvCommand