Author Topic: Is it possible to execute asm within Axe/Is there a bit rotation asm program?  (Read 9710 times)

0 Members and 2 Guests are viewing this topic.

Offline SamTebbs33

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-0
    • View Profile
(D and 255)->U.Getting the first 8 bits
(D and 65280)->V.Getting the last 8 bits
I fear those don't work since "and" is a 8-bit operation IIRC. To do a 16-bit operation you need the "." (which is somewhere in Catalog, not the "." you'd put between 3.14). But since you want to take the 8 first bits and the 8 last bits, you can also do {°D} and {°D+1}.

I have some axe code that works on my calculator (below), but it doesn't function the same in SC3 on Cemetech.net
That doesn't really surprise me. SC3 is pretty new and SC2 didn't support Axe. I suggest you to use TokenIDE instead.

Wow, I can't believe I forgot that and is an 8 bit operation! thanks!

I would use TokenIDE but it only works on Windows :/ I have a mac.

EDIT: What does the ° symbol do?
« Last Edit: January 23, 2014, 10:55:19 am by SamTebbs33 »

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Basically, the ° symbol gets the pointer to the following variable. So °D is the pointer to D. So {°D} is D's first byte and {°D+1} is D's second byte.
Note that you can also do the contrary, like L5→°MyVar, and then you have a variable in L5 (and L5+1, it's 2 bytes). And you can do 1→MyVar, MyVar++, etc.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline SamTebbs33

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-0
    • View Profile
Aah, I see.

Does anyone know of an IDE that supports Axe and works on a mac?

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
Okay, say your 16-bit number has digits "abcdefghijklmnop"
If you want to rotate the whole thing left, "bcdefghijklmnopa" I would do this which averages a half cycle faster for the same size:
Code: [Select]
Asm(2930012C)
In assembly:
    add hl,hl
    jr nc,$+3
    inc l

If you want to rotate the bytes separately, bcdefgha jklmnopi and then add them together to get the addition of the two 8-bit numbers: bcdefgha+jklmnopi : back into Axe's "Ans"
Code: [Select]
Asm(7C07CB05856F2600CB14)
    ld a,h
    rlca
    rlc l
    add a,l
    ld l,a
    ld h,0
    rl h
If you just want the 16-bit number bcdefghajklmnopi:
Code: [Select]
Asm(CB04CB05)
    rlc h
    rlc l

The right rotations for all of those:
Code: [Select]
;abcdefghijklmnop->pabcdefghijklmno
Asm(7C0FCB1DCB1C)
    ld a,h
    rrca
    rr l
    rr h
Code: [Select]
;abcdefghijklmnop->habcdefg+pijklmno
Asm(7C0FCB0D856F2600CB14)
    ld a,h
    rrca
    rrc l
    add a,l
    ld l,a
    ld h,0
    rl h
Code: [Select]
;abcdefghijklmnop->habcdefgpijklmno
Asm(CB0CCB0D)
    rrc h
    rrc l

I hope I got these correct.

Offline SamTebbs33

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-0
    • View Profile
Thanks!

How would I input the numbers I want to rotate?

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
(You double posted by accident, you may want to delete one of your posts).

That depends on how you want your input routine: easy to code or easy to use ? :P
Easy to code is basically "press up and down until the number is the one you want, then press enter".
Easy to use is "to get 123, press 1 then 2 then 3".

The latter is easily codable but hard to get easy to use, you have to make keys respond at the right pace, not too slow, not too fast, you have to support the "backspace" key, etc.

Hence why I say the first one is a lot easier to do :P
It is just that:

.AA
0->A
While 1
 Text(0,,A+getKey(4)-getKey(1)->A>Dec)
 Pause 200
EndIf getKey(54)
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline SamTebbs33

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-0
    • View Profile
Oh no, I meant how would I send the numbers to the asm routine :p sorry for not being clear.

For example, would I set A to the number to rotate?

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Just put them in HL (Axe's Ans) - that is usually the last value you worked with. Just write the expression (or the single varibale) in the line before the routine. The same way (with the sto-> operator) you can retrieve the value returned by the routine.
Code: [Select]
:A
:Asm(STUFF)
:->A

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
Oh no, I meant how would I send the numbers to the asm routine :p sorry for not being clear.

For example, would I set A to the number to rotate?
What MGOS said is indeed the way to pass the value to the routine:
Just put them in HL (Axe's Ans) - that is usually the last value you worked with. Just write the expression (or the single varibale) in the line before the routine. The same way (with the sto-> operator) you can retrieve the value returned by the routine.
Code: [Select]
:A
:Asm(STUFF)
:->A

Offline SamTebbs33

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-0
    • View Profile
Thanks guys! I will be sure to our these to good use