flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
jacko221 25 Jul 2006, 05:22
one last thing... i forgot to add the jump for the loop in the label exchange.
The code should be like this exchange: cmp bx,si ;compare the addresses jae print ;jump if they are equal or esi is above xchg si,bx ;else exchange bytes dec si ;decrease si inc bx ;increase bx jmp exchange |
|||
![]() |
|
shoorick 25 Jul 2006, 05:22
1.it is strange you are using 16-bit registers in protected mode - why not ebx/esi?
2.it would be good practice to preserve such registers like ebx/esi/edi 3.also, sizeof.buffer should be 1 - size of db. assuming to it something other is not correct, i think. you have to use other word for this purpose, like sizeof_buffer. 4.at last, you have place jump to exchange after inc (e)bx to make loop should be enough, i think... |
|||
![]() |
|
shoorick 25 Jul 2006, 05:28
no, not enough:
after sizeof.buffer = $-buffer next line you have to place db 0 (string terminator) you may not found this problem if there will be placed zeros of aligning sections, but otherwise you may got unexpected effect ![]() |
|||
![]() |
|
jacko221 25 Jul 2006, 05:31
![]() |
|||
![]() |
|
zhak 25 Jul 2006, 07:18
here's what you need, i think...
Code: format PE GUI 4.0 include '%fasminc%/win32ax.inc' entry start section '.data' data readable writeable buffer db 'reverse buffer',0 sizeof.buffer = $-buffer section '.code' code readable executable start: lea ebx,[buffer] lea esi, [ebx+sizeof.buffer-2] exchange: mov al, [esi] mov dl, [ebx] mov [esi], dl mov [ebx], al inc ebx dec esi cmp ebx, esi jle exchange invoke MessageBox,0,buffer,buffer,0 invoke ExitProcess,0 section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include '%fasminc%\apia\kernel32.inc' include '%fasminc%\apia\user32.inc' |
|||
![]() |
|
okasvi 25 Jul 2006, 13:19
here is one way of doing, I know it could be done alot more nicely
Code: format PE GUI 4.0 include 'win32a.inc' entry $ ;revstring push BUFFER_LEN push buffer2 push buffer call RevString ;messagebox push 0 push buffer push buffer2 push 0 call [MessageBox] ;exitprocess push 0 call [ExitProcess] ;- imports data import library kernel32, 'KERNEL32.DLL',\ user32, 'USER32.DLL' import kernel32, ExitProcess, 'ExitProcess' import user32, MessageBox, 'MessageBoxA' end data ;- data buffer db 'reverse buffer',0 BUFFER_LEN = $-buffer buffer2 rb BUFFER_LEN ;- proc RevString uses ebx esi edi, source, destination, length mov esi, [source] mov ebx, [length] mov edi, [destination] add esi, ebx xor ecx, ecx .loop: mov al, byte [esi] cmp al, 0 je @f mov byte [edi], al inc edi inc ecx @@: dec esi cmp ecx, ebx jne .loop mov byte [edi-1], 0 mov eax, [destination] ret endp |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.