Author Topic: Basic to ASM?  (Read 8077 times)

0 Members and 1 Guest are viewing this topic.

Offline program4

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 158
  • Rating: +15/-0
    • View Profile
Basic to ASM?
« on: July 28, 2010, 09:41:21 am »
I downloaded a random BASIC program on ticalc.org, and ran it through the ASM File Unsquisher, and there was a long list of hex codes. If you typed it in your calculator, would the program actually be in ASM?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Basic to ASM?
« Reply #1 on: July 28, 2010, 09:45:21 am »
No, BASIC is totally different from ASM. The File Unsquisher basically takes the hex data of a program and displays it; so if you did that with a BASIC program, all it would do is display the hex codes of the tokens (commands, etc.) in the BASIC program. It would not be ASM, since the commands themselves aren't translated.

And it wouldn't run on a calculator, even if you compile it (using the AsmComp( command), because you're making the calculator think it's ASM, even though it's not.

EDIT: Oh yeah, and if you run it with Asm(, like an ordinary assembly program, chances are your calculator will crash :D
« Last Edit: July 28, 2010, 10:23:43 am by Deep Thought »




Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Re: Basic to ASM?
« Reply #2 on: July 28, 2010, 10:13:36 am »
Your calculator would have a 99.999999% of crashing if you actually tried to run it.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Basic to ASM?
« Reply #3 on: July 28, 2010, 10:19:27 am »
I downloaded a random BASIC program on ticalc.org, and ran it through the ASM File Unsquisher, and there was a long list of hex codes. If you typed it in your calculator, would the program actually be in ASM?

The calculator would be running a bunch of "data" instead of actual commands.  Like everyone else said, it will most likely crash the calculator.
« Last Edit: July 28, 2010, 10:19:58 am by Hot_Dog »

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Basic to ASM?
« Reply #4 on: July 28, 2010, 07:53:13 pm »
First person to make a program that runs in ASM and BASIC without crashing the calculator or erring (for the ASM program you can ignore the mandatory BB6D at the beginning) wins something. (Non-trivial solutions only)
It'd be interesting to see if such a program could exist ;D
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Basic to ASM?
« Reply #5 on: July 29, 2010, 12:53:23 am »
:D We should have a contest for that someday: a game that runs both in BASIC and ASM. That would be absolutely amazing.

What about a BASIC>ASM converter? I think there's one on ticalc.org, but I don't think it works.
« Last Edit: July 29, 2010, 01:15:11 am by Deep Thought »




Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Basic to ASM?
« Reply #6 on: July 29, 2010, 01:01:51 am »
Well... I did it. The program does the same thing in both languages. It was a fun challenge, but it was also really hard. The main problem is that bcall is represented by $EF, and it has no token counterpart. So the next logical thing is to skip that step and straight call $0028. But guess what, no $00 either.

Here is the code in both languages.

Basic:
Code: [Select]
:
:
:Disp "(0.0)_Hel
lo!!!!"
:Return
:_sin-1(fMax(0fMa
x(0CubicReg 0_ra
ndM(HDegree>>(not equals)me
an(mean(mean(mea
n(00000000mean(a
bs(Vertical ?2in
t(Vertical 210^(V
ertical tanh-1(?V
ertical rEtanh-1(
?Vertical CubicR
eg Ey

And assembly:
Code: [Select]
.db $BB, $6D
sbc a, $2A
djnz $9DC9
ld a, ($1130)
add hl, hl
ld c, b
cp e
or h
cp e
cp h
cp e
cp h
cp e
cp a
dec l
dec l
dec l
dec l
ld hl, ($D53F)
ccf
add hl, hl
_9DAF:
jp $3028
_9DB2:
.db "(0.0) Hello!!!!"
_9DC1:
.db $30, $30
jr nc, $9DF5
jr nc, $9DF7
jr nc, $9DF9
_9DC9:
ld hl, $9DB2
xor a
ld ($9DB1), a
ld ($9DC1), a
call $9DAF
.dw _putS
call $9DAF
.dw _newLine
cp e
ret

BB 6D shows up as a ? on the calc as you can see from the screen shot. But that is the only token that I had to use calcsys to get. The rest of the program was typed in by hand. For converting back and forth, you change those first two returns to BB 6D.
« Last Edit: July 29, 2010, 01:07:20 am by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Basic to ASM?
« Reply #7 on: July 29, 2010, 03:07:03 am »
I tried...

Code: ("TI-BASIC") [Select]
:::Asm(prgmA)
:Return
:?2[size=8]E[/si
ze]Pt-On(28Pt-On
(tanh(^-1)(9Pt-O
n(XEmean(iPart(V
ertical tanh(^-1
)(9Pt-On(^r^E:Pa
ramtanh(^-1)(9Pt
-On(►DMSEsinh(^-
1)(randM(randM(r
andM(randM(randM
(randM(randM(ran
dM(TEngDegreeran
dM(randM(randM(ra
ndM(randM(randM(
randM(randM(rand
M(randM(randM(ra
ndM(randM(randM(
randM(randM(rand
M(randM(randM(ra
ndM(randM(randM(
randM(randM(rand
M(randM(randM(ra
ndM(randM(RFloat
randM(randM(rand
M(randM(randM(ra
ndM(randM(randM(
randM(randM(rand
M(randM(R≠>>Degr
eeAnsfMin(Fix r
andM(randM(randM
(randM(randM(ran
dM(randM(randM(r
andM(randM(randM
(randM(randM(ran
dM(randM(randM(r
andM(randM(randM
(randM(randM(ran
dM(randM(randM(≠
NormalrandM(rand
M(randM(randM(ran
dM(randM(randM(r
andM(randM(randM
(randM(randM(ran
dM(randM(randM(r
andM(randM(randM
(randM(randM(ran
dM(randM(randM(r
andM(randM(randM
(randM(randM(ran
dM(randM(T≠≤≠Ans
Ans≠0sin(^-1)fMa
x(0
Generated by [url=http://sc.cemetech.net]SourceCoder[/url], © 2005-2010 [url=http://www.cemetech.net]Cemetech[/url]

Code: (TI-ASM) [Select]
#include ti83plus.inc
.org $9D93
.db $BB,$6D
cp E ;$9D95
ld L,D ;$9D96
ld E,A ;$9D97
ld B,C ;$9D98
ld DE,$D53F ;$9D99
ccf ;$9D9C
xor A ;$9D9D
ld (BCALLER+2),A ;$9D9E
ld (TEXTEND),A ;$9DA1
call BCALLER ;$9DA4
.dw _HomeUp ;$9DA7
ld HL,TEXT ;$9DA9
call BCALLER ;$9DAC
.dw _PutS ;$9DAF
ld A,$77 ;$9DB1
call BCALLER ;$9DB3
.dw _PutMap ;$9DB6
ret ;$9DB8
TEXT:
.db "        The     " ;$9DB9
.db "                " ;$9DC9
.db "        Rick    " ;$9DD9
.db "        Roller",$27,"s" ;$9DE9
.db "                " ;$9DF9
.db "        of      " ;$9E09
.db "                " ;$9E19
.db "        Tomorro" ;$9E29
TEXTEND:
.db $30 ;$9E38
BCALLER:
jp $3028 ;$9E39

Basically, I was trying to cheat by making a program that would run itself as assembly if you ran it in BASIC. And then I realized that for it to work in BASIC, it has to start with the two colons, while for it to work in ASM, it has to start with $6DBB. And so I failed.

(Don't even try. The screenshot uses two separate programs to show what I tried to make. As you can see, I was trying to build my own version of the rickrolling program.)

EDIT: A pity it didn't work. If it worked, all you'd have to do is add that extra header, and any ASM program would run from the homescreen without Asm(.

EDIT2: Wait, since the plain TI-83 doesn't have a compiled ASM token, couldn't we make something like this (with a slightly different header) for it? It'd be more convenient than calling from an extra BASIC program.

EDIT3: Of course, somebody probably already thought of that :P
« Last Edit: July 29, 2010, 03:37:00 am by Deep Thought »




Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Basic to ASM?
« Reply #8 on: July 29, 2010, 10:17:32 am »
Wow, ours look really similar. But last night when I went to bed, I was wondering the same thing, if a basic program could Asm( itself. But I just found out it's not. I used a parser hook to trace through the execution of a program and the OS checks for either, BB 6D or BB 6C. BB 6C as you probably guessed is AsmPrgm.

I guess the only thing would be self modifying basic code.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Basic to ASM?
« Reply #9 on: July 29, 2010, 10:58:24 am »
Wow, ours look really similar.

Oh yeah, I took the idea to modify the jump from your example. I was going to give you credit for that in my post, but I totally forgot x.x Really sorry about that.

Do you think it would work on a plain 83?
« Last Edit: July 29, 2010, 10:59:02 am by Deep Thought »




Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Basic to ASM?
« Reply #10 on: July 29, 2010, 11:06:25 am »
I don't care if people copy me.  :)  But the 83 idea should work. I don't see why it wouldn't. Too bad I have never seen an 83 in my life.

It would totally be possible to make a game that runs in asm and basic though. You could use a djnz like I did because that is just a (. Then "if 0:" off a section where it jumps to say $9A00. That way you could make a basic game before the assembly game. At that point, I wouldn't even care if I used illegal characters in the assembly part.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Basic to ASM?
« Reply #11 on: July 29, 2010, 11:09:29 am »
It would totally be possible to make a game that runs in asm and basic though. You could use a djnz like I did because that is just a (. Then "if 0:" off a section where it jumps to say $9A00. That way you could make a basic game before the assembly game. At that point, I wouldn't even care if I used illegal characters in the assembly part.

But then you couldn't code it using the BASIC editor...

EDIT: Wow, just thought of an way this could be useful: Forget about having it run as a BASIC program. If we managed to make games completely compatible with the BASIC editor, calc users without link cables could just code the program directly, without bothering to use hex,

EDIT2: Oh, wait, $6DBB :P
« Last Edit: July 29, 2010, 11:11:44 am by Deep Thought »




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 to ASM?
« Reply #12 on: July 29, 2010, 08:56:23 pm »
The code above isn't TI-BASIC, though, right? I wonder if someone could manage to make a BASIC program wrote with legit BASIC syntax do the exact same thing as its ASM unsquished counterpart :P
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Basic to ASM?
« Reply #13 on: July 30, 2010, 12:57:32 am »
DJ, you are saying have the assembly program run the exact same code that the basic one does and come up with the same result?

It might be remotely possible, but it would take a ridiculous amount of time. Plus the assembly is usually longer. Mine is really two separate programs in one. Only the first 4 bytes are used by both.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

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 to ASM?
« Reply #14 on: July 30, 2010, 03:13:28 am »
Yeah that's what I meant. At first that thread had my hopes up lol :P

Still nice to see the above, though. Also I agree finding a combination of BASIC commands that does exactly what its Galandros unsquisher-generated counterpart does (after ASM compiling) would be insanely hard o.o
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)