简体   繁体   中英

creating a Loop Intel based Assembly x86

I am currently working on a project written in 32 bit intel syntax assembly. It is a small program to take input with sys read and cmp and check if it is a Palindrome and continue looping until enter has been pressed. My problem is, I can't figure out how to clear my memory for the variable I am using, it will move +1 and just print the rest of the word until I ctrl c out of the prompt. So my question is can you help me either figure out how to xor the memory or some other way? Thanks code is below. ;has to be callable in ac program


BITS 32

global _start

section .data

userMsg: DW 'Please enter a String to check:'

lenUserMsg EQU $-userMsg

;usereMsg DB 'Is a Palindrome'

;lenUsereMSG EQU $-usereMsg

;usrMsg DB 'Is not a Palindrome'

;lenUsrMsg EQU $-usrMsg


Section .bss

s:RESB 1024

w:RESB 1024


section .text

_start:

;promping the user to enter a string in which to check for palindrome

Loop_Palindrome:

mov eax, 4

mov ebx, 1

mov ecx, userMsg

mov edx, lenUserMsg

int 80h

mov eax, 3

mov ebx, 0

mov ecx, w

mov edx, s

int 80h

cmp eax, 0

je exit

cmp BYTE [w], 0

je exit


print_exit:

mov eax, 4

mov ebx, 1

mov ecx, w

mov edx, s

int 80h


jmp Loop_Palindrome

exit:

mov eax, 1

mov ebx, 0

int 80h

Found my Problem, needed to " cmp byte [w], 10 ". I Needed to check for new line not a 0 lol.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM