flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > [SOLVED]Compare String, Invalid OpCode (BITS 32 :) ) |
Author |
|
sid123 13 Feb 2014, 10:48
I don't know why this code should hang on QEMU, and cause a Invalid Opcode on Bochs, works fine on 16 bit though.
Code: strcmp: pusha .cmp: ;; Put one char from ESI into AL mov al, [esi] ;; Put one of 'em in BL mov bl, [edi] ;; Compare them cmp al, bl jne .unequal ;; End of String? cmp al, 0 je .equal_done inc esi inc edi jmp .cmp .unequal: popa ;; Set EAX to unequal code (Plan to use a CLC here.) mov eax, -1 ret .equal_done: popa ;; Null out EAX, Plan to use a STC here xor eax, eax ret I call it like this: Code: mov eax, shell_input_buffer call GetString ;; Put Buffer in ESI for comparison mov esi, shell_input_buffer .compare: ;; Now compare the strings mov edi, shell_help_str call strcmp cmp eax, 0 je shell_help ;call printf32 jmp shell_error My Get String Function works fine as it should, as I can "echo" my string properly, I guess it's some weird problem here. I don't understand why does it cause an "Invalid OpCode Error", is there a restriction in 32-bit Mode for using this? Cheers, Sid _________________ "Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X XD Last edited by sid123 on 15 Feb 2014, 16:10; edited 1 time in total |
|||
13 Feb 2014, 10:48 |
|
sid123 13 Feb 2014, 13:44
If I understand you correctly PUSHA is for 16 bit, PUSHAD is for 32 bit?
|
|||
13 Feb 2014, 13:44 |
|
baldr 13 Feb 2014, 22:53
sid123,
As fasm manual says, pusha mnemonic generates appropriate opcode for current code size (in other words, 0x60 always, except for 64-bit code ;-), whereas pushaw and pushad are more sensitive and generate operand-size override prefix on demand. This slightly deviates from Intel SDM/AMD APM though. Bochs has internal debugger; QEMU can be configured for remote debugging as well. Last edited by baldr on 15 Feb 2014, 14:35; edited 1 time in total |
|||
13 Feb 2014, 22:53 |
|
revolution 14 Feb 2014, 06:27
sid123: Your code does not show if the CPU is running in 32-bit or 16-bit mode. It also does not show if it is assembled in 32-bit or 16-bit mode. Example:
Code: use32 mov esi, something ;... use16 mov esi, something There are no apparent invalid opcodes in the code you posted so we are left guessing as to what is happening in the rest of the program. If you need more help then consider posting a complete example so that we can see what is happening. |
|||
14 Feb 2014, 06:27 |
|
SeproMan 15 Feb 2014, 14:30
sid123,
I see you don't take into account the length of the second string. Perhaps nothing is wrong with THIS code but is an error generated elsewhere. _________________ Real Address Mode. |
|||
15 Feb 2014, 14:30 |
|
sid123 15 Feb 2014, 16:02
Hi,
Thanks for all sugestions. I finally found out that by tweaking my segments a lil'; I could use the 'rep cmpsb' instructon. I had to tweak my GetString function to return the number of characters recorded in ECX. Thanks again for helping. Cheers, Sid |
|||
15 Feb 2014, 16:02 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.