General > General Technical Chat

ASM programming is FASCINATING!

<< < (13/24) > >>

MK14:

--- Quote from: tggzzz on July 30, 2020, 08:26:32 am ---Both those points are true. Nonetheless, your original contention that self-modifying code won't work on modern processors isn't true.

Cache coherence is found in any general-purpose SMP computer, and is a severe limitation on scalability.

--- End quote ---

>>"self-modifying code won't work on modern processors isn't true".

Many (not all) electronics/embedded processors (MCUs) these days, have Harvard architecture's, and the code can only reside in flash memory. (**Yes I know, some do let you run code in ram).

I.e. No self-modifying code (ignoring continually rewriting flash memory techniques, which would risk wearing out the flash and would be relatively slow, continually erasing/rewriting the flash, usually).

tggzzz:

--- Quote from: MK14 on July 30, 2020, 08:37:02 am ---
--- Quote from: tggzzz on July 30, 2020, 08:26:32 am ---Both those points are true. Nonetheless, your original contention that self-modifying code won't work on modern processors isn't true.

Cache coherence is found in any general-purpose SMP computer, and is a severe limitation on scalability.

--- End quote ---

>>"self-modifying code won't work on modern processors isn't true".

Many (not all) electronics/embedded processors (MCUs) these days, have Harvard architecture's, and the code can only reside in flash memory. (**Yes I know, some do let you run code in ram).

I.e. No self-modifying code (ignoring continually rewriting flash memory techniques, which would risk wearing out the flash and would be relatively slow, continually erasing/rewriting the flash, usually).

--- End quote ---

True, but "modern processor" != "embedded MCU", any more than all black birds are crows.

I remember seeing a C compiler get around the limitations of an instruction set by building a subroutine on the stack, and then execute it.

Nusa:
To the OP that's just having fun learning, I recommend the following book:
https://www.academia.edu/36492595/Prosser_The_Art_of_Digital_Design_2ed

That digital copy is free, but a new or used paper copy is easy to buy if you prefer that.

Disclaimer: I've known the authors my entire life as family friends and colleagues of my father. Also, I was one of those that did the labwork covered in the book (wirewrapping and testing their PDP-8 design) before the book was published. Winkel passed away four years ago, but Prosser is still moving. Dad died last October, age 88.

MK14:

--- Quote from: tggzzz on July 30, 2020, 09:19:04 am ---True, but "modern processor" != "embedded MCU", any more than all black birds are crows.

--- End quote ---

Doesn't make any difference.
Because I was effectively trying to say (in summary):
SOME modern processors, don't allow self-modifying code.

So, since many embedded MCU's are modern processors, what I said still stands and is correct.

I.e. If some crows, have Covid. Then it would be true that at least some black birds have Covid.

I would have needed to say, if ALL crows have Covid, then I couldn't say "ALL black birds have Covid", as that would not be necessarily correct.

Berni:
Hraward architecture MCUs are sort of the old way of doing things these days. But yes self modifying code is indeed problematic for those.

These days modern high performance MCUs are moving away from dedicated flash. The latency is becoming too high to directly execute instruction by instruction from it, so time critical things like interrupt handlers are meant to be put in RAM anyway. Also the manufacturing process optimized for CPUs does not make very dense flash, so megabytes of flash tend to start getting bigger than the CPU itself. For that reason they are now starting to make MCUs with no non volatile memory at all, requiring external memory to hold the program in things like QSPI flash, so copying critical code to RAM becomes even more important.

Loading code from some other memory to RAM and then executing it is technically self modifying code. Tho its more appropriate to call it a bootloader instead.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod