mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Programming (https://www.mersenneforum.org/forumdisplay.php?f=29)
-   -   asm trouble (https://www.mersenneforum.org/showthread.php?t=13984)

science_man_88 2010-09-27 17:35

asm trouble
 
I've tried iczelion tutorial for message box it works. I try adding mov(ax,1) it tells me I missed the right parenthesis and if i just try his basic outline it assembles fine but I goto check it out and it tells me it's not win32. any help i have books but I don't understand why i can't get mov(ax,1) to work. if i could maybe it's a start lol. I'm on a intel pentium d processor.

Robert Holmes 2010-09-27 21:05

You're using MASM? There's no need for parenthesis. It's just MOV (E)AX, 1.

science_man_88 2010-09-27 21:10

[QUOTE=Robert Holmes;231669]You're using MASM? There's no need for parenthesis. It's just MOV (E)AX, 1.[/QUOTE]

sorry long time no use lol.

though your very helpful so stick around lol.

science_man_88 2010-09-28 16:09

once I got one thing working I remember that I made this code before lol.


[CODE]include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start:
mov eax,9h
MsgBox 0, str$(eax), addr AppName, MB_OK
exit

end start[/CODE]

quite nice too bad I suck at thinking of ways to implement LL test though I think I could still do it, then I could just use this to print the ones that are prime lol maybe this is a job for f2xml(ST0) if we can make it calculate it with ST0 out of range maybe this would be of use lol.

CRGreathouse 2010-09-28 17:21

[QUOTE=science_man_88;231777]quite nice too bad I suck at thinking of ways to implement LL test though I think I could still do it[/QUOTE]

One step at a time! :smile:

You want to take numbers below, say, a billion and check if they're exponents of Mersenne numbers. The first natural step would be to test if the number is prime. For numbers this size, trial division is reasonable. Can you program that in assembly?

science_man_88 2010-09-28 17:36

I know the book I has breaks thing down to the parts that make up loops etc. and then talks of knowing your data as it's rarely random.

if possible conditional jumps should be used minimally.

to be prime it can't be a power and has to be of form 6n+1/-1 if above 3

so inc(eax) is useful in groups of 2 or 4

counting down is more efficient if I read the book correct.

checking for 6n+1 doesn't seem hard unless you put the limit on jumps to me. be nice if we could make a table of equivalent codes between languages so I could possibly turn Pari Codes into asm etc.

science_man_88 2010-09-28 17:37

yeah that would be a 2 variable operation one the exponent you want to test and 2 the number to divide it by also as we go could we not push it on the stack to make an array of primes found along the way.

bsquared 2010-09-28 17:44

[QUOTE=CRGreathouse;231785]One step at a time!
[/QUOTE]

Indeed, but the first step, IMO, should not be assembly at all! I realize that assembly language has the great lure of speed, but speed gains can typically only be realized with *extensive* knowledge of the underlying hardware... something yet to be demonstrated.

Why anyone would want to burden themselves with assembly language syntax/tools for anything but the most critical loops of code is beyond me. A msgbox... in ASM... really??

science_man_88 2010-09-28 17:47

win32 asm

anyway maybe something I can learn from asm I can carry into something else.

[CODE]include \masm32\include\masm32rt.inc

.code
AppName db "Masm32:", 0

start:
mov eax,7
[COLOR="Red"]imod 6,edx:eax[/COLOR]
cmp edx,1
jne bust
MsgBox 0, str$(eax), addr AppName, MB_OK
exit
bust:
end bust
end start[/CODE]

I get this error when i try to assemble.

[QUOTE]C:\masm32\try5.asm(8) : error A2008: syntax error : integer[/QUOTE]

CRGreathouse 2010-09-28 20:12

[QUOTE=bsquared;231792]Indeed, but the first step, IMO, should not be assembly at all![/QUOTE]

Yes, I of course agree... but if the goal is to learn asm, then let him learn asm!

alpertron 2010-09-28 20:56

You should replace the instruction you marked in red by:

xor edx,edx
mov ebx,6
div ebx

Then you have the quotient in EAX and the remainder in EDX.


All times are UTC. The time now is 04:39.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.