Math Quickie [TI-ASM]

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Math Quickie [TI-ASM]

Post by thegamefreak0134 »

Two questions:

How do you divide in asm? Really, I think I only need to divide by 100, because I can shift for most of the other calculations.

How do you take a square root? This doesn't have to be fast or anything, and I'm actually shooting for size. I just don't really know how to do this as all. I would just use a bios call, but alas! My ops are currently tied up for storage stuff and can't be used. Darn.

Thanks if you can help.

-gamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

This is totally awesome. It has, like, everything that has ever bugged me ever on a calc in asm. This should make my formula work muuuuch easier. Thanks! (how long has this been here that I haven't known about it? Who knows...)

It doesn't go into square roots, which is still a problem, as I need them to deal with StatEXP properly. I need to take thesquare root of a 16-bit number and output it somewhere. I really need it to go into the lower half of a 16-bit register, because although the biggest number the routine can output is 255, I have to go off and increment that. (although I could just check it and load the value at that point...) I can't even work through how to tae a square root in BASIC (or on paper for that matter) without using the built in function.

BTW, this will not be used very often, so speed is of no concern. In fact, size is of much bigger concern.

Thanks!

-gamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
CoBB
MCF Legend
Posts: 1601
Joined: Mon 20 Dec, 2004 8:45 am
Location: Budapest, Absurdistan
Contact:

Post by CoBB »

This is a newer version of the same page, square root discussion included:

http://baze.au.com/misc/z80bits.html
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

Ah, thanks. I knew there was a more up-to-date page, just couldn't find it :\
User avatar
Jim e
Calc King
Posts: 2457
Joined: Sun 26 Dec, 2004 5:27 am
Location: SXIOPO = Infinite lives for both players
Contact:

Post by Jim e »

For Square roots I put this up on the wiki.
http://wikiti.denglend.net/index.php?ti ... quare_root

I have to read cobbs though.
Image
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

Just one quick question: Does "unrolling" a piece of code mean to repeat it a certain number of times?
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

ld b,3
loop:
inc a
djnz loop

unrolled would be

inc a
inc a
inc a

so, yes.
User avatar
thegamefreak0134
Extreme Poster
Posts: 455
Joined: Mon 23 Jan, 2006 10:09 pm
Location: In front of a Computer, coding
Contact:

Post by thegamefreak0134 »

Cool. OK, provided I get this to work (shouldn't be too dificult) I'll be designing the pokemon data arrays per pokemon and will likely be working on stat pages, with the exception that everything will be re-calculated in these versions rather than simply displaying a pre-calculated stat like the actual game will do (to be faithful and all.) I'll even make a little feature that, based on status and stats and whatnot, shows the min and max ammounts of damage a given pokemon's attack will do to another pokemon in your party. All of this was being hindered by a stupid divide operation. Thanks a million y'all!

-gamefreak
I'm not mad, just a little crazy.

DarkNova - a little side project I run.
Post Reply