In service to this idea, I wrote a simple program that loads into your process's P1 space, and at one minute or one second intervals, formats the current time and stores in in your DCL prompt. I had grown weary of having people at work that would say "I can do it at home on my PeeCee, why can't we do it on the VAX?"
The program allocates some space in your process's P1 space, and copies the code to do the work to it. That code calls $settimr to schedule an AST that modifies your prompt with the current time. It also reschedules itself to run again after a minute (or second) have elapsed.
P1 space doesn't get run down when an image exits, so all of this endures through the life of your process. Not really all that much to it.
Since the code is copied to a different address than it was linked at, is is necessary for it to be PIC - position independent code. That's not too tough to do on a VAX - you access locations that are within the code being moved using addressing modes that are relative to the PC, and you access locations that are outside of the code being moved by absolute addresses.
That is. inside the code to be relocated, use
mov zeep,r0
(other code and data)
zeep: long 666
The mov zeep,r0 uses relative mode, and after relocation, zeep is still the same distance away from the instruction as it was when it was assembled.
If zeep is not part of the code being relocated, but is a location outside of it, use absolute mode to access it.
mov @#zeep,r0
That's it in a nutshell. Register mode is always good
mov r2,r5
Is PIC,.But, if you are moving or using addresses in the registers, it will take a little thought to keep it PIC.
SImple, nicht wahr? Well, it gets easier with practice.
So here it is - minute_clock will update every minute. Second_clock will update every second.
To use...
$ mac minute_clock
$ mac second_clock
$ link minute_clock
$ link second_clock
$ run minute_clock
13:29>
or
$ run second_clock
$ 13:29:23>
Per login session, don't run more than once, or run both versions - these programs don't unload until you log out, so it would be wasteful to get more than one copy running in your process.
No comments:
Post a Comment
Comments?