flat assembler
Message board for the users of flat assembler.

Index > Heap > Stupid assembly math :-D

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
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! Laughing ):

.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. Laughing

_________________
FASM Rules!
OS Dev is fun!
Pepsi tastes nasty!
Some ants toot!
It's over!
Post 07 Jul 2005, 18:45
View user's profile Send private message AIM Address Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
It could really calculate infinity, if only registers had infinite number of bits Smile
Post 07 Jul 2005, 19:04
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
Yeah exactly... and if you had a LOT of time on your hands Laughing
Post 07 Jul 2005, 19:22
View user's profile Send private message AIM Address Reply with quote
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. Wink
Post 09 Jul 2005, 11:45
View user's profile Send private message Reply with quote
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. Wink
Post 09 Jul 2005, 12:28
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
That's even better Tomasz! Very Happy
Post 09 Jul 2005, 15:15
View user's profile Send private message Reply with quote
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...
Post 11 Jul 2005, 11:49
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Uhm, MCD, uhm, that's the point silly. Wink [Read: Stupid math assembly]
Post 11 Jul 2005, 12:05
View user's profile Send private message Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 604
Location: Germany
MCD
smiddy wrote:
Uhm, MCD, uhm, that's the point silly. Wink [Read: Stupid math assembly]
I know Cool
Post 11 Jul 2005, 12:45
View user's profile Send private message Reply with quote
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...
Post 11 Jul 2005, 13:53
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
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. Wink
Post 11 Jul 2005, 14:30
View user's profile Send private message Reply with quote
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 Smile
Post 11 Jul 2005, 15:58
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
I wonder what infinity-1 is?
Code:
@@:
inc eax
jmp @b
dec eax
    
Post 11 Jul 2005, 19:26
View user's profile Send private message AIM Address Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Whoops! Sorry, I'm a dork! But hey, stupid math, stupid smiddy, stupid denominator. Razz
Post 11 Jul 2005, 23:30
View user's profile Send private message Reply with quote
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? Wink
Post 12 Jul 2005, 15:31
View user's profile Send private message Visit poster's website Reply with quote
smiddy



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

That means FASM can't see infinity, not yet. Wink
Post 12 Jul 2005, 17:32
View user's profile Send private message Reply with quote
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 Very Happy
Post 12 Jul 2005, 18:35
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Macroabilities, to see from infinity and beyond. Laughing
Post 12 Jul 2005, 20:17
View user's profile Send private message Reply with quote
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?
Post 12 Jul 2005, 21:07
View user's profile Send private message AIM Address Reply with quote
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
Wink
Post 12 Jul 2005, 21:42
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.