Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
23 May, 2013, 22:50:50 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 ... 98 99 [100] 101 102 ... 110   Go Down
  Print  
Author Topic: Axe Q&A -  (Read 59488 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
parserp
Hero Extraordinaire
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 22:55:20
Date Registered: 08 September, 2011, 02:01:43
Location: Here.
Posts: 1421


Total Post Ratings: +80

View Profile WWW
« Reply #1485 on: 07 May, 2012, 21:45:10 »
0

If I have 8 chars stored in L1, and I want to copy them to str0+1, the following code works in a normal program, but not in an app.

1
2
:Copy(L1,Str0+1,8)

Why is that?
Logged

ticalc.org | Cemetech | TI-Freakware | casiocalc.org

My New Website!
Spoiler for The Rest:



A useful tool
Spoiler for bands:
Five Finger Death Punch
Disturbed
Slipknot
Linkin Park
Avenged Sevenfold
Breaking Benjamin
Skillet
30 Seconds to Mars
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 21:51:10
Date Registered: 02 July, 2009, 06:38:05
Posts: 1680


Total Post Ratings: +493

View Profile
« Reply #1486 on: 07 May, 2012, 21:59:16 »
+1

I'm guessing you are defining Str0 to be a pointer to a block of data set aside inside of your executable, perhaps like this:

Buff(10)→Str0

This works fine for programs, as they are run from RAM so the 10-byte block of data is contained inside of the program in RAM. But applications are run from ROM, which you probably know stands for read-only memory. And as the name suggests, you cannot* write data to ROM, so attempting to write data back to Str0, which is part of your application in ROM, will fail.

The solution for applications is to use a section of safe RAM or an appvar to hold any data that will be modified.


* Data can be written to ROM, but it's through a complicated method of interfacing with the flash chip that usually involves backing up a whole 64KB of data, erasing the original 64KB of data, and then copying the 64KB back to its original location with the desired changes made.
« Last Edit: 07 May, 2012, 22:02:21 by Runer112 » Logged
parserp
Hero Extraordinaire
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: Yesterday at 22:55:20
Date Registered: 08 September, 2011, 02:01:43
Location: Here.
Posts: 1421


Total Post Ratings: +80

View Profile WWW
« Reply #1487 on: 07 May, 2012, 22:10:27 »
0

shocked That is exactly what I was doing. Now it makes sense. Thanks! Cheesy
Spoiler for Hidden:
* parser padwan nominates Runer112 the official omnimaga mind reader Tongue
« Last Edit: 07 May, 2012, 22:10:50 by parser padwan » Logged

ticalc.org | Cemetech | TI-Freakware | casiocalc.org

My New Website!
Spoiler for The Rest:



A useful tool
Spoiler for bands:
Five Finger Death Punch
Disturbed
Slipknot
Linkin Park
Avenged Sevenfold
Breaking Benjamin
Skillet
30 Seconds to Mars
Hayleia
Programming Absol
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Last Login: Today at 19:39:26
Date Registered: 01 June, 2011, 20:12:47
Location: ud-ud ?
Posts: 2055


Total Post Ratings: +256

View Profile
« Reply #1488 on: 08 May, 2012, 07:47:21 »
0

Me again, with my conditional comments Tongue
The problem with ending a conditional comment with "..." is that if I do the code 1 (below), the parser would understand the code 2 (below)

     Code 1:
code
...If Const
code
...
code
...
code
...
etc

     Code 2:
code
...If Const
code
...
code
...
code
...
etc

If the conditional comment ended with "...End", the parser would know the difference between a beginning and an end.
So would it be possible to change this in Axe, so that we end a conditional comment with "...End" ?
« Last Edit: 11 May, 2012, 20:13:59 by Hayleia » Logged





Spoiler for what I am according to...:
me: useless
Pokemon Test: an Absol
turiqwalrus: an eggplant
p2: A HUMAN BEING !
Blackpilar and p2: iplantonlyplantwantplanttoplantknowplantifplantyouplantareplantaplantboyplantorplantaplantgirlplant
click here to know where you got your last +1s
C0deH4cker
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 19 December, 2012, 22:22:42
Date Registered: 18 October, 2011, 23:19:08
Location: $9D95
Posts: 258


Total Post Ratings: +10

View Profile WWW
« Reply #1489 on: 15 May, 2012, 01:21:27 »
0

Can recursive functions be created in Axe? Like a simple fibonacci sequence generator or factorial function?
Logged

Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: Today at 03:56:01
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7813


Total Post Ratings: +706

View Profile WWW
« Reply #1490 on: 15 May, 2012, 04:11:25 »
0

You can, but it's not recommended because each nested call takes space on the stack, and going too deep leaves you with a nice stack overflow.
Logged




C0deH4cker
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 19 December, 2012, 22:22:42
Date Registered: 18 October, 2011, 23:19:08
Location: $9D95
Posts: 258


Total Post Ratings: +10

View Profile WWW
« Reply #1491 on: 15 May, 2012, 05:28:07 »
0

For some reason, even a simple factorial program did not work correctly for me.


1
2
3
4
5
6
Lbl Fact
If r1 <= 1
1:Return
End
r1*Fact(r1-1):Return

Can somebody post a working sample?
« Last Edit: 15 May, 2012, 05:28:26 by C0deH4cker » Logged

Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: Today at 03:56:01
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7813


Total Post Ratings: +706

View Profile WWW
« Reply #1492 on: 15 May, 2012, 06:11:39 »
0

How big are the numbers you're testing with?

EDIT: In your code, r1 gets overwritten. You need to call FACT as sub(FACTr,r1-1).
« Last Edit: 15 May, 2012, 06:13:08 by Deep Thought » Logged




Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 21:51:10
Date Registered: 02 July, 2009, 06:38:05
Posts: 1680


Total Post Ratings: +493

View Profile
« Reply #1493 on: 15 May, 2012, 06:45:58 »
+1

For some reason, even a simple factorial program did not work correctly for me.


1
2
3
4
5
6
Lbl Fact
If r1 <= 1
1:Return
End
r1*Fact(r1-1):Return

Can somebody post a working sample?

Your routine worked fine for me. Smiley Just note that, for factorials of numbers larger than 8, the calculation will overflow so the result returned will be incorrect.

EDIT: In your code, r1 gets overwritten. You need to call FACT as sub(FACTr,r1-1).

Actually this is not the case. Once *Fact( is reached, the first r1 has already been pushed onto the stack.



And because I can't resist optimizing, here is a very optimized recursive factorial function I came up with, weighing in at 17 bytes. Grin


1
2
3
4
5
6
Lbl Fact
!If
Return +1
End
Return *(-1Fact())
Logged
C0deH4cker
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 19 December, 2012, 22:22:42
Date Registered: 18 October, 2011, 23:19:08
Location: $9D95
Posts: 258


Total Post Ratings: +10

View Profile WWW
« Reply #1494 on: 15 May, 2012, 21:48:52 »
0

Lol thanks! And youre right, my way did work, but i was typing it on here from memory and also working it out in my head when i typed it, so i typed a correct version instead.


My Fibonacci program just causes a RAM Clear, probably due to a stack overflow. Z80 processors aren't very good with recursion, are they?
Logged

Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 20:30:28
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #1495 on: 15 May, 2012, 22:08:47 »
0

They are fine with recursion, it just takes a lot of memory the way Axe does it, since it backs up all 6 variables each time you call the routine
Logged

Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 21:51:10
Date Registered: 02 July, 2009, 06:38:05
Posts: 1680


Total Post Ratings: +493

View Profile
« Reply #1496 on: 15 May, 2012, 22:26:09 »
0

They are fine with recursion, it just takes a lot of memory the way Axe does it, since it backs up all 6 variables each time you call the routine

Nope, Axe only backs up the function variables that you would overwrite with the call. So something like sub(LBLr,A) only pushes 2 words onto the stack, the previous value of r1 and the return address (required for any function call).

My Fibonacci program just causes a RAM Clear, probably due to a stack overflow. Z80 processors aren't very good with recursion, are they?

That depends how deep you need to recurse. The OS has allocated 400 bytes for the stack, which gives you space for 200 stack entries. You can expect about 20 of these to be in use when your program is run, so you have an allowance of roughly 180 stack entries. That's about 90 recursive calls with one argument, 60 recursive calls with two arguments, etc. So as long as you don't overflow the stack, the z80 is fine at recursion. Overflow the stack, and expect a RAM clear.
Logged
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 20:30:28
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #1497 on: 15 May, 2012, 22:31:55 »
0

Oh that's good!  However, some functions like fibonacci might be easy to implement with recursion, but they they are incredibly inefficient >.<
Logged

C0deH4cker
LV5 Advanced (Next: 300)
*****
Offline Offline

Gender: Male
Last Login: 19 December, 2012, 22:22:42
Date Registered: 18 October, 2011, 23:19:08
Location: $9D95
Posts: 258


Total Post Ratings: +10

View Profile WWW
« Reply #1498 on: 17 May, 2012, 04:50:35 »
0

Yeah. I could easily write it without recursion (I wrote a fibonacci function in asm before), but recursion is just easier, and I think it is more fun due to the different method of thinking required for programming recursively.
Logged

piston
LV0 Newcomer (Next: 5)

Offline Offline

Last Login: 25 May, 2012, 18:10:44
Date Registered: 25 May, 2012, 17:57:22
Posts: 1

Total Post Ratings: 0

View Profile
« Reply #1499 on: 25 May, 2012, 18:04:10 »
0

Where can I find the Freq() function?
Also what do the green Key:Sinreq mean? Is that supposed to be an indication as to where i can find Freq() ?
Logged
Pages: 1 ... 98 99 [100] 101 102 ... 110   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.29 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.