Log in

View Full Version : Loop myLoop


jackall
July 5th, 2009, 20:47
; 1+2+3+4+5+6+7+8+9+10=37
; This code below gives ASCII version of the sum as 7 in the message box.

Code:
.386
.model flat
extrn ExitProcess: proc
extrn MessageBoxA: proc

mb_ok equ 0
hwnd equ 0
.data
head db "sum of 1+2+..A",0
body dd 0

.code
start:
mov ecx,10
mov eax,00

myloop:
add eax,ecx
loop myloop
add body,eax

push mb_ok
push offset head
push offset body
push hwnd
call MessageBoxA

push 0
call ExitProcess
end start

; tasm32/tlink32


how does one get the value in decimal in the message box ?
...the changes required in the code to transform from ASCII to decimal!

...looking forward.

evaluator
July 6th, 2009, 01:15
range coincidence.
but SUM = 55

jackall
July 6th, 2009, 06:00
Quote:
range coincidence.

May be an exercise in one’s anagramic skills.

Well,
When the (attached) .exe is run, Message box displays ascii 7, which is=37h which over again is=55d.

The Question is how (code required) do one get this 55d put on view in the window instead of the 7 making an appearance.

thank you for the response.

arc_
July 6th, 2009, 07:47
Write an additional loop that integer-divides the number by 10 until it becomes 0, and write out a byte "30h + remainder of division" on each iteration (30h is the ascii code for the character '0'). Mind you, you will need to write the bytes in reverse order, from back to front. Use the "idiv" instruction to do the division (look it up to see how it works).

For example: 53
53 / 10 = 5, remainder 3. Write out 30h + 3 = 33h (which is '3')
5 / 10 = 0, remainder 5. Write out 30h + 5 = 35h (which is '5')
Stop

evaluator
July 6th, 2009, 11:19
ahm, you are asking for Dword_2_Decimal conversion??
very bad! you did NULL search!!

jackall
July 6th, 2009, 11:58
arc! Yes, you have made it clear.

It is the profusion of such flair that makes one wanting to come back here.

i am thankful to you for sharing the information and for making an added effort to make things easier.

Regards. . .

esther
July 7th, 2009, 06:46
hi
Do a search on the forum "Convert memory to string",you might find what you want

dELTA
July 7th, 2009, 06:46
Jackall, this is a newbie reversing forum, not a newbie programming forum. Thus, you are still welcome to post such questions in the Off Topic forum, but please don't be angry if people don't want to answer such off topic (and very elementary) questions.

The following board is probably much better suited for asm programming questions of all kinds btw:

http://www.asmcommunity.net/board

You are of course still welcome with your reversing questions here, as long as they follow our rules regarding doing you own reasonable research etc.

jackall
July 7th, 2009, 15:09
dELTA. . .

The point you have mentioned is received loud and clear, as this being a reversing forum, you do not encourage rambling of an assembly programming follower.

With my narrow understanding, i believe that, the basis of all this work out called reversing is based on authentic awareness of assembly language and my focus in fact, shifted to assembly from reversing.

For example, the asm generated in Olly from the exe used in my post:

MOV ECX, 0A
MOV EAX, 0
/ADD EAX, ECX
\LOOPD SHORT sum.0040100A
ADD [DS: 40200F], EAX

Doesn’t this original code as seen below could make reversing much more clearer, meaningful? (i may be forgiven as my understanding is limited in this situation).

start:
mov ecx,10
mov eax,00

myloop:
add eax,ecx
loop myloop
add body,eax

But if you hold the view that chaff is independent of grain and here we deal with only the former, yes... i respect your point of view, though not fully subscribe to it. Well, i bear this view in my future postings.

Regarding another point that you have mentioned...

i don’t consider a forum is a picnic spot where a few misguided teenagers could taunt everyone, and at everything. iam here to learn, understand if possible, what i haven’t understood yet. iam learning out of a conscious choice, not out of any compulsion.

i don’t feel, even a little uncomfortable when an erudite proficient rebukes me (find a single erroneous word!! in my request/response to personmann, naides, blabberer and admiral, a few of whom i hold at high esteem!!).

But, the latest manifestations of these coarse weird clowns here, the nits and lice, possessing nothing more than a little superficial acquaintance in any sphere, pitifully hiding their weakness with weird use of adjectives and integers, can get away with that buffoonery, only for the moment and that again to some degree. A Circus needs jokers and jesters to entertain kids and dimwits; do you need them too ?

But, they will not be allowed to have a free run over me. i don’t get angry with them. But, when they deliberately cross my path, make a concerted effort to Bronx cheer, i like to tell them, what i feel they are worthy of, and where they in reality must belong to. don’t you think i do have a right to react in an appropriate manner ?

Well, thank you for taking the time to post the message.

Regards...

BanMe
July 7th, 2009, 15:46
lol Hey Jackall
long time no see.. how goes things? good I hope.

Please dont take dELTA's words as a afront to you. take them as a gentle guide, for it is unwise to anger him..
It's Great to see you on this board and hope to see more posting from you.
Contact me on Messenger and maybe I can be of assistance to such simple questions. atoi would've worked if I understand the problem correctly from briefing the post and asm code..

regards BanMe

dELTA
July 7th, 2009, 19:06
Quote:
[Originally Posted by jackall;81627]The point you have mentioned is received loud and clear, as this being a reversing forum, you do not encourage rambling of an assembly programming follower.
Well, more precisely we don't prefer to have any off topic posts outside the off topic forum.


Quote:
[Originally Posted by jackall;81627]With my narrow understanding, i believe that, the basis of all this work out called reversing is based on authentic awareness of assembly language and my focus in fact, shifted to assembly from reversing.
...
But if you hold the view that chaff is independent of grain and here we deal with only the former, yes... i respect your point of view, though not fully subscribe to it. Well, i bear this view in my future postings.
Actually, the only "view I hold", in addition to what I wrote above, is that an extremely elementary programming question that really doesn't have anything to do with assembler programming, but rather with basic understanding of the difference between a string and an integer, which also can be answered with very basic own research, and ALSO has been posted outside the off topic forum, is an acceptable reason for members to be annoyed for having their time wasted, and also an acceptable reason for them to show this annoyance by either reflecting it in their answers, or not to answer at all.

And regarding the chaff and grain, you also need to eat to reverse stuff for any longer period of time, but we still don't swap recipes outside of the off topic forum on this board.


Quote:
[Originally Posted by jackall;81627]Regarding another point that you have mentioned...

i don’t consider a forum is a picnic spot where a few misguided teenagers could taunt everyone, and at everything. iam here to learn, understand if possible, what i haven’t understood yet. iam learning out of a conscious choice, not out of any compulsion.

i don’t feel, even a little uncomfortable when an erudite proficient rebukes me (find a single erroneous word!! in my request/response to personmann, naides, blabberer and admiral, a few of whom i hold at high esteem!!).

But, the latest manifestations of these coarse weird clowns here, the nits and lice, possessing nothing more than a little superficial acquaintance in any sphere, pitifully hiding their weakness with weird use of adjectives and integers, can get away with that buffoonery, only for the moment and that again to some degree. A Circus needs jokers and jesters to entertain kids and dimwits; do you need them too ?
Well, we don't consider our forums a magical place where people can just throw out any stupid, non-researched and more or less off-topic question the second they think of it, not to mention expecting to have it answered by someone, or even disrespecting anyone who don't want to answer it, or anyone annoyed with this breach of our forum rules. If anyone does this, we find it completely ok to release both the hounds, the clowns and anyone else who's up for handing out a bashing, if nothing else just so we don't have to do it ourselves.


Quote:
[Originally Posted by jackall;81627]But, they will not be allowed to have a free run over me.
Actually, they will, as long as you break any forum rules, and luckily for us, we're the ones deciding that.

All we want is for people to respect the time of our members, and thus follow the rules of the board. If someone doesn't, they don't deserve any respect back, and if they don't accept that, they will be bashed one way or another. Simple as that.

Finally, we do indeed encourage learning, we just don't necessarily encourage it happening by having our members spoon feed people all the things that are rather to be considered prerequisites of the topics discussed on this board than the topics themselves.