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

0 Members and 1 Guest are viewing this topic.

#### SamTebbs33

• LV1 Newcomer (Next: 20)
• Posts: 16
• Rating: +0/-0
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #15 on: January 23, 2014, 10:53:52 am »
(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 »

#### Hayleia

• Programming Absol
• Coder Of Tomorrow
• LV12 Extreme Poster (Next: 5000)
• Posts: 3367
• Rating: +393/-7
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #16 on: January 23, 2014, 10:59:18 am »
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.

#### SamTebbs33

• LV1 Newcomer (Next: 20)
• Posts: 16
• Rating: +0/-0
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #17 on: January 23, 2014, 11:22:08 am »
Aah, I see.

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

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4659
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #18 on: January 23, 2014, 11:30:19 am »
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 hIf 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->pabcdefghijklmnoAsm(7C0FCB1DCB1C)    ld a,h    rrca    rr l    rr h
Code: [Select]
;abcdefghijklmnop->habcdefg+pijklmnoAsm(7C0FCB0D856F2600CB14)    ld a,h    rrca    rrc l    add a,l    ld l,a    ld h,0    rl h
Code: [Select]
;abcdefghijklmnop->habcdefgpijklmnoAsm(CB0CCB0D)    rrc h    rrc l
I hope I got these correct.

#### SamTebbs33

• LV1 Newcomer (Next: 20)
• Posts: 16
• Rating: +0/-0
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #19 on: January 24, 2014, 02:37:46 pm »
Thanks!

How would I input the numbers I want to rotate?

#### Hayleia

• Programming Absol
• Coder Of Tomorrow
• LV12 Extreme Poster (Next: 5000)
• Posts: 3367
• Rating: +393/-7
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #20 on: January 25, 2014, 02:13:28 am »
(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 ?
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
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.

#### SamTebbs33

• LV1 Newcomer (Next: 20)
• Posts: 16
• Rating: +0/-0
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #21 on: January 25, 2014, 05:09:56 am »
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?

#### MGOS

• LV6 Super Member (Next: 500)
• Posts: 336
• Rating: +95/-0
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #22 on: January 25, 2014, 05:18:32 am »
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

#### Xeda112358

• they/them
• Moderator
• LV12 Extreme Poster (Next: 5000)
• Posts: 4659
• Rating: +718/-6
• Calc-u-lator, do doo doo do do do.
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #23 on: January 25, 2014, 08:29:46 pm »
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

#### SamTebbs33

• LV1 Newcomer (Next: 20)
• Posts: 16
• Rating: +0/-0
##### Re: Is it possible to execute asm within Axe/Is there a bit rotation asm program?
« Reply #24 on: January 26, 2014, 03:01:54 pm »
Thanks guys! I will be sure to our these to good use