News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Adding To Addresses ESI

Started by AgentSmithers, May 24, 2009, 07:59:06 PM

Previous topic - Next topic

AgentSmithers

Anygot one a link to informing on how to add to addresses

I want to move slowly down the ram by creating an Array.

moving the ptr to a Variable then adding to that var.

This examples of using a variable with the value seems to crash like

.data
MyVar dd 5
StartOfArray db 16 dup ("0")
.data?


mov ESI, offset [StartOfArray]
add ESI, MyVar

I don't think im doing it right, It might be adding the two Addresses themself together instead of the inside MyVar, Anyone have the correct ways of INC a Address?

BogdanOntanu

Please take the time needed to learn basic English.

You must explain clearly what you want to do.

IF you write confusing sentences with odd placement of words THEN we can not understand what you are asking about AND because of this we can not help you.

I have locked one of your previous threads because of cracking suspicions. Under the circumstances we need a clear explanation of what you want to achieve before one can help you. Confusion will not help.

In your example I can not find the symbol named "StartOfArray". What is it?




Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

dedndave

#2

MyVar dd ?      ;5 elements in the array
         dd ?      ;each element is a double-word
         dd ?      ;a double-word (dword) is 4 bytes
         dd ?      ;dd stands for define dword
         dd ?

.code
;
; do stuff
;
mov esi, offset MyVar   ;start at the beginning
mov ecx,5                 ;count register (5 elements in the array)

loop01:
;
; do stuff
;
  add esi,4      ;point to next element (each element is 4 bytes long)
;
; do more stuff
;
  loop loop01


EDIT - one thing to note - if you use the LODSD instruction, it loads the value at [esi] into the eax
register, then increments the esi (by 4) pointer for you - esi is called the (extended) source index register

similarly, if you use the STOSD instruction, it stores the value in eax to [edi], then increments the
edi register (by 4) for you - edi is called the (extended) destination index register

if you use the MOVSD instruction, it moves the dword at [esi] to [edi], then increments both esi and edi by 4

in all these examples, i have indicated that the registers increment - that assumes that the direction flag (DF)
is cleared or 0 - if the direction flag is set (or 1), the registers are decremented by the target size, rather than
incremented
cld - clear direction flag (up)
std - set direction flag (down)

SEE ALSO: REP, CMPS, SCAS

AgentSmithers

Thanks this is was I was looking for!

rags

From a previous locked topic:
QuoteI was not asking how to Hack with ASM, You assumed, My Question was simple on Adding Addeses together.
Wasn't he just given the answer to the locked topic?
God made Man, but the monkey applied the glue -DEVO

dedndave

this was a simple programming question
the information given is available thousands of places on the web
actually, if you look at the locked topic - this is not related

he has been admonished for attempting to ask about hacking in here
we don't need to train him to become elusive in the manner questions are asked

if that means he can't ask any questions at all, then his ID would have been purged, as well
and - his IPA could even be banned from the site to prevent him from making a new ID

my hope is, that by the time he becomes proficient enough to write meaningful software,
he will realize that time spent "hacking" generally pays $0, while
time spent writing productive code can put money in the pocket

i think we all know that you don't go from newbie to "hacker" overnight

UtillMasm

my english is better than this man.
:dance:

AgentSmithers

Well if we are still into that topic I'm a God at VC++6 and Vb.net and I know Network Security verry well, Arp Posing ICMP redirects, Wep cracking, Im not a noob at security, But what im trying to point out is I was not asking you guys to teach me how to hack, it was a tiny sniplet and you guys all assumed. I did not think you guys would get offended by such content due to the fact is was about 30 lines of code and all it did was really generate random strings. I'm sorry lets leave it behind us, I feel like its people are chasing after my name in threads...

AgentSmithers

Quote from: dedndave on May 24, 2009, 11:19:55 PM

MyVar dd ?      ;5 elements in the array
         dd ?      ;each element is a double-word
         dd ?      ;a double-word (dword) is 4 bytes
         dd ?      ;dd stands for define dword
         dd ?

.code
;
; do stuff
;
mov esi, offset MyVar   ;start at the beginning
mov ecx,5                 ;count register (5 elements in the array)

loop01:
;
; do stuff
;
  add esi,4      ;point to next element (each element is 4 bytes long)
;
; do more stuff
;
  loop loop01


EDIT - one thing to note - if you use the LODSD instruction, it loads the value at [esi] into the eax
register, then increments the esi (by 4) pointer for you - esi is called the (extended) source index register

similarly, if you use the STOSD instruction, it stores the value in eax to [edi], then increments the
edi register (by 4) for you - edi is called the (extended) destination index register

if you use the MOVSD instruction, it moves the dword at [esi] to [edi], then increments both esi and edi by 4

in all these examples, i have indicated that the registers increment - that assumes that the direction flag (DF)
is cleared or 0 - if the direction flag is set (or 1), the registers are decremented by the target size, rather than
incremented
cld - clear direction flag (up)
std - set direction flag (down)

SEE ALSO: REP, CMPS, SCAS

By default does masm like to decrement due to speed, I know other processors such as RISC Architectures counted down faster?

What does LOSB stand for? "Load Single Byte"??

So is LOSB verry register depended everything has to be placed in the right register to have this function correctly and the output is always put in the cordinating registers?
Do you got a list of the Acronyms that masm uses? (ex.  Mov = Move Sub = Subtract LOSB = "Load Single Byte")
I think It will help me remember all the meanings and such.

Right now Im currently reading http://doc.ddart.net/asm/Microsoft_MASM_Programmers_Guide_v6.1/Chap_05.htm and just wanted to confirm.

dedndave

well - there are a lot of assembly language mnemonics - and a lot of instructions
LODS is load string
LODSB - byte
LODSW - word
LODSD - dword

STOS, CMPS, SCAS are similar "string" instructions and REP, REPZ, REPNZ are prefixes used with them to repeat
they are dependant primarily on ESI and EDI registers and the DF
if REP is used, the ECX register holds the count

what you need is a list of the pentium instruction set
you can find it hundreds of places with google - Intel is a good source for material, of course
the first step to learning assembler is to learn the processor, itself
learn how it works inside - registers - flags - all that
once you understand the processor basics, you will want to begin memorizing the instruction set
the best way is to try using each one in a program - that will keep you busy for a while

once you know what the processor can do, you will want to learn the windows API function calls
there are more function calls than there are x86 instructions - so - that will keep you busy for another while
if you are proficient in C, you will already be familiar with the API calls
i am a n00b, myself

Mark Jones

AgentSmithers, you might like this forum better. Lots more "free thinking" going on over there.

When you want to learn programming proper, we'll still be here.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08