flat assembler
Message board for the users of flat assembler.

 Index > Heap > Stupid assembly math :-D Goto page 1, 2  Next
Author
THEWizardGenius

Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
The FPU has infinity, so why can't the integer CPU? Here's some code for calculating infinity (note that you will need a very fast processor for this or else it will take a long time! ):

.spot:
inc eax
jmp .spot

And here's how to multply infinity by n:

.spot
inc eax
jmp .spot
mov ebx,n
mul ebx

And here's infinity to the infinity power:

.spota:
inc eax
jmp .spot
mov ebx, eax
mov ecx, eax
.spotb:
mul ebx
loop .spotb

There might be a more efficient way of doing the last example, I'm not sure. But now you can finally calculate infinity.

_________________
FASM Rules!
OS Dev is fun!
Pepsi tastes nasty!
Some ants toot!
It's over!
07 Jul 2005, 18:45
decard

Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
It could really calculate infinity, if only registers had infinite number of bits
07 Jul 2005, 19:04
THEWizardGenius

Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
Yeah exactly... and if you had a LOT of time on your hands
07 Jul 2005, 19:22
smiddy

Joined: 31 Oct 2004
Posts: 559
smiddy
Isn't this infinity?

Code:
```   mov eax,1
mov ebx,0
div ebx
```

This places an exception on your CPU, which actually tells you you've hit infinity, and its very fast too.
09 Jul 2005, 11:45
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
Let's check it:
Code:
```mov eax,1
mov ebx,0
div ebx
@@:
inc ecx
jmp @b
cmp eax,ecx
je yeah    ```

When the program finishes, we will know.
09 Jul 2005, 12:28
smiddy

Joined: 31 Oct 2004
Posts: 559
smiddy
That's even better Tomasz!
09 Jul 2005, 15:15
MCD

Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
Yeah, but you should have placed the infinity-checking in the "integer divideby 0"-exception handler, because this is where it will land...
11 Jul 2005, 11:49
smiddy

Joined: 31 Oct 2004
Posts: 559
smiddy
Uhm, MCD, uhm, that's the point silly. [Read: Stupid math assembly]
11 Jul 2005, 12:05
MCD

Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
smiddy wrote:
Uhm, MCD, uhm, that's the point silly. [Read: Stupid math assembly]
I know
11 Jul 2005, 12:45
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
as true mathematicans, we must first DEFINE zero before we can use it:
Code:
```mov eax,1
dec eax
```

but we of course need to have defined 1 to define 0. But we can define 1 just like we did with 0, with "mov eax,2". We need to have 2 defined and so on, until, at the end (you will know when it comes) we reach infinte, which we alredy have defined.
And so we have precisely-deductive definition (i don't know what's it's right name in english) of whole number scale 0 to infinte. And they say methamathics is just some theoretical good-for-nothing crap, ha...
11 Jul 2005, 13:53
smiddy

Joined: 31 Oct 2004
Posts: 559
smiddy
Isn't it the limit as the denominator approaches 0? So 1/0 ≈ 1/.0000000000000000000000000000000000001

Because, really, not dividing it is exactly 0 times, then it would be 1, using that logic.

And then there is 0/0, what is that. L^hopital <I can't remember, is that how it is spelled?> must have been smoking some good stuff that day.
11 Jul 2005, 14:30
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
smiddy, that was a stupid idea, now we don't have wrapped text.

PS: As I discovered later the button to send quick message is too far right too
11 Jul 2005, 15:58
THEWizardGenius

Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
I wonder what infinity-1 is?
Code:
```@@:
inc eax
jmp @b
dec eax
```
11 Jul 2005, 19:26
smiddy

Joined: 31 Oct 2004
Posts: 559
smiddy
Whoops! Sorry, I'm a dork! But hey, stupid math, stupid smiddy, stupid denominator.
11 Jul 2005, 23:30
donkey7

Joined: 31 Jan 2005
Posts: 127
Location: Poland, Malopolska
donkey7
try:
Code:
```INFINITY = 1/0
mov eax,INFINITY
```

But FASM writes 'value out of range'. Can someone fix this error?
12 Jul 2005, 15:31
smiddy

Joined: 31 Oct 2004
Posts: 559
smiddy
That was a good one donkey7!

That means FASM can't see infinity, not yet.
12 Jul 2005, 17:32
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i believe tomasz will make some macro for it using new macroabilities
12 Jul 2005, 18:35
smiddy

Joined: 31 Oct 2004
Posts: 559
smiddy
Macroabilities, to see from infinity and beyond.
12 Jul 2005, 20:17
THEWizardGenius

Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
Infinity, by Intel standards, is probably the greatest possible number plus one.
So, you could say infinity = 0xFFFFFFFF + 0x1 = 0
So, infinity = 0, and surely FASM can see 0?
12 Jul 2005, 21:07
vid
Verbosity in development

Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
THEWizardGenius: You was almost right, except one little fact. But thanks to you world now knows answer to one of greatest math questions ever: What is infinity? If we take 0 as nothing (speaking about infinity we should use philosphical terms), then we can state that
"Inifity is nothing, with carry flag set"

PS: Smiddy, I hate you, "Submit" button is sooooooooooooooooooooooooooooooooooooo far away
12 Jul 2005, 21:42
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area
Goto page 1, 2  Next

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum