Re: Retired programmer wants to learn programming



In article <43E22B8D.3690913E@xxxxxxxxx>, cbfalconer@xxxxxxxxx says...
Gerry Quinn wrote:
cbfalconer@xxxxxxxxx says...

There is a major difference between creating an executable function
and modifying existing code. As an example, way back when, the
8080 had only i/o instructions of the immediate form "in port" and
"out port". This was not satisfactory for my purposes, so I wrote
a routine that received the value of port, created the sequence:

in port (or "out port")
ret
nop

on the stack, and called it. It then returned the result. Worked
just fine, was freely interruptible and re-entrant, etc. It was
minisculely slower than raw code, but avoided all sorts of
recompilation and/or assembly etc.

That IS self-modifying code. Your executable adds machine code to
itself, and executes it.

No it isn't. It has none of the disadvantages of
self-modification. The code is pure and re-entrant. Think of an
extremely small compiler and code generator buried within an
application.

It may be pure and re-entrant, but it is still self-modifying code.
Deal with it.

- Gerry Quinn



.



Relevant Pages

  • Re: Retired programmer wants to learn programming
    ... If you can create and execute a function X, ... "out port". ... That IS self-modifying code. ... The code is pure and re-entrant. ...
    (comp.programming)
  • [PATCH] drivers/cdrom/cm206.c trivial check_region() fix
    ... stick with pure reads for a while. ... Hope that 8 possible ranges, ... 15 bits of one port and 6 of another make things ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • ANSI types of Win32 variables
    ... I'm recompiling an MFC app as a pure C++ library so I can port it to ... Linux. ...
    (microsoft.public.vc.mfc)
  • TK IP protocol tester
    ... I vaguely remember a (pure) TK app was written by someone to test IP ... It's like a telnet client/server which you can change the ... port number to connect or listen, then you can send/receive data on ...
    (comp.lang.tcl)