• Axe Q&A 5 5
Currently:  

Author Topic: Axe Q&A  (Read 588245 times)

0 Members and 1 Guest are viewing this topic.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #60 on: February 18, 2011, 07:11:51 pm »
Whoops, not sure how those sub's got in there... I fixed both blocks of code now.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #61 on: February 18, 2011, 07:13:36 pm »
Lol ok
I was asking partly because I think I've seen similar uses of sub( , but they were probably just hl abuse :P
Vy'o'us pleorsdti thl'e gjaemue

Offline ee511

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #62 on: February 18, 2011, 07:39:47 pm »
hello fellow axe-ers. I am trying to create some code that uses the "sin(" function, but when the value should be negative, it turns up a really big number like 65000 or so. Help!  :mad:

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #63 on: February 18, 2011, 07:48:37 pm »
Welcome to Omnimaga, ee511!

In Axe, negative numbers are the same as "really big numbers". Everything above the value 32,767 is treated as a negative number. (See the Axe guide for details.)

The only thing that makes any difference is how you treat a number. Try drawing a sprite at y-value 65,535, then draw it at y-value -1. It's exactly the same :)




Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #64 on: February 18, 2011, 07:50:19 pm »
I kinda wondered about that...is there a way to force axe to see it as a negative number i.e. when using Disp ?
Vy'o'us pleorsdti thl'e gjaemue

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #65 on: February 18, 2011, 07:51:20 pm »
I kinda wondered about that...is there a way to force axe to see it as a negative number i.e. when using Disp ?

It's exactly the same. The only reason Disp >Dec displays it unsigned (large number) is because the OS routine that displays numbers treats it that way. There's no routine to display a negative, unfortunately.
« Last Edit: February 18, 2011, 07:51:29 pm by Deep Thought »




Offline ee511

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #66 on: February 18, 2011, 07:52:35 pm »
but in calculations, how can i make it be treated as a negative number?

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #67 on: February 18, 2011, 07:54:13 pm »
Addition/subtraction work fine, // does signed division, idk about multiplication tho...it's something weird about high/low order bits or something.
« Last Edit: February 18, 2011, 07:54:39 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #68 on: February 18, 2011, 07:55:43 pm »
Well, it's sort of weird. When you're adding, subtracting, or multiplying, it's exactly the same. 65530-5 and -6-5 both result in the same value, for example. But when it comes to division, there are two forms: signed and unsigned. That's when you get to decide which it is. Use / for unsigned division, and // for signed division.




Ashbad

  • Guest
Re: Axe Q&A
« Reply #69 on: February 18, 2011, 07:56:03 pm »
when using the Sin( function, depending on where it is used you can use the Sign{ command to convert a "Normal" negative number into input the function can read in the right context.  Since -1 == 65535 in axe (if you're using a general purpose variables [all of which are 16 bit] such as vars A-Z and Theta)  then the Sin( is calculating the sin of 65535.  at least methinks.  Even if it is doing it correctly, a Sign{ function never hurts, I know that for sure.

also one way you can tell a positive number/negative number is by the highest bit -- if it is set, and you're treating the number as a signed value, then it's negative.  Thing is, if you're treating it unsigned, all numbers (except 0) are positive -- and like DT said it's the usage that matters, not the high bit.  So, in axe,  5 plus -1 actually reads as 5 plus 65535, the 16 bit equivalent.    the thing is, when you add those two numbers, you reach a number that cannot fit inside a 16 bit space -- so it loops it back to zero and adds the rest.  So, 5 plus 65535 comes out with 4.  Easy to understand?  Not a chance if you didn't already know some of the concept, but I'm sure you'll get the hang of the concept eventually.

also welcome :)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #70 on: February 18, 2011, 07:57:51 pm »
when using the Sin( function, depending on where it is used you can use the Sign{ command to convert a "Normal" negative number into input the function can read in the right context.  Since -1 == 65535 in axe (if you're using a general purpose variables [all of which are 16 bit] such as vars A-Z and Theta)  then the Sin( is calculating the sin of 65535.  at least methinks.  Even if it is doing it correctly, a Sign{ function never hurts, I know that for sure.

No, DON'T use sign{! sign{ is only used to get a signed value from a pointer. If you use it on a value you already have, you will end up with some random number you don't need.
« Last Edit: February 18, 2011, 07:58:17 pm by Deep Thought »




Ashbad

  • Guest
Re: Axe Q&A
« Reply #71 on: February 18, 2011, 08:00:08 pm »
ahh, I see.  my bad, disregard that part from my little speech.  Though the second part will go unchallenged I'm sure :)

anyways it's just that It's been a while since I even touched the Sin( command in axe, and I wasn't really thinking while I was posting and while I was posting I was both eating and taking a dump at the same time and... [/excuse]

Offline ee511

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +0/-0
    • View Profile
Re: Axe Q&A
« Reply #72 on: February 18, 2011, 08:07:16 pm »
ummmm... ok. i sorta get it. well fortunately, i won't be dealing with anything over 65535, unless its negative. but in the event that it i do have to deal with the sin( of a negative number, is there some way to get a pointer to the ram where the A-Z and Theta variables are stored? (or even better, the pointer to a specific variable.)

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #73 on: February 18, 2011, 08:18:49 pm »
ummmm... ok. i sorta get it. well fortunately, i won't be dealing with anything over 65535, unless its negative. but in the event that it i do have to deal with the sin( of a negative number, is there some way to get a pointer to the ram where the A-Z and Theta variables are stored? (or even better, the pointer to a specific variable.)

Hmm, why would you need the pointer? If you need to get the signed value, know that just using a var like A-Z and theta, it's already in the right format for both signed and unsigned.




Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #74 on: February 18, 2011, 08:21:54 pm »
You definitely won't be dealing with anything over 65535, because the calculator is physically incapable of storing a number larger than that in its 16-bit registers. When it comes down to signs, the only difference between an unsigned and a signed number is just how you interpret the number. ⁻1 and 65535 are stored exactly the same on the calculator. It has no idea if it should be unsigned or signed. The only thing that "makes" a number signed is if you treat it as so.

The sin() function is periodic, meaning that for every 256 input values, it loops back around to where it started. For example, sin(254) would return the same result as sin(510) or sin(⁻2) (which is the same exact thing as sin(65534)), so you don't even have to worry about negative inputs.

Regarding the locations of variables in RAM, you can find the pointer to any variable by prefixing the variable with a degree symbol, such as °A. There are 27 2-byte variables, and they are stored in a contiguous 54-byte section of RAM in the order A,B,C,...,Z,θ. The variables start, by default, at the hexadecimal location $89B6 in RAM, which is equal to L1+714.
« Last Edit: February 18, 2011, 08:24:58 pm by Runer112 »