flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3 Next |
Author |
|
shoorick 28 Sep 2010, 13:48
to not puzzle newbie with invoke/stdcall difference here is an example (where it was cooked)
type a number in upper edit, then press OK ![]()
|
|||||||||||
![]() |
|
iic2 28 Sep 2010, 15:42
Quote: simple right ?.. mate its hard for me I'm starter >.< and btw I need in 32bit mode very small example on the world Overflowz, the only way to understand the simplicity of assembler is to sit down and explore a few samples given. I mean, stay down in that one procedure and change and remove stuff just to se what happen. Save those copies as back-ups with special names just in case you want to try something difference with it or even add more to it. I do that for weeks before moving on and it was worth it and still is. I wanted to understand the complete flow of the code while googling like hell all at the same time. Than you move on to the next adventure. When it all said and done, you will only need to master 5 - 10 main blocks of assembler code. With those in mind, you can rebuild many, many more customized for your program needs, quickly ... but only after you learn what it does. It will be truly amazing all you will learn with assembler, that other programmers will "NEVER" learn just because of the language they were taught to use which they are also are taught not to use ASM. This is more geared as an promotion to keep you from exploring outside their tools. C++, JAVA, etc. I'm taking a C++ course now and it has really goofy syntax but it's teach you how to talk the programming sh*t which is needed on a job. I will never stop moonlight with ASM. With it, you will always be on top of any solution needed. |
|||
![]() |
|
Overflowz 28 Sep 2010, 17:45
iic2, you're 100% right!
![]() ![]() |
|||
![]() |
|
Overflowz 28 Sep 2010, 19:12
Hey, this method is the best for me but 1 question, is that possible to write with proc's and not with ":" things ? and also, when I tried add 16 number to ecx, instead of HEX numbers it's showing "0,1,2,3,4,5,6,7,8,9,:,;,<,=,>,?,10...". someone can add function that should replace ;,:,<.. things into A,B,C,D,E,F .. ?
![]() Code: dec2str: ; EAX = value ; EDI = buffer mov ecx,16 .stack_dec: xor edx,edx div ecx add edx,'0' push edx test eax,eax jz .purge_dec call .stack_dec .purge_dec: pop dword[edi] inc edi ret |
|||
![]() |
|
baldr 28 Sep 2010, 19:26
Overflowz,
Check for edx>9 and add 'A'-10 instead of '0'. This method indeed is simple, but unnecessarily resource hungry (use iteration instead of recursion whenever possible). Division by power of 2 can be done other way. |
|||
![]() |
|
edfed 28 Sep 2010, 19:32
yes, it is possible:
there was a contest in general forum about binary to hexa conversion, and the winner algorythm was this one: Code: locodelassembly: ;use32 mov ah,al and al,0fh call @f xchg al,ah shr al,4 @@: cmp al,10 cmc sbb dl,dl and dl,7 add al,dl add al,'0' ret |
|||
![]() |
|
LocoDelAssembly 28 Sep 2010, 20:00
edfed, the first place actually belongs to MHajduk with a 25 bytes entry which additionally does not violate the original rules (i.e. no branches nor stack is used while in my code are used both). bitRAKE also posted 25 bytes code, but since he was second in doing that then so is his position
![]() |
|||
![]() |
|
edfed 28 Sep 2010, 20:10
but your too is 25 bytes, and it is the fastest.
that's why i say you are the winner. Code: bitrake: xor ah, ah mov bl, 16 div bl imul ebx, eax, 7 shr bx, 6 and bl, 1 lea eax,[eax+8*ebx+'00'] ; 32 bit sub eax,ebx the code from bitrake there is the smallest and the fastest, under some condition, tosay, my pc see loco as the fastest, maybe tomorrow, it will be bitrake. this one from mhajduk is just one of the slower, but one of the smaller too. Code: mhajduk: ror al,4 aam 16 imul ebx, eax, 7 shr bx, 6 and bl, 1 lea eax,[eax+8*ebx+'00'] sub eax,ebx |
|||
![]() |
|
MHajduk 28 Sep 2010, 20:35
edfed wrote: this one from mhajduk is just one of the slower, but one of the smaller too.
BTW, the contest which Fanael started was about size not speed, hence your "opinions" are completely inadequate here. |
|||
![]() |
|
ouadji 28 Sep 2010, 22:14
Just a quick note in French to tease edfed aie edfed, y'a MHajduk qui t'as mis à la masse là ... edfed, je te taquine (amicalement) ! ![]() |
|||
![]() |
|
Overflowz 29 Sep 2010, 12:34
baldr, I need example mate
![]() |
|||
![]() |
|
bitshifter 29 Sep 2010, 12:46
One must learn to stand before walking.
One must learn to walk before running. So why then are you looking at running shoes already? |
|||
![]() |
|
Overflowz 29 Sep 2010, 13:29
True. I just dont understand much english isn't that hard to imagine ?..
![]() |
|||
![]() |
|
Overflowz 01 Oct 2010, 14:28
1 simple question, what does "div ecx" ? for example ecx has value 50, when we will call "div ecx" what will happened ? ty. and what the point of doing that ?
|
|||
![]() |
|
LocoDelAssembly 01 Oct 2010, 14:57
Quote:
Divides the unsigned number in EDX:EAX (both registers are combined to generate a 64-bit dividend), by the number in ECX and the quotient is stored in EAX and the reminder in EDX. Consider reading the manuals like http://flatassembler.net/docs.php?article=manual#2.1.4 , http://www.intel.com/products/processor/manuals/ (the instruction set manuals), and the perhaps easier to follow than Intel's manuals http://developer.amd.com/documentation/guides/Pages/default.aspx (volume 3). Additionally, Intel's and AMD's first volume are important for basic Assembly knowledge. |
|||
![]() |
|
Overflowz 14 Oct 2010, 19:18
I'm getting mad about this.. I dont understand the code.. just someone can tell me if this can be done with MOVSB or STOSB function ? thanks.
|
|||
![]() |
|
LocoDelAssembly 14 Oct 2010, 20:33
Are you sure you really wanted to post this question here and not in the other one you were trying to concatenate two strings?
Anyway, if you mean the integer to string functionality then no, you can't use none of those instructions to magically convert integer to string. Lets try a different approach first: Code: void toString(char *buff, unsigned int number, unsigned int base) { char digit; digit = (number % base); digit += (digit > 9 ? 'A' - 10 : '0'); number = number / base; if (number != 0){ toString(buff, number, base); buff++; /* Move base pointer */ } buff[0] = digit; buff[1] = '\0'; /* NUL char. It gets overwritten unless this is the least significant digit (we are going to accept this inneficiency for now) */ } |
|||
![]() |
|
Overflowz 14 Oct 2010, 21:12
grrrr never mind.. I'll try to learn everything about assembly and I'll learn that later when I can understand things like that. Anyway thank you very much for replies.
|
|||
![]() |
|
revolution 15 Oct 2010, 00:09
Overflowz wrote: I'll try to learn everything about assembly ... |
|||
![]() |
|
Goto page Previous 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.