I have two vectors; one of them (VectorA) is entered by the user, and the other (VectorB) contains a bunch of single-digit numbers. Both are char vectors. The idea is that the program should compare VectorA numbers in order to make sure they are valid numbers by comparing them with tags in VectorB that contain all valid numbers.
If all the numbers in VectorA are in VectorB, the program returns 0. If any of the VectorA numbers is not in VectorB, the program returns 1 instead. EAX Return Register.
Here is the code, I hope it is not too dirty, but carry me (also please excuse me if I use the wrong terminology, since English is not my native language) ...
MOV edi, 5 ;VectorA is a 5 digit vector. character_1: mov rcx, 10 ;VectorB is a 10 digit vector. character_2: mov eax, [ebx+edi-1] ;ebx contains the address of VectorA cmp eax, [VectorB+rcx-1] je found_it loop character_2 mov eax, 1 jmp end_comp found_it: dec edi cmp edi, 0 jne character_1 mov eax, 0 end_comp:
Firstly, I know that I probably shouldn't have used EAX as an index, but after trying with a number of other registries, EAX was the only one that did not do YASM freak out.
The problem is ... It does not seem to work. The first test cycle works fine. If the last VectorA number is 9, it actually jumps to the found_it tag and does what it should do. However, no matter what the second number is, he never finds it on VectorB.
For debugging purposes, I added the line mov esi, [VectorB+rcx-1] directly above the main CMP line, where two values ββare compared. I learned that for the first time they are compared, ESI has the right value. However, the second time the program passes this instruction, ESI returns 14648, which, of course, does not match the contents of EAX in the next line.
Does anyone know what I'm doing wrong?