corpse: musings on the retro language
Post 178 of 178: prior | comments | permalink
2012-02-15
I've dropped the social media stuff, made a few tweaks to the stylesheets (to begin drawing in elements from the ongoing web design changes), and updated to the latest image. So Corpse is now running nicely on an 11.3 development image, with the most recent libraries, and a bit of old stuff removed. This should be helpful in keeping it running at a reasonable speed.
RSS has reverted back to just headings. I need to rewrite the article inclusion code to fix some bugs that were restricting things to just a few partial lines. Hopefully I'll find time to do this soon.
Post 177 of 178: prior | next | comments | permalink
2012-02-13
I have merged the new decompiler into the Autopsy debugger. So we now have three possible views into the compiled code.
Let's look at these briefly. First, a simple test function:
: test 1 2 + [ 45 ] dip * putn cr ;
With this loaded, we can look at the compiled code. First is the horizontal mode. Try running horizontal see test.
+--------------++--------------++--------------++--------------+ | 15646 || 15647 || 15648 || 15649 | |--------------||--------------||--------------||--------------| | 0 || 0 || 1 || 1 | | nop || nop || lit || 1 | +--------------++--------------++--------------++--------------+ +--------------++--------------++--------------++--------------+ | 15650 || 15651 || 15652 || 15653 | |--------------||--------------||--------------||--------------| | 1 || 2 || 16 || 671 | | lit || 2 || + || quote | +--------------++--------------++--------------++--------------+ +--------------++--------------++--------------++--------------+ | 15654 || 15655 || 15656 || 15657 | |--------------||--------------||--------------||--------------| | 15658 || 1 || 45 || 9 | | || lit || 45 || ; | +--------------++--------------++--------------++--------------+ +--------------++--------------++--------------++--------------+ | 15658 || 15659 || 15660 || 15661 | |--------------||--------------||--------------||--------------| | 757 || 18 || 4709 || 371 | | dip || * || putn || cr | +--------------++--------------++--------------++--------------+ +--------------+ | 15662 | |--------------| | 9 | | ; | +--------------+
As you can see, there's a lot of information here. You get one box per memory location, with the address as the header, the value, and the corresponding opcode or subroutine call. It's a nice view, but consumes a lot of space.
The second view, vertical is simpler, and more space friendly. Try vertical see test.
15646 nop 15647 nop 15648 lit 1 15650 lit 2 15652 + 15653 call 671 15654 call 15658 15655 lit 45 15657 ; 15658 call 757 15659 * 15660 call 4709 15661 call 371 15662 ;
This provides less information, but is far more space friendly.
With both of these there is a loss of direct mapping to the original source. Retro's compiler doesn't make it possible to restore a 1:1 copy, but we can come close in many circumstances. This is done through the source display mode. Try: source see test.
1 2 + [ 45 ] dip * putn cr ;
The source view has limitations. Things like repeat/again and other inlining funcitons won't be mapped and displayed correctly. Even so, it does suprisingly well, given that Retro makes no actual attempts to provide a means of reconstructing the source.
Post 176 of 178: prior | next | comments | permalink
2012-02-11
Retro has, through the Autopsy debugger, two dissassemblers for examining compiled code. While useful, I have desired a means of recovering the original (or close approximation) source code for a function.
Withh the new quotes implementation, this is finally within reach. I have checked in a new file (examples/see.rx) which contains a function named see which attempts to decompile a function back to its original source. There are still some limitations, but overall it works very nicely. Once it can cover a few more cases, I will integrate it into Autopsy.
Post 175 of 178: prior | next | comments | permalink
2012-02-09
I've just pushed some changes to the way quotes are implemented.
Originally quotes were compiled in memory as follows:
jump to code following quote ... compiled code for quote ... return instruction code to push address of compiled code
This means that a minimal quote consumed 5 cells of memory. (Two for the jump, one for the return, and two for the push). The new approach is far smaller:
call to 'quote' ... compiled code ... return instruction
Since calls are implicit, this reduces the minimal size to two cells.
The work is now done by the quote function. This will calculate and return the address of the quote, and skip over it in memory. A bit slower, but doing this allows a lot of savings: the image is now 8,666 cells in size.