Author Topic: ASM Routines - Source Code  (Read 8118 times)

0 Members and 1 Guest are viewing this topic.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
ASM Routines - Source Code
« on: April 19, 2010, 10:40:01 pm »
I've decided to release the source code for all templated commands the compiler uses when parsing.  I challenge anyone to improve the code :)

You'll have to ignore the cryptic scripts that surround the routines and it probably won't be very obvious what is being done in each one of them.  If you see any routine you think you can get from the start to the finish more efficiently with equal or lesser size, alert me!  If you have any specific question just ask.

Some of the inefficiencies I can't do anything about by the nature of the way the parser currently works, but I plan to correct this eventually (like the jr's at the beginning of the subroutines)

This might also benefit anyone who is trying to transition from Axe to assembly since Axe is for the most part just cookie-cut out of this template.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: ASM Routines - Source Code
« Reply #1 on: April 19, 2010, 11:30:19 pm »
oooh nice to see you are releasing the source for the routines. It might come handy for some people. :)
Dream of Omnimaga

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: ASM Routines - Source Code
« Reply #2 on: April 20, 2010, 02:11:27 am »
This could be a great way to improve the speed and efficiency of Axe :) it's so cool how you could just recompile a game and make it faster automaticaly ifyou did it with a new version ^^

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: ASM Routines - Source Code
« Reply #3 on: April 20, 2010, 09:54:06 am »
I will have a look at the routines. ;)
Hobbing in calculator projects.

SirCmpwn

  • Guest
Re: ASM Routines - Source Code
« Reply #4 on: April 20, 2010, 11:21:57 am »
Question:
If you have fastCopy impemented, then why does CopyBuffer use GrBufCpy?

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: ASM Routines - Source Code
« Reply #5 on: April 20, 2010, 12:24:36 pm »
Question:
If you have fastCopy impemented, then why does CopyBuffer use GrBufCpy?
What is called "Fastcopy" in the routines is actually safe copy.  Copybuffer was what I used to use but I don't use it anymore.  I'm just keeping it there becasue in the future there will be more settings on how to optimize the code for efficiency on the size-speed spectrum.  Not all the routines in the list are actually used.
« Last Edit: April 20, 2010, 12:25:43 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

SirCmpwn

  • Guest
Re: ASM Routines - Source Code
« Reply #6 on: April 20, 2010, 12:37:47 pm »
Oh, I understand more now.  Thanks for the clarification.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: ASM Routines - Source Code
« Reply #7 on: April 25, 2010, 10:45:50 pm »
These routines might actually need some optimizing.  I couldn't find an algorithm for signed division anywhere on the internet, so I had to do it the really bulky/lazy way with taking the absolute value and then adding the sign at the end.  The line drawing I just translated the pseudo-code from Wikipedia directly into assembly, but there might be a better way for that as well.
___Axe_Parser___
Today the calculator, tomorrow the world!

_player1537

  • Guest
Re: ASM Routines - Source Code
« Reply #8 on: May 14, 2010, 12:41:00 am »
Quigibo, could you help me understand your "getkey(x)" command.  I found it in the routines, and skipped the "jp" and ".db" parts, but I don't understand what H and L mean in the routine.  Could you help?

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: ASM Routines - Source Code
« Reply #9 on: May 14, 2010, 01:10:00 am »
That one is actually really complicated, the Parser itself uses an algorithm to determine what to make H and L.  That's why I require the number for direct keys to be constant instead of variable becasue it would be way too slow to have to convert it each time its trying to detect a key.

Anyway, H is the key group and L is the bit inverse of the key code I think.  There's a chart on day 22 of the learn z80 in 28 days tutorial you can use for reference.

By the way, I haven't updated the list with new commands since the last few versions.  If anyone wants any just ask and I'll post them up here.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: ASM Routines - Source Code
« Reply #10 on: May 16, 2010, 04:48:53 pm »
This looks like it would be very neat to look at/learn from, so if you don't mind, I'd appreciate it if you attached an updated list.  Thanks! :D

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: ASM Routines - Source Code
« Reply #11 on: May 17, 2010, 01:53:06 am »
Sure thing!  I also included a list of some of my macros since I think I use a few of them in my routines.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: ASM Routines - Source Code
« Reply #12 on: May 17, 2010, 04:45:40 am »
I also included a list of some of my macros since I think I use a few of them in my routines.
I especially liked the min and max macros. Mind if I release some of the macros and routines in a z80 library? (I put credit in the source code and readme, it is my habit)

The adding and multiplying hl by constants can help out some beginners (drawback of some not understanding exactly what are doing) or copy/paste to spare time.
Hobbing in calculator projects.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: ASM Routines - Source Code
« Reply #13 on: May 17, 2010, 09:09:48 pm »
Sure, use as many as you want.
___Axe_Parser___
Today the calculator, tomorrow the world!