flat assembler
Message board for the users of flat assembler.
Index
> Main > Simple code went crashing |
Author |
|
JohnFound 14 Mar 2014, 18:56
You must initialize edi to some valid address, before trying to "mov [edi], al".
|
|||
14 Mar 2014, 18:56 |
|
StrenoJr 14 Mar 2014, 19:06
Could you give me a code on that?
Mine with define double continues with crashes. |
|||
14 Mar 2014, 19:06 |
|
AsmGuru62 14 Mar 2014, 19:16
Also, issue with LOOP. It uses full ECX, but your code works with CX only.
May cause trouble if high bits of ECX are not zero. Your code will LOOP much longer than intended. P.S. Same with AX vs. EAX. When you use DIV - CPU divides EDX:EAX, but the high bits of EAX may be undefined (50 was moved into AX, so high bits are left unused). P.P.S. To define buffer with string: Code: buffer rb 32 ; buffer of 32 CHARs ... mov edi, buffer ; before converting the value P.P.P.S. Also, if you planning to use the string somewhere - I think you must terminate it with 00h byte. After LOOP is completed -- ECX is zero, so simply store CL at EDI: Code: mov [edi], cl |
|||
14 Mar 2014, 19:16 |
|
JohnFound 14 Mar 2014, 19:30
SysWorm wrote: Could you give me a code on that? Something like this (read the comments): Code: format PE console ; There is no need to end the instructions with semicolon. ; The semicolon ";" in assembly starts a comment. start: mov eax, 50 ; AVOID USING 16 bit registers in 32bit program. mov ebx, 0xA xor ecx, ecx change: xor edx, edx div ebx add edx, '0' ; This is more readable in FASM. And should be 48="0" push edx inc ecx; ; USE ECX HERE. cmp eax, 0 jne change mov edi, MyBuffer ; INIT EDI move: pop eax mov [edi], al add edi, 1 loop move mov byte [edi], 0 ; don't forget to end your string with 0. end: push 0 call [ExitProcess] section '.rdata' data readable writeable MyBuffer rb 256 ; BUFFER of 256 bytes. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
14 Mar 2014, 19:30 |
|
StrenoJr 15 Mar 2014, 08:50
Guys thank you very much.
I removed everything and made it a second time and now it works like a charm. I noticed also a fancy thing: not only writeable data is valid but writable data seems to be legal too. *Don't know how I could put 49 instead of 48, I was probably stressed of it so much haha same as the size of registers was that bad because I didn't know what's wrong in there so I tried everything |
|||
15 Mar 2014, 08:50 |
|
revolution 15 Mar 2014, 08:54
SysWorm wrote: I noticed also a fancy thing: not only writeable data is valid but writable data seems to be legal too. Code: symbols_8: db 'linkinfo',19h,9 db 'readable',19h,30 db 'resource',1Ah,2 db 'writable',19h,31 symbols_9: db 'shareable',19h,28 db 'writeable',19h,31 |
|||
15 Mar 2014, 08:54 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.