FASM IRC Bot Prefix

132 views Asked by At

I've been trying to learn how to create an IRC bot in assembler from some old sources. Everything is going fine with my learning except for a prefix problem.

The prefix for the bot is:

CommandPrefix equ "^^"

And the length of the prefix is added with:

add eax, 2d

I want to change the prefix to just "^", but I am having trouble with figuring out what "add eax" should be changed too for it to work. Or even if that is the best way to do it. Any help with this would be appreciated.

Here is what the original code looks like to get some idea:

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
0

There are 0 answers