Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Set a flag to determine if the user is cheating
- isCheating db 0
- ; Define a function to check if the user is cheating
- checkForCheats:
- ; Set a list of cheats
- cheats db 'cheat1', 0, 'cheat2', 0, 'cheat3', 0, 0
- cheatsLen equ $ - cheats
- ; Initialize pointers to the beginning of the input and cheat strings
- mov si, [bp + 4] ; Input string pointer
- mov di, offset cheats ; Cheat string pointer
- .checkLoop:
- ; Check if the input string matches the current cheat string
- cld ; Clear direction flag
- lodsb ; Load character from string
- scasb ; Compare character with cheat string
- jne .nextCheat ; If not equal, go to next cheat
- or al, al ; Check if we've reached the end of the input string
- jz .foundCheat ; If input string is empty, we've found a cheat
- .nextCheat:
- ; Increment cheat string pointer to next cheat
- mov di, offset cheats ; Reset cheat string pointer
- add di, cheatsLen ; Increment cheat string pointer to next cheat
- cmp di, offset cheats + cheatsLen ; Check if we've reached the end of the cheat list
- jb .checkLoop ; If not, go back to the beginning of the loop
- ; If we've reached this point, the user is not cheating
- xor al, al
- mov [isCheating], al
- ret
- .foundCheat:
- ; If we've found a cheat, set the flag to true
- mov al, 1
- mov [isCheating], al
- ret
- ; Prompt the user for input
- ; (This code assumes the
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement