The EBX register stores the address where the string (String1) is stored. I need to compare the first four characters of String1 with String2. If they are equal, then change the string to String3. Assembler is studying recently. I would be very grateful if you help me figure it out.
- So, first you will need instructions for comparing and changing the register (containing the address). - MBo
- Tell me please. I can not find - minaevmaksimik
- OK, I 'll look for you - MBo
- Can I use the cmp command to compare a register containing an address with a string? - minaevmaksimik
|
1 answer
The first four characters can be compared in one operation, if you use pointers to strings as pointers to dword :
mov eax, dword ptr[String2] ;загружаем 4 байта по указателю String2 cmp eax, dword ptr[ebx] ;сравниваем с 4 байтами по указателю из ebx jne not_equal mov esi, String3 ;копирование String3 в String1 mov edi, ebx copy: lodsb stosb test al, al ;предполагается, что строки null-терминированные jnz copy not_equal: - Thank you very much, and what team to make data on the pointer? I already have one line in memory. The second you need to add there. - minaevmaksimik
- Is it possible to compare so cmp eax, 73747231 (4 bytes of a string)? - minaevmaksimik
- @minaevmaksimik, why suddenly only one of the strings is in memory, where are the others? What is meant by the words "you need to add the second one"? It must be entered from the keyboard, read from a file or where should it come from? - t3f
- I have to add the second line to the memory myself. How can I do this? I can add a string in byte command? - minaevmaksimik
- One team - no. The answer to the question "how do I do this?" depends on the answer to the question asked above: "where does it (the line) come from?". - t3f
|