Is there any way to execute a single line of assembly within a basic program (without having a one-line subprogram)? I have tried the AsmPrgm and Asm( commands and they don't seem to work (ERR:SYNTAX on the AsmPrgm or on the first hexadecimal character after the Asm( command). Being able to do this would greatly enhance many of my programs.
What calculator are you targeting? If you're on the monochrome calculators, you can use the ExecHex command in Doors CS.
TI-84+ and TI-83+. Some questions about the ExecHex function: a)Does the hex string need to be in quotations, and b) What is the code already ends in C9? Also, will the code still run if the program is not run from Doors CS? And finally, is there a way to do this without Doors CS so everyone can use my program?
Kydapoot wrote:
TI-84+ and TI-83+. Some questions about the ExecHex function: a)Does the hex string need to be in quotations, and b) What is the code already ends in C9? Also, will the code still run if the program is not run from Doors CS? And finally, is there a way to do this without Doors CS so everyone can use my program?

a) I believe it would have to be in a string variable like many other celtic commands(usually Str0), but someone would have to confirm this since I am not the one making it.
b) It is supposed to end in C9, Doors just adds it like a sort of security to prevent crashing your calc, but you can put it if you feel like it (I think it is recommended but I don't see why since it will be corrected for you, so you would just be wasting space). Also, yes the libs work even if you did not run the program from the Doors desktop.
If you don't want to use libs, I believe the only way is to have subprograms, which you seem reluctant (understandably) to use.
EDIT: By looking at the page you linked above, it looks like the string would simply be an argument (in quotation marks) in the det( command. I think this is particularly strange given that other commands that use strings use Str0 as input and Str9 as output (with either the output or an error code in Str9). This might not be the case though since these information pages can sometimes be slightly ambiguous. If it were up to me, I'd keep going with Str0 just to keep the input as uniform as possible, but it isn't up to me Rolling Eyes
EDIT 2: I just remembered something, another option using libs without exechex (since the command is not yet available) (without subprograms) would be to use celtic to load a string of hex into a program, then run this program and delete it at the end of your program. This way you can keep it simple for the user by keeping it contained in a single program.
In DoorsCSE, this would be done with a combination of det(4), det(2) and det(6 like so:

Code:
"PROGNAME→Str0
det(4 //create a program named PROGNAME
"Asm84CPrgmHEXSTRING→Str9
1:det(2 //put the hex string in the new program
Asm(prgmPROGNAME //run the program
det(6 //delete the program
How much overhead does ExecHex have? Like if you decided to do a for loop in native code instead of in BASIC, would it really save that many cycles?
It would be okay even if you added an unnecessary C9 because if it returns, it stops before it gets to the next C9
I used KermMartian's Code

Code:
det(20,"HEXSTRING")

and it worked fine (I left the C9, closing quotations, and colsing parenthesis on because I was paranoidand unfamiliar with the syntax and wanted as much security as possible). Thanks! Good Idea
Kydapoot wrote:
I used KermMartian's Code

Code:
det(20,"HEXSTRING")

and it worked fine (I left the C9, closing quotations, and colsing parenthesis on because I was paranoidand unfamiliar with the syntax and wanted as much security as possible). Thanks! Good Idea

It's totally safe to cut off C9") from the end
oldmud0 wrote:
How much overhead does ExecHex have? Like if you decided to do a for loop in native code instead of in BASIC, would it really save that many cycles?


For comparison, a For( loop has between 0.6 ms and 1 ms of overhead, and it takes about 1.0 ms to store something to Ans, and about 0.32 ms to execute a function with one real argument that returns a real value.

Although I don't have exact timings, ExecHex needs to convert the hex string to raw machine code, which I can't imagine taking less than 100 cycles per byte of machine code, or 0.06 ms. In addition, even though ExecHex doesn't return a value, it probably takes at least 1 ms to look up the string in the VAT (if it's not a constant string). So for a twenty-byte program, that's about 2 ms at minimum.

I attempted to time the execution of a BASIC program with a one-letter name, but timings varied wildly from 1.6 s to 2.7 s.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement