Skip to main content
3 of 11
added 266 characters in body
questiontype
  • 1.1k
  • 8
  • 12

Was Self-modifying-code possible just using BASIC?

Was Self-modifying-code possible just using BASIC ?

  • On commonly affordable home-computers between - Anytime -1984
  • Code that changes its own instructions while it is executing
  • Just using BASIC
  • Not using peek or poke or assembly language

Were there any machines on which the following theoretical / generic example programs might work -

10 Let Line 20 = Print "word"
20 Print "nothing"

Or just -

10 Let Line 10 = Print "word"

Or the following theoretical / generic example program -

10 Print "10 Print "word"" + [ A special Carriage-return function / command that makes the computer accept this as the new 'Line 10' ]

  • In the example above, I'm wondering if you print the new 'Line 10' to the screen, whether there was any special Carriage-return function / command that made the computer accept this as the new 'Line 10', obviously very unlikely there would have been.

I would probably have to ask a separate question to ask -

  • How was Self-modifying-code used to save space
  • Were there any other 'interesting' uses for Self-modifying-code that would have been possible on the machines specified in this question
  • Also, I wonder if you could 'somehow' set a Data-file as the new current program, or even how many programs( surely only one ) or data-files could be held at one time ( there's no way this should be possible via just BASIC, without peek or poke or assembly )
questiontype
  • 1.1k
  • 8
  • 12