Welcome to קודגורו Sign in | Join | Faq

אקסטרים

Started by ofri at 02-26-2011 4:50. Topic has 1 replies.

Print Search
Sort Posts:    
   02-26-2011, 4:50
ofri is not online. Last active: 2/26/2011 6:47:55 PM ofri

Top 150 Posts
Joined on 02-26-2011
Posts 1
שימוש בשני שורדים
מישהו יכול לתת לי דוגמא איך להשתמש בשני שורדים? לא הבנתי איך להשתמש בES.
תודה

   Report 
   03-11-2011, 13:07
GalDor is not online. Last active: 1/9/2012 2:33:56 AM GalDor

Top 10 Posts
Joined on 09-09-2008
Posts 48
Re: שימוש בשני שורדים
The basic thing is this: each team is allocated a segment (usually something like 0x2000) which only they can access. In other words, if XLII1 tries to write to 0x2000:0x0100 he succeeds, if XLII2 tries to read that byte he will also succeed, but if FSM1 tries to do so he will die from memory error.

The value of that shared segment is initially given to your survivors in the ES register. That is, in the example above, the initial value of ES for XLII1 and XLII2 would be 0x2000, but for FSM1 it could be something like 0x2100.

An example for such a thing is the following. In this example, survivor1 saves the address of a part of its code in the shared segment, and survivor2 reads that address and goes there. This way, both survivors are next to each other.
;;;;;;;;;;;;;;;;;;;;;survivor1;;;;;;;;;;;;;;;;;;;;;
@start:
add ax, @code2-@start ;ax now contains the address of @code2
stosw  ;this stores ax in the address: ES:DI. DI is initialized to 0, so that address is: ES:0000. Note that we do
           ;not  know the actual value of ES (we don't know if it is 0x2000 or 0x2100) but this does not matter, since
           ;survivor2 will have the same value in ES.
@code1:
;This will be run by survivor1
;Do stuff here
@code2:
;This will be run by survivor2
;Do stuff here

;;;;;;;;;;;;;;;;;;;;;survivor2;;;;;;;;;;;;;;;;;;;;;
push es
pop ds ;DS now points to the shared segment. We don't know in advance what that value is, but we do know
            ;that survivor1 receives the same value.
lodsw   ;This loads the value at DS:SI to ax. But, SI is initialized to 0, so it loads: DS:0000 to ax. Since DS is
            ;pointing to the private segment, this is the same address where survivor1 stored the address of
            ;@code2. So, now ax is the address of @code2 (in survivor1's code!).
jmp ax ;This jumps to wherever ax points at. In this case, to @code2.

----------------------------------
Have you heard about the new Cray super computer? It’s so fast, it executes an infinite loop in 6 seconds.
   Report 
קודגורו » פורומים » אקסטרים » Re: שימוש בשני שורדים

Powered by Community Server, by Telligent Systems