Well, I thought I'd take a moment to update everyone on the status of PASM. Last time I blogged about this, I had compiled my very first trivial PHP script.. Well, since then I have decided that now is the time to start cleaning things up a bit and put things into a more reasonable framework.
As a result, I have completely re-organized PASM into a more modular approach. The new version is divided into an engine (which processes the op codes) and a code-generation module (which generates the actual assembler code).
By making the code-generation portion of PASM module the concept is that PASM could be extended at some future point to create assembly code for other platforms or assemblers. Of course at this point that's thinking much too far into the future -- but i must say the code is much, much cleaner. I'm one step closer to getting the project into a redistrobutable form -- but I'd like it to do a little more before I do that..
Just to give a quick update, here is a brief list of the opcodes i have implemented thus far (and a desc. of them if they aren't obvious):
That's pretty much it :) Although there around 25 opcodes implemented and seem to behave exactly as they should. It's been a lot of work just to be able to compile some trivial math!! My next step is to start implementing string-related opcodes. I hope to have most of the basic functionality implemented by the end of April (as long as I have the time)..
While I was re-coding the PASM engine to make things more reasonable I decided to also re-write the PASM memory manager. As I've already posted the memory manager (called PMM) is available to download on my projects page. To read about the first release of PMM, it is archived here.
Thanks to those who sent me e-mails showing interest in this project so far. Your encouragement is always appreciated!
Well, I thought I'd take a moment to update everyone on the status of PASM. Last time I blogged about this, I had compiled my very first trivial PHP script.. Well, since then I have decided that now is the time to start cleaning things up a bit and put things into a more reasonable framework.
As a result, I have completely re-organized PASM into a more modular approach. The new version is divided into an engine (which processes the op codes) and a code-generation module (which generates the actual assembler code).
By making the code-generation portion of PASM module the concept is that PASM could be extended at some future point to create assembly code for other platforms or assemblers. Of course at this point that's thinking much too far into the future -- but i must say the code is much, much cleaner. I'm one step closer to getting the project into a redistrobutable form -- but I'd like it to do a little more before I do that..
Just to give a quick update, here is a brief list of the opcodes i have implemented thus far (and a desc. of them if they aren't obvious):
That's pretty much it :) Although there around 25 opcodes implemented and seem to behave exactly as they should. It's been a lot of work just to be able to compile some trivial math!! My next step is to start implementing string-related opcodes. I hope to have most of the basic functionality implemented by the end of April (as long as I have the time)..
While I was re-coding the PASM engine to make things more reasonable I decided to also re-write the PASM memory manager. As I've already posted the memory manager (called PMM) is available to download on my projects page. To read about the first release of PMM, it is archived here.
Thanks to those who sent me e-mails showing interest in this project so far. Your encouragement is always appreciated!
I'm happy to announce that I am now ready to release the first public version of PMM. PMM is a memory management system written almost entirely in assembler (using FASM). The memory management system has been designed to be flexable and powerful and supports features such as:
As of right now, I have only tried to compile this on Redhat linux using FASM 1.45. Of course, you are free to try it on other platforms and let me know. For more information (including downloading) visit the projects page.
I'm happy to announce that I am now ready to release the first public version of PMM. PMM is a memory management system written almost entirely in assembler (using FASM). The memory management system has been designed to be flexable and powerful and supports features such as:
As of right now, I have only tried to compile this on Redhat linux using FASM 1.45. Of course, you are free to try it on other platforms and let me know. For more information (including downloading) visit the projects page.
Once again, the PHP-DEV mailing list is packed full of discussions relating to how PHP handles errors. Last year, I faught and failed attempting to get the developers to go along with adding error codes (for i18n)... now the topic of the day has been relating to how PHP5 will handle errors -- at least as they relate to the new OO model. For some reason, Andi (and I assume Zeev) think that PHP5 shouldn't throw exceptions internally (even though you can write scripts that throw exceptions).
The proposal basically consists of PHP throwing exceptions which can be caught instead of triggering E_ERROR messages which kill the script. To provide backward compatiability if the exception is not caught by the script PHP would catch it internally and then trigger a E_ERROR.
Unfortunately, at least Andi is thus far unwilling to go along with this idea because he feels that "...we'll end up having an unmanageable hybrid because there's no way we're going to change the error-handling of the existing internal functions."
I get this feeling that Andi and Zeev really really really want to just shove PHP5 out the door ASAP, hence why they don't seem willing to do a major overhaul to the error handling mechanism. Which is a shame, because I think an overhaul such as this would in the end make PHP even more robust than it already is by allowing developers to gracefully deal with errors.
Once again, the PHP-DEV mailing list is packed full of discussions relating to how PHP handles errors. Last year, I faught and failed attempting to get the developers to go along with adding error codes (for i18n)... now the topic of the day has been relating to how PHP5 will handle errors -- at least as they relate to the new OO model. For some reason, Andi (and I assume Zeev) think that PHP5 shouldn't throw exceptions internally (even though you can write scripts that throw exceptions).
The proposal basically consists of PHP throwing exceptions which can be caught instead of triggering E_ERROR messages which kill the script. To provide backward compatiability if the exception is not caught by the script PHP would catch it internally and then trigger a E_ERROR.
Unfortunately, at least Andi is thus far unwilling to go along with this idea because he feels that "...we'll end up having an unmanageable hybrid because there's no way we're going to change the error-handling of the existing internal functions."
I get this feeling that Andi and Zeev really really really want to just shove PHP5 out the door ASAP, hence why they don't seem willing to do a major overhaul to the error handling mechanism. Which is a shame, because I think an overhaul such as this would in the end make PHP even more robust than it already is by allowing developers to gracefully deal with errors.
For those of you who haven't visited the projects page yet, a side project of mine that I have been working on is PASM. Basically, this is the first known attempt at true machine-language code generation (Marco is working on a PHP->C converter). The application itself consists of three separate pieces -- the ASM backend library and memory manager (written from scratch by me), a PHP module which takes over the Zend engine to produce a associative array representing the compiled script, and a the PASM application (written in PHP) which pulls to two of them together.
Want the (very, very simple) test script and the resulting ASM code? Read on... I'm very interested in hearing what people think, comments welcome!
The trivial test script:
<?php
      $b = 5;
       $a = $b + $b;
      $c = (($a + $b) ($a $a)) - ($a + $a);
?>
The resulting[1] assembly-code output when compiled using PASM:
format ELF
use32
include 'cdecl.inc'     ÂÂ
include 'pasm_lib.inc'    ÂÂ
include 'externs.inc'    ÂÂ
include 'mem_manager.inc'   ÂÂ
include 'debug.inc'    ÂÂ
include 'pasm_var_macros.inc'  ÂÂ
section '.text' executable
 public main
main:
 ccall pasm_initapp, NULL
 call __pasm_script_main
 ccall pasm_exitapp, NULL
 ret
ÂÂ
__pasm_script_main:
;; begin what would be PHP code ;;
       pmkv b
       pc2i dword b
       dconst PASM_TC_3e816714863fb, 5
       pseti b, PASM_TC_3e816714863fb.lo, PASM_TC_3e816714863fb.hi
       push [b]
       push [b]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e8167148b215
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e8167148b215
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fadd st, st1
       pseti PASM_TV_3e8167148b215
       push [PASM_TV_3e8167148b215]
       pmkv a
       pop [PASM_TV_OP1]
       pc2i a
       pgeti PASM_TV_3e8167148b215
       pseti a
       unset PASM_TV_3e8167148b215
       push [a]
       push [b]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e81671490035
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e81671490035
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fadd st, st1
       pseti PASM_TV_3e81671490035
       push [PASM_TV_3e81671490035]
       push [a]
       push [a]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e81671494e68
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e81671494e68
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fmul st, st1
       pseti PASM_TV_3e81671494e68
       push [PASM_TV_3e81671494e68]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e81671499c75
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e81671499c75
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fmul st, st1
       pseti PASM_TV_3e81671499c75
       push [PASM_TV_3e81671499c75]
       push [a]
       push [a]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e8167149ea95
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e8167149ea95
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fadd st, st1
       pseti PASM_TV_3e8167149ea95
       push [PASM_TV_3e8167149ea95]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e816714a38b5
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e816714a38b5
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fsub st, st1
       pseti PASM_TV_3e816714a38b5
       push [PASM_TV_3e816714a38b5]
       pmkv c
       pop [PASM_TV_OP1]
       pc2i c
       pgeti PASM_TV_3e816714a38b5
       pseti c
       echo c
       unset PASM_TV_3e816714a38b5
  ÂÂ
;; end what would be PHP code ;;
 ret
section '.data' writeable
;; PHP Variable Defs here... ;;
PASM_TV_OP1    dd     ?
PASM_TV_OP2    dd     ?
b      dd     ?
PASM_TV_3e8167148b215  dd     ?
a      dd     ?
PASM_TV_3e81671490035  dd     ?
PASM_TV_3e81671494e68  dd     ?
PASM_TV_3e81671499c75  dd     ?
PASM_TV_3e8167149ea95  dd     ?
PASM_TV_3e816714a38b5  dd     ?
c      dd     ?
[1] - The 'echo c' mnemonic was added manually, just so I could test to see if $c actually contained the value it should.
This assembler program is compiled using fasm:
# fasm mytest.asm mytest.o
# gcc -o mytest mytest.o
# ./mytest
1480[PASM:INFO] Shut down of PASM application started
[PASM:INFO] Successful Termination of Application
#
The [PASM:INFO] stuff is debugging information. Hopefully I'll have more time soon to work on this, but unfortunately the PASM project doesn't pay the bills ;)
For those of you who haven't visited the projects page yet, a side project of mine that I have been working on is PASM. Basically, this is the first known attempt at true machine-language code generation (Marco is working on a PHP->C converter). The application itself consists of three separate pieces -- the ASM backend library and memory manager (written from scratch by me), a PHP module which takes over the Zend engine to produce a associative array representing the compiled script, and a the PASM application (written in PHP) which pulls to two of them together.
Want the (very, very simple) test script and the resulting ASM code? Read on... I'm very interested in hearing what people think, comments welcome!
The trivial test script:
<?php
      $b = 5;
       $a = $b + $b;
      $c = (($a + $b) ($a $a)) - ($a + $a);
?>
The resulting[1] assembly-code output when compiled using PASM:
format ELF
use32
include 'cdecl.inc'     ÂÂ
include 'pasm_lib.inc'    ÂÂ
include 'externs.inc'    ÂÂ
include 'mem_manager.inc'   ÂÂ
include 'debug.inc'    ÂÂ
include 'pasm_var_macros.inc'  ÂÂ
section '.text' executable
 public main
main:
 ccall pasm_initapp, NULL
 call __pasm_script_main
 ccall pasm_exitapp, NULL
 ret
ÂÂ
__pasm_script_main:
;; begin what would be PHP code ;;
       pmkv b
       pc2i dword b
       dconst PASM_TC_3e816714863fb, 5
       pseti b, PASM_TC_3e816714863fb.lo, PASM_TC_3e816714863fb.hi
       push [b]
       push [b]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e8167148b215
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e8167148b215
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fadd st, st1
       pseti PASM_TV_3e8167148b215
       push [PASM_TV_3e8167148b215]
       pmkv a
       pop [PASM_TV_OP1]
       pc2i a
       pgeti PASM_TV_3e8167148b215
       pseti a
       unset PASM_TV_3e8167148b215
       push [a]
       push [b]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e81671490035
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e81671490035
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fadd st, st1
       pseti PASM_TV_3e81671490035
       push [PASM_TV_3e81671490035]
       push [a]
       push [a]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e81671494e68
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e81671494e68
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fmul st, st1
       pseti PASM_TV_3e81671494e68
       push [PASM_TV_3e81671494e68]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e81671499c75
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e81671499c75
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fmul st, st1
       pseti PASM_TV_3e81671499c75
       push [PASM_TV_3e81671499c75]
       push [a]
       push [a]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e8167149ea95
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e8167149ea95
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fadd st, st1
       pseti PASM_TV_3e8167149ea95
       push [PASM_TV_3e8167149ea95]
       pop [PASM_TV_OP1]
       pop [PASM_TV_OP2]
       pmkv PASM_TV_3e816714a38b5
       pc2i PASM_TV_OP1
       pc2i PASM_TV_OP2
       pc2i dword PASM_TV_3e816714a38b5
       pgeti PASM_TV_OP1
       pgeti PASM_TV_OP2
       fsub st, st1
       pseti PASM_TV_3e816714a38b5
       push [PASM_TV_3e816714a38b5]
       pmkv c
       pop [PASM_TV_OP1]
       pc2i c
       pgeti PASM_TV_3e816714a38b5
       pseti c
       echo c
       unset PASM_TV_3e816714a38b5
  ÂÂ
;; end what would be PHP code ;;
 ret
section '.data' writeable
;; PHP Variable Defs here... ;;
PASM_TV_OP1    dd     ?
PASM_TV_OP2    dd     ?
b      dd     ?
PASM_TV_3e8167148b215  dd     ?
a      dd     ?
PASM_TV_3e81671490035  dd     ?
PASM_TV_3e81671494e68  dd     ?
PASM_TV_3e81671499c75  dd     ?
PASM_TV_3e8167149ea95  dd     ?
PASM_TV_3e816714a38b5  dd     ?
c      dd     ?
[1] - The 'echo c' mnemonic was added manually, just so I could test to see if $c actually contained the value it should.
This assembler program is compiled using fasm:
# fasm mytest.asm mytest.o
# gcc -o mytest mytest.o
# ./mytest
1480[PASM:INFO] Shut down of PASM application started
[PASM:INFO] Successful Termination of Application
#
The [PASM:INFO] stuff is debugging information. Hopefully I'll have more time soon to work on this, but unfortunately the PASM project doesn't pay the bills ;)
For those of you who were watching the Oscars, you might have noticed the ridiculus political rants of Michael Moore regarding Bush and the war on Iraq... It was bad enough when he was bitching that the whole thing was rigged so he'd lose -- so much for a conspiracy theory on that one, huh?
For those of you who weren't fortunate enough to listen to this moron's rants (which were rightfully greeted with a number of boos):
"On behalf of our producers Kathleen Glynn and Michael Donovan from Canada, I'd like to thank the Academy for this.I have invited my fellow documentary nominees on the stage with us, and we would like to — they're here in solidarity with me because we like nonfiction.We like nonfiction and we live in fictitious times.We live in the time where we have fictitious election results that elects a fictitious president.We live in a time where we have a man sending us to war for fictitious reasons. Whether it's the fictition of duct tape or fictition of orange alerts we are against this war, Mr. Bush. Shame on you, Mr. Bush, shame on you. And any time you got the Pope and the Dixie Chicks against you, your time is up. Thank you very much. "
Of course, for someone talking about fiction he has no problems making of ficitious words like fictition... but hey, what do you expect for a hypocritical two-bit who makes a living doing PR stunts and talking out of his ass.
For those of you who were watching the Oscars, you might have noticed the ridiculus political rants of Michael Moore regarding Bush and the war on Iraq... It was bad enough when he was bitching that the whole thing was rigged so he'd lose -- so much for a conspiracy theory on that one, huh?
For those of you who weren't fortunate enough to listen to this moron's rants (which were rightfully greeted with a number of boos):
"On behalf of our producers Kathleen Glynn and Michael Donovan from Canada, I'd like to thank the Academy for this.I have invited my fellow documentary nominees on the stage with us, and we would like to — they're here in solidarity with me because we like nonfiction.We like nonfiction and we live in fictitious times.We live in the time where we have fictitious election results that elects a fictitious president.We live in a time where we have a man sending us to war for fictitious reasons. Whether it's the fictition of duct tape or fictition of orange alerts we are against this war, Mr. Bush. Shame on you, Mr. Bush, shame on you. And any time you got the Pope and the Dixie Chicks against you, your time is up. Thank you very much. "
Of course, for someone talking about fiction he has no problems making of ficitious words like fictition... but hey, what do you expect for a hypocritical two-bit who makes a living doing PR stunts and talking out of his ass.
The Observer (a UK based news agency) reports: "The United States is conducting a secret 'dirty tricks' campaign against UN Security Council delegations in New York as part of its battle to win votes in favour of war against Iraq." An interesting read if nothing else. For those who want to get straight to it:
I'm assuming RT (regarding the memo) means "Regional Targets"... does anyone have thoughts on what QRC could stand for?
The Observer (a UK based news agency) reports: "The United States is conducting a secret 'dirty tricks' campaign against UN Security Council delegations in New York as part of its battle to win votes in favour of war against Iraq." An interesting read if nothing else. For those who want to get straight to it:
I'm assuming RT (regarding the memo) means "Regional Targets"... does anyone have thoughts on what QRC could stand for?
I was trying to get things in order for my trips, etc. today and I happened to go to PHP-Con's web site (where I will be speaking late April... actually I think I'm speaking on my birthday..) and what did I find but front-and-center a picture of yours truly. It's the result of a tounge-in-cheek interview I did for them a bit back, and when I saw it I just started laughing... perhaps it was that my picture really did look blue (so blue they even bothered to comment on it @ the web site).. or maybe its just I can't possibly take myself that seriously :) If your bored and want a good laugh at my expense, feel free to check it out.
I was trying to get things in order for my trips, etc. today and I happened to go to PHP-Con's web site (where I will be speaking late April... actually I think I'm speaking on my birthday..) and what did I find but front-and-center a picture of yours truly. It's the result of a tounge-in-cheek interview I did for them a bit back, and when I saw it I just started laughing... perhaps it was that my picture really did look blue (so blue they even bothered to comment on it @ the web site).. or maybe its just I can't possibly take myself that seriously :) If your bored and want a good laugh at my expense, feel free to check it out.
Well, that was a good waste of a few hours...
I started out the day trying to do some simple tasks on my virtual server which this and my other websites are hosted from. Yes, it's one of those silly systems that make it "seem" like you have your own machine but really don't... turns out they tend to be quite insecure, as I found out when I realized my webserver was running as superuser (including child processes).
It all started when I successfully moved my CVS repository to my VS today and was in the process of setting up a web-based CVS viewing software when I realized something... When I did a ls -l in my htdocs directory I found...
drwxr-xr-x 15 admin admin 4096 Mar 18 18:03 coggeshall.org
"admin" is my equivlent superuser account for my virtual server..
I was perplexed, as my site shouldn't have been working with this set of permissions -- yet everything worked fine! My next step was to check out the processes with a quick 'ps' and I realized my apache was running as superuser... It wasn't my fault, my httpd.conf file was just fine and everything should have been running as 'web'.
Finally, I gave up and called the hosting company I use (which anyone who is really interested can e-mail me to find out the name) and spent the next 4 hours trying to figure out what was going on... Unforunately the hosting support wasn't the best in the world (he sounded like a newbie, but weren't we all at some point?) and it took me writing this script:
<?php
       $fr = fopen("/etc/passwd", 'a');
        fputs($fr, "testing");
       fclose($fr);
?>
To convince him that the web server really was improperly configured... eventually he called the system admin who had the day off and everything got fixed..
The moral? I've learned that VS servers are sketchy (but cheap), and to pay much closer attention when I'm doing things..