Author Topic: BASIC (Ab)Uses of Assembly Opcodes  (Read 15142 times)

0 Members and 2 Guests are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #15 on: November 21, 2010, 01:06:00 am »
coyuld you translate this to something more english-style so I can get the grasp of it easier?
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #16 on: November 21, 2010, 01:12:28 am »
Okay, say you want to make a rectangle with one corner at the pixel coordinate (8,8) and the opposite corner at (17,26). Converted to hex and you get:
(8,8)=   (08,08)
(17,26)=(11,1A)

For this opcode, you need to switch the coordinates around:
1st coordinate: 210808
2nd coordinate:111A11
Then you just choose your rectangle method.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #17 on: November 21, 2010, 02:06:38 am »
Ah ok but do you need a copy of the routine everytime you use it?
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #18 on: November 21, 2010, 02:13:59 am »
What do you mean? I am confused, now...

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #19 on: November 21, 2010, 02:15:50 am »
I mean, do you have to include a copy of the rectangle drawing routine for everytime it's called? Like if you make a program that draws a nice RPG menu using rectangles 8 times, will it include 8 copies of the routine in the program? That might end up pretty large. I was wondering because on the previous page, the last piece of code seemed to have two parts looking similar.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #20 on: November 21, 2010, 02:17:32 am »
Okay, I am still a tad lost, but the other code would draw two different boxes. Each one has its own coordinates supplied to it.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #21 on: November 21, 2010, 02:22:01 am »
Sighs, I think I am clear enough. Could a bilingual person translates for me?

Anyway, what I mean is if we use pseudo code (similar to Axe) as example:

Would the code be more like

{x1,y1,x2,y2}
sub(RCT)
{x1,y1,x2,y2}
sub(RCT)
{x1,y1,x2,y2}
sub(RCT)
{x1,y1,x2,y2}
sub(RCT)
{x1,y1,x2,y2}
sub(RCT)
{x1,y1,x2,y2}
sub(RCT)
{x1,y1,x2,y2}
sub(RCT)
{x1,y1,x2,y2}
sub(RCT)
Lbl RCT
Draw left side
Draw right side
Draw up side
Draw lower side
End


Or would it be like

{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side
{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side
{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side
{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side
{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side
{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side
{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side
{x1,y1,x2,y2}
Draw left side
Draw right side
Draw up side
Draw lower side

?

If you don't understand, then sorry, but I think I did my best to explain myself. Someone will have to explain for me, then.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #22 on: November 21, 2010, 02:25:31 am »
If I wanted to draw 6 rectangles, I would need:
21xxyy11xxyyEFzz4D
21xxyy11xxyyEFzz4D
21xxyy11xxyyEFzz4D
21xxyy11xxyyEFzz4D
21xxyy11xxyyEFzz4D
21xxyy11xxyyEFzz4D
C9
Is this what you mean?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #23 on: November 21, 2010, 02:35:08 am »
Not sure. I don't know how to explain better. Can anyone else help me?
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #24 on: November 21, 2010, 02:36:35 am »
I think he's saying that you need the code every time you draw a rectangle, but it can be done efficiently by linking the Hex together.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #25 on: November 21, 2010, 10:49:33 am »
Yes! And I wasn't going to put this in, but I might as well. If you need to draw 10 rectangles or more it becomes more memory efficient to use this method (my new method I am using with ASMDRAW6). This example only draws three so that it isn't as confusing:

0603
21BB9D11AD9DC5ED
A0EDA013EDA0EDA0
13EDA0E5D5210000
110000EF624DD1E1
C110DFC9
0000040562
010102025F
010818187D

Here are the rules:
  • the 0603 tells how many rectangles there are. The 06 stays the same, but but if you were to draw 11 rectangles, you would use 0B instead of 03.
  • The 0000040562 translates to doing 210000110405EF624D
I don't know an easier way to describe this one which is why I wanted to leave it out... :(

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: BASIC (Ab)Uses of Assembly Opcodes
« Reply #26 on: November 21, 2010, 11:06:41 am »
So basically, this routine is kinda like this (in Axe-ish code):
2->B  (Number of lines to draw minus one)
For(A,0,B)
A*5+GDB1->C
Rect({C},{C+1},{C+2},{C+3})  // These refer to the values at the bottom
// The last value is for the type of the box, and I can't show that in Axe. ;D  The type for Rect() in Axe is the filled rectangle
End
Return
[[0000040562]]->GDB1
[[010102025F]]
[[010818187D]]
« Last Edit: November 21, 2010, 11:20:43 am by ztrumpet »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #27 on: November 21, 2010, 11:18:22 am »
Um, I am not very Axe literate, so I am not sure... But the stuff after C9 provides the coordinates and the rectangle type. So if we look at 0000040562 as aabbccddee, then:
aa=left coordinate
bb=upper coordinate
cc=right coordinate
dd=lower coordinate
ee=Rectangle type (EF5F4D is the inverted box; use 5F)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #28 on: December 06, 2010, 11:47:20 pm »
It has been a while, so here is my next little trick. If you have a bunch of opcodes, but you don't want a bunch of programs, you can turn them into a library. A simple library can be made using this format:

EFD74AB7C0
EFEF4A3C47

10xx
<<code>>
10yy
<<code>>
...

EF6A48C9

The xx and yy are the sizes of the <<code>> they correspond to in bytes.
The EF6A48 is just an LCD update which will occur as the last command. This can be changed to another code.

So, say I wanted to use:
Code: [Select]
05 bytes: (LCD On) 3E03D310C9
05 bytes: (LCD Off) 3E02D310C9
10 bytes: (Invert Screen) 210000115F3FEF5F4DC9
I would do:
Code: [Select]
EFD74AB7C0
EFEF4A3C47
1005
3E03D310C9
1005
3E03D310C9
100A                       ;0A is the hexadecimal value for 10
210000115F3FEF5F4DC9
EF6A48
C9
If I named this prgmA, then to run, I use a number that tells which code to run. So "0" would turn on the LCD, "1" would turn it off, and "2" would invert the screen. Anything after that would update the LCD (display the graph screen).
So:

Code: [Select]
:1                    ;LCD Off
:Asm(prgmA
:2                    ;Invert screen
:Asm(prgmA
:Pause "HI
:0                    ;LCD On
:Asm(prgmA
This would turn the LCD Off, invert the screen, and turn it back on, after you hit enter (for the Pause).

I made a program a while ago that did this for you. I am going through my TICalc programs to update them, and I came across this program. I added more features and abilities as well, and now it has 3 types of libraries it can make. A "Basic" library (like the one above). A "Tech" library that allows stringing arguments together, and a "Zeda" version which is what SpriteLib uses. Stringing would be like using {1,2,3:Asm(prgmA instead of calling the program each time.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: BASIC (Ab)Uses of Assembly Opcodes
« Reply #29 on: January 22, 2011, 06:08:40 pm »
Wow, it's been so long I actually googled this to find it :D Okay, for a quick list of Assembly opcodes, I have been working on a small document for the past few days. It has some codes that are some combination of useful, fun, funny, and crazy. Feel free to have fun and ask questions :D

*As a note, I do not have my PDF vieweriser working, so I do not know what it actually looks like or how easy it is to use ... Grrr, Adobe, grr