I am attempting to make a program that will input numbers into an array then be able to search the array for one of the numbers.I can get it to read and search alright to find the number but the user is supposed to be able to search again, where I have to compare their input to “n” and “N”. I can’t seem to get it to work correctly. I am not sure if using atow is the correct input or not, but here is the code.
number1 WORD ?
anArray WORD 100 DUP (?)
count WORD ?
search WORD ?
searchn BYTE "n",0
searchNo BYTE "N",0
prompt1 BYTE "Enter a number or -1 to quit.", 0
prompt2 BYTE "Enter a number to search for", 0
prompt3 BYTE "Search for another number Y/N",0
inString BYTE 40 DUP (?)
outMsgLabel BYTE "Search Result", 0
frontOut1 BYTE 6 DUP (?)
outMsg1 BYTE " is element"
rearOut1 BYTE 6 DUP (?),0
frontOut2 BYTE 6 DUP (?)
outMsg2 BYTE " is not in array",0
searchAgain: input prompt3, inString, 40
atow inString
mov dx,ax
atow searchn
mov ax,"n"
cmp ax,dx
je end1
atow searchNo
mov ax,"N"
cmp ax,dx
je end1
jmp next
I have only included the snippets of the code that doesn’t work and my .DATA section.
Why does everyone say write it in a HLL first?
Why are you using WORD sizes? Use the natural size of the processor 32 bit.
What Assembler is this? If it is MASM or any other, are input, atow macros or functions? Well either way, you are trying to convert the address of inString to a word not its contents
Try this: