kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) (12/14/90)
Playing around with code objects on my HP48 I ran into a problem: Can a code object be included into a user language program ? If yes, how ? I have assembled a code object on my workstation, transferred it to the HP and stored it in a variable. Calling this variable as a subroutine from user language works well. But then I wanted to include the code directly into the user language program and edited it using the interactive stack. This didn't work as expected. The code object changed to something that gave the value 'Code' (as unresolved name) when executed. Of course I could build the whole thing (user language + code object) using the assembler, but I feel there could be a way to incorporate the code object into the program using only the HP48. Any suggestions ? -KK
bgribble@jarthur.Claremont.EDU (Bill Gribble) (12/16/90)
In article <kskalb.661187537@faui1f> kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) writes: >Can a code object be included into a user language program ? >If yes, how ? [...] >But then I wanted to include the code directly into the user language >program and edited it using the interactive stack. >This didn't work as expected. The code object changed to something >that gave the value 'Code' (as unresolved name) when executed. If you're familiar enough with machine language, it wouldn't be too hard to write a 'linker' that would process a user-language program by looking for globals in the user-program object that were equivalent to code objects and then including them. You could write it so that a global starting with, say, the '.' character was to be replaced with its object, so that the program sequence \<< IF '.test' THEN '.yes' ELSE '.no' END \>> when given to the linker as an argument would have the global '.test' replaced by the code object 'test' and so on. Doesn't seem like the code would be that hard, actually. The only tricky part would be checking each 5-nibble RPL code for an object type and skipping the proper number of nibbles to get to the next RPL code. As an alternative, you could use ->ASC and ASC-> to disassemble the user program into an editable string, insert the ->ASC'ed code object, fix the checksum using the KCRC {syseval || program}, I forget, and then ASC-> it to get a program again. Hope this helps! >-KK ***************************************************************************** ** Bill Gribble Harvey Mudd College, Claremont, CA ** ** bgribble@jarthur.claremont.edu Never heard of it? You're stupid. ** *****************************************************************************
cloos@acsu.buffalo.edu (James H. Cloos) (12/18/90)
In article <kskalb.661187537@faui1f> kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) writes: [etc.] >Can a code object be included into a user language program ? >If yes, how ? [etc.] You will have to use a function such as \->PRG posted previously by Rick Grevelle. (see below). To do this, write your usrlang program as usual, execute PRG\-> to put each element of the porgram on the stack, put your code object on the stack, then use ROLLD & ROLL to position the CODE where it belongs in the program (interactive stack helps here). If you left a marker for where the code was to be inserted, make sure you remove it from the stack, if you didn't, make sure you increment the #_of_elements count that PRG\-> left on level 1. Now use \->PRG to combine the elements back into a program. The four programs in the downloadable dir below need to be run thru ASC\-> to use them. Here is the DIR: %%HP: T(3)A(R)F(.); DIR \->PRG "D9D2043C8154450B21305CEC" PRG\-> "D9D202BA812BF81F3040379C1B21305293" ALG\-> "D9D202BA812BF8194040379C1B2130C3D2" \->ALG "D9D2043C81D6450B2130474F" END These routines do do argument checking. -JimC -- James H. Cloos, Jr. Phone: +1 716 673-1250 cloos@ACSU.Buffalo.EDU Snail: PersonalZipCode: 14048-0772, USA cloos@ub.UUCP Quote: <>
akcs.joehorn@hpcvbbs.UUCP (Joseph K. Horn) (12/18/90)
Klaus Kalb asks how to include pre-written Code objects inside user-code programs without assembling the entire program. A very handy way is to use Rick Grevelle's PRG-> and ->PRG routines (posted here earlier) with ROLL and ROLLD. ---------------------------Example:-------------------------------- I have a Code object stored in 'JUNK'. I have a program that looks like this: << A B C + JUNK * >> but I want the program to look like this: << A B C + Code * >>. Here's how to do it: 1) << A B C + JUNK * >> (this is the original program) 2) PRG-> (decomposes program into its objects + count (8)) 3) 4 ROLL (this pulls JUNK down from level 4 to level 1) 4) RCL (this replaces JUNK with its Code contents) 5) 4 ROLLD (this puts the Code into level 4, where JUNK was) 6) ->PRG (this recomposes the program into a single object) 7) See << A B C + Code * >> on the stack! Steps 3 and 5 are done easily by using the interactive stack. In fact, this application is the only time I use the interactive stack. If more than one replacement is to be made, steps 3 through 5 can be automated (if you have Donnelly's Tool Library) this way: ->LIST 'JUNK' DUP RCL REPLACE OBJ->. That'll replace every 'JUNK' with its contents throughout the whole program. Global search and replace on program objects! Can't do THAT on most handhelds! Of course, this method can be used to insert "External"s and anything else your heart desires into programs. You don't ever have to assemble the whole thing like we used to do! Now you can write a chunk at a time, verify that each chunk works, and then tack the chunks together with ->PRG. PRG-> by Rick Grevelle, in ASC format. String checksum: # CE4Dh. ASC'd object checksum: # 3925h. -----[ PRG-> begin ]----- %%HP:; "D9D202BA812BF81F3040379C1B21305293" -----[ PRG-> end ]----- ->PRG by Rick Grevelle, in ASC format. String checksum: # 7844h. ASC'd object checksum: # CEC5h. -----[ ->PRG begin ]----- %%HP:; "D9D2043C8154450B21305CEC" -----[ ->PRG end ]----- Usage: Place a program object in level 1. Press PRG->. See the program's objects in levels 2 through n, and find n in level 1. PRG-> converts a program object into a meta-object. Place objects in levels 2 through n, and place n in level 1, and press ->PRG. See the objects combined into a program object in level 1. ->PRG converts a meta-object into a program object. -- Joseph K. Horn -- (714) 858-0920 -- Peripheral Vision, Ltd.
akcs.falco@hpcvbbs.UUCP (Andrey Dolgachev) (12/21/90)
In order to put a code object in a user program, you can also use the Put command described in the hidden directory message (826