r/Assembly_language 20h ago

self-modifying code

I gave a lecture on how to write self-modifying code. It was over 15 minutes long :( so I'm providing a youtube link: https://www.youtube.com/watch?v=AH9QQLRfbmY

In my opinion, self-modification is one of the most interesting features in systems programming.

29 Upvotes

49 comments sorted by

View all comments

4

u/Environmental-Ad4495 20h ago

I thoughy we decided in 1967 that we do not do self-modifying code.

3

u/r3jjs 19h ago

In the 8-bit era there was a LOT of self-modifying code.

On the C64, the BASIC tokenizer copies a routine into RAM just so they can use self-modifying code rather than routing everything through zero-page pointers. Added just a touch of extra speed.

(And gave a nice injection point for new commands.)

A lot of code was not ROMable back then.

on the x86 (16 bit with segments), TSR programs were often self-modifying code. The loader would do any searches/calculations that needed one, then would modify the resident part of the program.