[cctalk] Re: Self modifying code was HCF

2024-11-03 Thread Gavin Scott via cctalk
On Sun, Nov 3, 2024 at 10:35 PM Tony Duell via cctalk
 wrote:
> This is one of the few high level languages I've seen with a
> specific instruction for self-modifying code.

Don't forget the ALTER statement in COBOL which changes a GO TO
statement in some paragraph somewhere to point to a different
destination than what's written in the source code.

COBOL has a few funky features. Another one is that you can have a
sequence of Paragraphs:

PARA-A.
PARA-B.
PARA-C.
PARA-D.

And in one place you can say PERFORM PARA-A THROUGH PARA-C, and in
another place PERFORM PARA-B THROUGH PARA-D, etc. which means you have
to somehow pass in the paragraph you want to return from and every
paragraph has to end with a conditional return based on whether it's
the requested exit point. Some machines had special machine
instructions for COBOL Paragraph call and return to help deal with
these and similar oddities.


[cctalk] Re: Self modifying code was HCF

2024-11-03 Thread Tony Duell via cctalk
On Mon, Nov 4, 2024 at 12:05 AM dwight via cctalk  wrote:
>
> I/O addresses for the 8080 come to mind.

BASIC-09 under OS-9 (6809 processor) lets you execute a system call
from a BASIC program. The problem is that a system call is coded as a
software interrupt instruction followed by a byte giving the call
number. So doing that implies self-modifying code. But under OS-9,
code modules are re-entrant and can be called by any process running
on the machine. You could find the process is switched between storing
the call number byte and executing the instruction.

It gets round this by building a trivial program (basically a software
interrupt, the call number byte, and a return instructio) on the user
stack (which is local to each process) and then calling it there.

On the HP9825 with a String Variables ROM and an Advanced Programming
ROM, there is a documented instruction to store the contents of a
string variable as a program line which of course you can then
execute. This is one of the few high level languages I've seen with a
specific instruction for self-modifyng code.

-tony


[cctalk] Re: Self modifying code was HCF

2024-11-03 Thread Chuck Guzis via cctalk
On 11/3/24 15:56, dwight wrote:
> I/O addresses for the 8080 come to mind.
> Dwight

Well, in theory you could avoid that one by constructing 256-entry
tables for IN and OUT instructions and using a computed CALL/JUMP to
access the right one.  The 8080 I/O address space is only 256 addresses.

Not pretty, but a possible solution.

--Chuck



[cctalk] Re: Self modifying code was HCF

2024-11-03 Thread dwight via cctalk
I/O addresses for the 8080 come to mind.
Dwight


From: Chuck Guzis via cctalk 
Sent: Sunday, November 3, 2024 3:36 PM
To: Mike Katz via cctalk 
Cc: Chuck Guzis 
Subject: [cctalk] Re: Self modifying code was HCF

On 11/3/24 14:48, Mike Katz via cctalk wrote:
> Though not Halt and Catch Fire you guys are forgetting the joy of self
> modifying code.

Indeed, this was the *only* way to do things on early first- and
second-generation systems.  Even the lowly 1620 CADET, without the
optional indirect addressing feature mandated use of code modification.

--Chuck



[cctalk] Re: Self modifying code was HCF

2024-11-03 Thread Chuck Guzis via cctalk
On 11/3/24 14:48, Mike Katz via cctalk wrote:
> Though not Halt and Catch Fire you guys are forgetting the joy of self
> modifying code.

Indeed, this was the *only* way to do things on early first- and
second-generation systems.  Even the lowly 1620 CADET, without the
optional indirect addressing feature mandated use of code modification.

--Chuck



[cctalk] Re: Self modifying code was HCF

2024-11-03 Thread Mike Katz via cctalk
Though not Halt and Catch Fire you guys are forgetting the joy of self 
modifying code.


That is how many PDP-8 programs worked.  Even the bin loader where the 
jump to loop instruction would be replaced with a jump to loaded program 
start by the loader itself.


There were many programs that were very difficult to figure out what 
they were doing, due to using this technique.


I love the PDP-8 but I don't miss self modifying code at all.


On 11/3/2024 4:03 PM, Paul Koning via cctalk wrote:



On Nov 3, 2024, at 4:59 PM, Mychaela Falconia  wrote:

Paul Koning wrote:


1. Show a one-word PDP-11 program that writes all of memory, in reverse order.

MOV -(PC),-(PC)

I remember this one from late-Soviet/early-Russian BK0010 hacker clubs...
BK0010 was a "home computer" built around 1801VM1 microprocessor, a
Soviet implementation of basic PDP-11 instruction set.  No idea exactly
which DEC model it corresponds to, if any.


2. Show a one-word PDP-11 program that clears all of memory,
in forward order, halting on completion.

This one I am struggling with - it's been too many decades since I did
any PDP-11 assembly...

Hint: you get to pick the initial values of the registers.

paul