flat assembler
Message board for the users of flat assembler.
Index
> Windows > mod operator help |
Author |
|
dxl 02 Aug 2008, 19:36
a thread has its own stack and you have to assume registers are different in the thread i mean, if you didnt set them IN THE THREAD you cannot rely on their values.
Generally the problem occurs with ebp. Prototype for CreateThread: HANDLE WINAPI CreateThread( __in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes, __in SIZE_T dwStackSize, __in LPTHREAD_START_ROUTINE lpStartAddress, __in_opt LPVOID lpParameter, __in DWORD dwCreationFlags, __out_opt LPDWORD lpThreadId ); If i read well, your [ThreadId] is probably not correct if you expect the thread id to be returned in the dword place in memory called ThreadId. Don't use [] |
|||
02 Aug 2008, 19:36 |
|
dxl 02 Aug 2008, 19:51
Example of MOD programming
Routine to compute (seed*A) MOD M (32 bits numbers) after execution eax contains this value. prototype: int rand(int) rand: M equ 7fffffffh ;2^31-1 seed equ dword [ebp+8] A equ 16807 push ebp mov ebp,esp push edx ebx mov eax,A xor edx,edx ;clear edx mul seed ;edx:eax<-seed*A mov ebx,M div ebx ;edx<-(seed*A) mod M mov eax,edx pop ebx edx mov esp,ebp pop ebp ret 4 ;don't forget it! Routine used in a Linear congruential generator. |
|||
02 Aug 2008, 19:51 |
|
swight 03 Aug 2008, 13:36
I fixed the brackets,didn't change anything since I wasn't using that handle(just following a tutorial).think div may be working, it just causes a crash on thread exit. replaced div with a subtraction loop and it runs without crashing.
|
|||
03 Aug 2008, 13:36 |
|
Yardman 03 Aug 2008, 17:28
[ Post removed by author. ]
Last edited by Yardman on 04 Apr 2012, 03:23; edited 1 time in total |
|||
03 Aug 2008, 17:28 |
|
swight 04 Aug 2008, 01:21
that proc worked for me I will have to analyze later what I was doing wrong.
|
|||
04 Aug 2008, 01:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.