<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://cpulator.01xz.net/mw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Henry</id>
	<title>CPUlator Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://cpulator.01xz.net/mw/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Henry"/>
	<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/wiki/Special:Contributions/Henry"/>
	<updated>2026-05-13T03:41:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Privacy&amp;diff=122</id>
		<title>MediaWiki:Privacy</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Privacy&amp;diff=122"/>
		<updated>2024-10-02T11:36:46Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;-&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Disclaimers&amp;diff=121</id>
		<title>MediaWiki:Disclaimers</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Disclaimers&amp;diff=121"/>
		<updated>2024-10-02T11:36:21Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;-&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;-&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Contactpage-subject-feedback&amp;diff=120</id>
		<title>MediaWiki:Contactpage-subject-feedback</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Contactpage-subject-feedback&amp;diff=120"/>
		<updated>2024-10-02T09:10:10Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CPUlator feedback&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Contactpage-subject-feedback&amp;diff=119</id>
		<title>MediaWiki:Contactpage-subject-feedback</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Contactpage-subject-feedback&amp;diff=119"/>
		<updated>2024-10-02T09:09:47Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;CPUlator wiki feedback&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CPUlator wiki feedback&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Contactpage-pagetext-feedback&amp;diff=118</id>
		<title>MediaWiki:Contactpage-pagetext-feedback</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Contactpage-pagetext-feedback&amp;diff=118"/>
		<updated>2024-10-02T09:05:50Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;Use this form if you have a suggestion or a bug to report.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Use this form if you have a suggestion or a bug to report.&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Mainpage-title&amp;diff=117</id>
		<title>MediaWiki:Mainpage-title</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=MediaWiki:Mainpage-title&amp;diff=117"/>
		<updated>2024-10-02T06:51:39Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;CPUlator Help&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CPUlator Help&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryStackRedZone&amp;diff=114</id>
		<title>Msg/MemoryStackRedZone</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryStackRedZone&amp;diff=114"/>
		<updated>2019-09-30T00:50:55Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A stack frame is a region of memory used by an executing function. The memory region at or above the stack pointer is allocated stack space that may be used, while addresses less than the stack pointer may not be used until allocated first. This warning tells you that a memory access attempted to use memory that is near, but below the stack pointer. It is likely (but not necessarily) a bug in allocating, using, and deallocating stack space.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	mov sp, #0x1000			// Initialize SP to something sane    &lt;br /&gt;
	bl Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	str r0, [sp, #-4]		// Store to stack space we haven&#039;t allocated yet&lt;br /&gt;
	sub sp, #4				// Allocate stack space: Too late.&lt;br /&gt;
	add sp, #4				// Deallocate stack space&lt;br /&gt;
	bx lr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movi sp, 0x1000			# Initialize SP to something sane    &lt;br /&gt;
	call Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	stw r0, -4(sp)			# Store to stack space we haven&#039;t allocated yet&lt;br /&gt;
	subi sp, sp, 4			# Allocate stack space: Too late.&lt;br /&gt;
	addi sp, sp, 4			# Deallocate stack space&lt;br /&gt;
	ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	li $sp, 0x1000			# Initialize SP to something sane    &lt;br /&gt;
	jal Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	sw $0, -4($sp)			# Store to stack space we haven&#039;t allocated yet&lt;br /&gt;
	addiu $sp, $sp, -4		# Allocate stack space: Too late.&lt;br /&gt;
	addiu $sp, $sp, 4		# Deallocate stack space&lt;br /&gt;
	jr $ra&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above examples, the stack pointer is 0x1000, but a memory access occurred to 0x0ffc, which is not part of the stack because it is below the stack pointer value (0x1000). &lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Check that any stack space needed by a function is allocated before being used. Also ensure that stack space is not used after being deallocated.&lt;br /&gt;
* Another common cause is overrunning the beginning of arrays that are located on the stack while iterating over them (also called a &amp;quot;buffer overflow&amp;quot;, a well-known cause of security vulnerabilities). Check the addresses of the memory access and ensure that it makes sense.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and compares the address of each memory access to the stack pointer at the beginning of the function. This warning is generated if a memory access hits the 128-byte region immediately below the stack pointer. This warning is generated at the memory load or store.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory access to unallocated stack space}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/StackDeallocatedParentFrame&amp;diff=113</id>
		<title>Msg/StackDeallocatedParentFrame</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/StackDeallocatedParentFrame&amp;diff=113"/>
		<updated>2019-03-17T04:14:51Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A stack frame is a region of memory used by an executing function. When calling a function, the child function&#039;s stack frame is at a lower address than the caller&#039;s stack frame. New stack space is allocated by decrementing the stack pointer, and stack space is deallocated by incrementing the stack pointer. However, a function should not deallocate the parent function&#039;s stack frame. In other words, the stack pointer should never be greater than the value at the beginning of the function. This warning tells you that the stack pointer has increased past the value it had at the beginning of the current function.&lt;br /&gt;
&lt;br /&gt;
This is a more stringent requirement than simply requiring the stack pointer to be restored to its original value at the end of the function. Because an interrupt can occur at any moment, if the stack pointer increases beyond the current stack frame (deallocating the parent&#039;s stack frame) even momentarily, the parent function may lose some of its stack values because an interrupt handler may have executed and used the &amp;quot;free&amp;quot; stack space below the stack pointer.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	mov sp, #0x1000			// Initialize SP to something sane    &lt;br /&gt;
	bl Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	add sp, #4				// Deallocate 4 bytes of the caller&#039;s stack frame&lt;br /&gt;
	sub sp, #4				// Can&#039;t do this even if the operation is reverted&lt;br /&gt;
	bx lr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movi sp, 0x1000			# Initialize SP to something sane    &lt;br /&gt;
	call Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	addi sp, sp, 4			# Deallocate 4 bytes of the caller&#039;s stack frame&lt;br /&gt;
	subi sp, sp, 4			# Can&#039;t do this even if the operation is reverted&lt;br /&gt;
	ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	li $sp, 0x1000			# Initialize SP to something sane    &lt;br /&gt;
	jal Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	addiu $sp, $sp, 4		# Deallocate 4 bytes of the caller&#039;s stack frame&lt;br /&gt;
	addiu $sp, $sp, -4		# Can&#039;t do this even if the operation is reverted&lt;br /&gt;
	jr $ra&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above examples, the stack pointer is initialized to 0x1000. The child function Func can allocate and deallocate stack space below the stack pointer (currently 0x1000). It is not allowed to deallocate the parent&#039;s stack frame. The child function here attempts to move the stack pointer to 0x1004. This results in the warning: &#039;&#039;&#039;Stack pointer moved beyond current stack frame. sp at beginning of current function was 00001000&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The message also reminds you that the stack pointer was 0x1000 at the beginning of the function, and that the stack pointer has increased beyond this point (to 0x1004).&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Normally, all stack pointer manipulations are matched: decrease the stack pointer when entering a function, and increase the stack pointer immediately before returning. &lt;br /&gt;
* Carefully trace through any operations that change the stack pointer. Make sure they&#039;re all matched (every decrement is matched by an increment of the same amount). Ensure that the function prologue and epilogue only execute once (not accidentally part of a loop).&lt;br /&gt;
* The two places where stack pointer manipulations often occur are at the function prologue and epilogue, and allocating and deallocating arguments passed on the stack when calling a function. These operations are all matched. If your function uses the stack pointer for other purposes, this is an easy source of bugs.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and compares the current stack pointer to the stack pointer at the beginning of the function. This warning is generated at the instruction that modifies the stack pointer.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|SP moved beyond current stack frame}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryStackRedZone&amp;diff=112</id>
		<title>Msg/MemoryStackRedZone</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryStackRedZone&amp;diff=112"/>
		<updated>2019-03-17T04:12:05Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A stack frame is a region of memory used by an executing function. The memory region at or above the stack pointer is allocated stack space that may be used, while addresses less than the stack pointer may not be used until allocated first. This warning tells you that a memory access attempted to use memory that is near, but below the stack pointer. It is likely (but not necessarily) a bug in allocating, using, and deallocating stack space.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	mov sp, #0x1000			// Initialize SP to something sane    &lt;br /&gt;
	bl Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	str r0, [sp, #-4]		// Store to stack space we haven&#039;t allocated yet&lt;br /&gt;
	sub sp, #4				// Allocate stack space: Too late.&lt;br /&gt;
	add sp, #4				// Deallocate stack space&lt;br /&gt;
	bx lr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movi sp, 0x1000			# Initialize SP to something sane    &lt;br /&gt;
	call Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	stw r0, -4(sp)			# Store to stack space we haven&#039;t allocated yet&lt;br /&gt;
	subi sp, sp, 4			# Allocate stack space: Too late.&lt;br /&gt;
	addi sp, sp, 4			# Deallocate stack space&lt;br /&gt;
	ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	li $sp, 0x1000			# Initialize SP to something sane    &lt;br /&gt;
	jal Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	sw $0, -4($sp)			# Store to stack space we haven&#039;t allocated yet&lt;br /&gt;
	addiu $sp, $sp, -4		# Allocate stack space: Too late.&lt;br /&gt;
	addiu $sp, $sp, 4		# Deallocate stack space&lt;br /&gt;
	jr $ra&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above examples, the stack pointer is 0x1000, but a memory access occurred to 0x0ffc, which is not part of the stack because it is below the stack pointer value (0x1000). &lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Check that any stack space needed by a function is allocated before used.&lt;br /&gt;
* Another common cause is overrunning the beginning of arrays that are located on the stack while iterating over them (also called a &amp;quot;buffer overflow&amp;quot;, a well-known cause of security vulnerabilities). Check the addresses of the memory access and ensure that it makes sense.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and compares the address of each memory access to the stack pointer at the beginning of the function. This warning is generated if a memory access hits the 128-byte region immediately below the stack pointer. This warning is generated at the memory load or store.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory access to unallocated stack space}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryMisaligned&amp;diff=111</id>
		<title>Msg/MemoryMisaligned</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryMisaligned&amp;diff=111"/>
		<updated>2019-03-17T04:07:21Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Memory accesses need to be aligned. The memory address must be a multiple of the size of the access. For example, a 4-byte load must use an address that is a multiple of 4 bytes. This message says that the memory access was not properly aligned.&lt;br /&gt;
&lt;br /&gt;
Attempting a misaligned memory access may throw an exception, or result in a load or store that doesn&#039;t behave as you would expect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, [pc,#1]			// Load 4-byte word from a misaligned address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldw r2, 1(r0)			# Load 4-byte word from a misaligned address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	lw $v0, 1($0)			# Load 4-byte word from a misaligned address&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above examples try to load from an address that isn&#039;t a multiple of 4, but a 4-byte (word-sized) access must be to an address that is a multiple of 4 bytes. The warning message tells you the address the memory access attempted to access.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Start by looking at the address used for the memory access (which base register and what offset). Then look at how the address is calculated and why it became incorrect.&lt;br /&gt;
* Also check that you are using the correct size memory access. For example, when iterating over a byte array (also called a &amp;quot;string&amp;quot;), each element is one byte, so a byte-sized load or store needs to be used.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator checks alignment for all memory accesses. This warning is generated while executing the load or store.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory access misaligned}} If the processor throws an alignment exception, disabling the warning message does not change the behaviour of the processor, and the alignment exception will still be thrown.&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=110</id>
		<title>Msg/FunctionNestCount</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=110"/>
		<updated>2019-03-17T04:06:03Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the function call depth to be very large. This warning tells you that you have exceeded 32 nested function calls.&lt;br /&gt;
&lt;br /&gt;
Deep function call nesting isn&#039;t technically an error. If your program really uses more than 32 nested functions, disable this warning. If not, this is likely indicative of a bug.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
	bl NotAFunction		// This is a function call, but the target doesn&#039;t behave like a function (no return).&lt;br /&gt;
    nop&lt;br /&gt;
NotAFunction:	&lt;br /&gt;
    b _start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
	call NotAFunction		# This is a function call, but the target doesn&#039;t behave like a function (no return).&lt;br /&gt;
    nop&lt;br /&gt;
NotAFunction:	&lt;br /&gt;
    br _start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
	jal NotAFunction		# This is a function call, but the target doesn&#039;t behave like a function (no return).&lt;br /&gt;
    nop&lt;br /&gt;
NotAFunction:	&lt;br /&gt;
    b _start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The call at line 4 repeatedly calls a function that never returns. The function call depth increases by one every time the call is executed. The Call stack will show a stack of calls originating from line 4.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Make sure functions are returning, not stuck in an unending recursion.&lt;br /&gt;
* Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction.&lt;br /&gt;
* Use the [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Call stack window&#039;&#039;&#039;] (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call instruction in the function one nesting level up.&lt;br /&gt;
* The [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Trace window&#039;&#039;&#039;] may also be useful to see the last 200 instructions executed.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator tracks idiomatic call and return instructions and counts the function call nesting depth. This message is generated at a call instruction when the new call depth exceeds 32.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function nesting too deep}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=109</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=109"/>
		<updated>2019-03-17T04:04:44Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
	str r0, [pc, #4]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop&lt;br /&gt;
	nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
	stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop						# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	li $v0, 0x24630001		# An opcode&lt;br /&gt;
	sw $v0, 0x10($0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop						# This instruction gets changed to an addiu (opcode 0x24630001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can pause the program (like a breakpoint) whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=108</id>
		<title>Msg/FetchBadPC</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=108"/>
		<updated>2019-03-17T04:00:04Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* ARMv7 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from a code section (such as &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt;) from an executable file generated by an assembler or compiler. This message tells you that the simulator thinks you&#039;re currently executing outside a code section.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
    nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
(This example uses two nops in the .text section for ARM because the assembler pads the length of the .text section to a multiple of 8 bytes.)&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the examples above show, one of the common reasons for encountering this warning is that the program runs past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section and starts executing in the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section. Although the first 32-bit word of the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is a valid opcode in this example, executing instructions from the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is usually unintended.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* As in the examples above, make sure your program isn&#039;t executing past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section.&lt;br /&gt;
* Executing from a bad location could also be due to a branch with an incorrect target address. To find the offending branch, try using the [https://cpulator.01xz.net/doc/#callstack &amp;lt;b&amp;gt;Trace window&amp;lt;/b&amp;gt;] (located in the same panel as the registers window by default) to look backwards in the program execution.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
ELF executables contain &amp;quot;sections&amp;quot; of bytes that define where in memory each blob of bytes in the executable should be loaded. The ELF executable also includes information on whether each section is intended for executable code (e.g., the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section contains code) or for data (the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is marked as containing data). The simulator tracks the sections defined in the most recently loaded ELF executable, and checks each instruction fetch against the sections. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
There may be uncommon cases where the simulator&#039;s idea of what is a code section doesn&#039;t match reality, and you may want to disable this warning. Some examples:&lt;br /&gt;
* Your program writes code into a data section and then executes it. In this case, executing from a data section really is the right thing to do.&lt;br /&gt;
* Your program has multiple ELF executables. The simulator uses the section boundaries defined in the most recently loaded ELF executable.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Outside a code section}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=107</id>
		<title>Msg/FetchBadPC</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=107"/>
		<updated>2019-03-17T03:59:55Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* ARMv7 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from a code section (such as &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt;) from an executable file generated by an assembler or compiler. This message tells you that the simulator thinks you&#039;re currently executing outside a code section.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
    nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
(The example uses two nops in the .text section for ARM because the assembler pads the length of the .text section to a multiple of 8 bytes.)&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the examples above show, one of the common reasons for encountering this warning is that the program runs past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section and starts executing in the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section. Although the first 32-bit word of the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is a valid opcode in this example, executing instructions from the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is usually unintended.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* As in the examples above, make sure your program isn&#039;t executing past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section.&lt;br /&gt;
* Executing from a bad location could also be due to a branch with an incorrect target address. To find the offending branch, try using the [https://cpulator.01xz.net/doc/#callstack &amp;lt;b&amp;gt;Trace window&amp;lt;/b&amp;gt;] (located in the same panel as the registers window by default) to look backwards in the program execution.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
ELF executables contain &amp;quot;sections&amp;quot; of bytes that define where in memory each blob of bytes in the executable should be loaded. The ELF executable also includes information on whether each section is intended for executable code (e.g., the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section contains code) or for data (the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is marked as containing data). The simulator tracks the sections defined in the most recently loaded ELF executable, and checks each instruction fetch against the sections. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
There may be uncommon cases where the simulator&#039;s idea of what is a code section doesn&#039;t match reality, and you may want to disable this warning. Some examples:&lt;br /&gt;
* Your program writes code into a data section and then executes it. In this case, executing from a data section really is the right thing to do.&lt;br /&gt;
* Your program has multiple ELF executables. The simulator uses the section boundaries defined in the most recently loaded ELF executable.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Outside a code section}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=106</id>
		<title>Msg/FetchBadPC</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=106"/>
		<updated>2019-03-17T03:57:30Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from a code section (such as &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt;) from an executable file generated by an assembler or compiler. This message tells you that the simulator thinks you&#039;re currently executing outside a code section.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
    nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the examples above show, one of the common reasons for encountering this warning is that the program runs past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section and starts executing in the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section. Although the first 32-bit word of the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is a valid opcode in this example, executing instructions from the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is usually unintended.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* As in the examples above, make sure your program isn&#039;t executing past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section.&lt;br /&gt;
* Executing from a bad location could also be due to a branch with an incorrect target address. To find the offending branch, try using the [https://cpulator.01xz.net/doc/#callstack &amp;lt;b&amp;gt;Trace window&amp;lt;/b&amp;gt;] (located in the same panel as the registers window by default) to look backwards in the program execution.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
ELF executables contain &amp;quot;sections&amp;quot; of bytes that define where in memory each blob of bytes in the executable should be loaded. The ELF executable also includes information on whether each section is intended for executable code (e.g., the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section contains code) or for data (the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is marked as containing data). The simulator tracks the sections defined in the most recently loaded ELF executable, and checks each instruction fetch against the sections. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
There may be uncommon cases where the simulator&#039;s idea of what is a code section doesn&#039;t match reality, and you may want to disable this warning. Some examples:&lt;br /&gt;
* Your program writes code into a data section and then executes it. In this case, executing from a data section really is the right thing to do.&lt;br /&gt;
* Your program has multiple ELF executables. The simulator uses the section boundaries defined in the most recently loaded ELF executable.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Outside a code section}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=105</id>
		<title>Msg/ClobberedSP</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=105"/>
		<updated>2019-03-17T03:55:56Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should always ensure that the stack pointer is the same at the entry and exit of the function. This message tells you that this didn&#039;t happen: the stack pointer was different at the function return than when the function was first called.&lt;br /&gt;
&lt;br /&gt;
If you also clobbered ra, see also [[Msg/ClobberedRA]]&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    # ...&lt;br /&gt;
    &lt;br /&gt;
MyFunction:&lt;br /&gt;
    push {r4}				// Change SP&lt;br /&gt;
    bx lr					// SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    subi sp, sp, 4			# Modify SP&lt;br /&gt;
    ret					# SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    addiu $sp, $0, 0x1000		# Initialize SP&lt;br /&gt;
    jal Function&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    subu $sp, $sp, 4			# Modify SP&lt;br /&gt;
    jr $ra						# SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* This message is complaining that the stack pointer differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the stack pointer at both the function entry and return. Are they the same?&lt;br /&gt;
* The most common way to use the stack pointer is to modify it while pushing and popping values on the stack. When pushes and pops are mismatched, there is a net change in the stack pointer in the function.&lt;br /&gt;
* The two places where stack pointer manipulations often occur are at the function prologue and epilogue, and allocating and deallocating arguments passed on the stack when calling a function. These operations are all matched. If your function modifies the stack pointer for other purposes, change your code so that this doesn&#039;t happen (e.g., copy the stack pointer to another register and modify that, instead of modifying the stack pointer).&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies that they haven&#039;t changed when executing the matching function return. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}} &lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRegs&amp;diff=104</id>
		<title>Msg/ClobberedRegs</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRegs&amp;diff=104"/>
		<updated>2019-03-17T03:52:27Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A calling convention defines which registers a function is allowed to modify (caller-saved), and which registers a function should preserve (callee-saved). Clobbering a register means overwriting its value. This message tells you that there were callee-saved registers (those a function should not modify) that were changed inside the current function.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;8&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	bl Func&lt;br /&gt;
	nop&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	add r4, #1			// Modify a callee-saved register&lt;br /&gt;
	bx lr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;8&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	call Func&lt;br /&gt;
	nop&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	addi r16, r16, 1			# Modify a callee-saved register&lt;br /&gt;
	ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;8&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    jal Func&lt;br /&gt;
    nop&lt;br /&gt;
&lt;br /&gt;
Func:&lt;br /&gt;
    addiu $s0, $s0, 1	# Modify a callee-saved register&lt;br /&gt;
    jr $ra&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* This message is complaining that one or more registers differ between the start of the function and at the function return. Use breakpoints and make a note of the value of those registers at both the function entry and return. Are they the same?&lt;br /&gt;
* If your function wants to (temporarily) modify callee-saved registers, it should preserve its value first, usually by storing the old value onto the stack and restoring it just before leaving the function. Saving and restoring (also called spilling and filling) can go wrong in many ways, such placing the stack at a location that doesn&#039;t contain memory.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies that callee-saved registers haven&#039;t changed when executing the matching function return. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered callee-saved register}}&lt;br /&gt;
The main reason you might consider disabling this warning is if you are intentionally using a non-standard calling convention.&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=103</id>
		<title>Msg/ClobberedRA</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=103"/>
		<updated>2019-03-17T03:50:06Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should normally return to the instruction after the call instruction in the caller that called this function. This message tells you that this didn&#039;t happen: the function return is returning somewhere other than the instruction following the matching call.&lt;br /&gt;
&lt;br /&gt;
If you also clobbered sp, see also [[Msg/ClobberedSP]]&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop					// Should return here&lt;br /&gt;
    nop					// Actually returns here&lt;br /&gt;
    # ...&lt;br /&gt;
&lt;br /&gt;
MyFunction:&lt;br /&gt;
    add lr, #4				// Change LR&lt;br /&gt;
    bx lr					// return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    call Function&lt;br /&gt;
    nop					# Should return here&lt;br /&gt;
    nop					# Actually returns here&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    addi ra, ra, 4			# Modify ra&lt;br /&gt;
    ret					# return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MIPS ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;9&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    jal Function&lt;br /&gt;
    nop					# Should return here&lt;br /&gt;
    nop					# Actually returns here&lt;br /&gt;
&lt;br /&gt;
Function:&lt;br /&gt;
    addiu $ra, $ra, 4	# Modify ra&lt;br /&gt;
    jr $ra				# return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* This message is complaining that the return address (or link address for ARM) differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the return address (ra or lr) at both the function entry and return. Are they the same?&lt;br /&gt;
* Typically, the return address register is not used in a function body except for saving and restoring it to the stack when there is a nested function call. A common cause of the return address changing is a problem during save and restore, e.g., popping from a different location than the corresponding push, or modifying the value that was on the stack. Watch the return address&#039;s save and restore and ensure that both the location on the stack and values are the same.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies at return instructions that the return address matches the location of the matching call. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}}&lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=102</id>
		<title>Msg/DevGpio</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=102"/>
		<updated>2019-03-12T09:37:08Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about the warning messages that can are produced by the GPIO I/O devices. On the Altera University Program computer systems, the same GPIO device is used for switches, push buttons, LEDs, and the 40-pin expansion header.&lt;br /&gt;
&lt;br /&gt;
==== The GPIO device may not support byte, half-word, or misaligned stores. Use aligned word-sized stores. ====&lt;br /&gt;
&lt;br /&gt;
The GPIO devices only work correctly with word-sized accesses. Narrower stores produce undefined results.&lt;br /&gt;
&lt;br /&gt;
The GPIO device hardware ignores the byte-enable signals, so the device treats every access as if it were a word-sized access. This is generally ok with loads, because the device replies with the entire 32-bit value and the CPU extracts part of the word for a narrow (16 or 8 bit) load. This fails for narrow stores because the GPIO device will capture all 32 bits of data, but it is not known what the values of the unused data lines are. (It is probably not random, but it is almost certainly not what you want.)&lt;br /&gt;
&lt;br /&gt;
==== Each bit of the GPIO device&#039;s edge capture register is cleared when a 1 is written to the corresponding bit position. Writing 0 does not clear any edge capture register bits. ====&lt;br /&gt;
&lt;br /&gt;
The edge capture register hardware is designed to clear a bit only when a 1 is written to it. &lt;br /&gt;
&lt;br /&gt;
A long time ago (around Quartus version 13.1 and earlier), writing any value into the edge capture register would clear all bits of the GPIO port&#039;s edge capture register. This was changed somewhere around version 14.0 to require writing a 1 to clear (allowing partially clearing the register), but Altera&#039;s computer system manuals are &#039;&#039;still&#039;&#039; incorrect (as of version 18.0). This warning was added because a non-negligible number of users believed the incorrect documentation and wrote 0 to clear the edge capture register, causing wasted debugging effort.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a snippet of Verilog code from the GPIO port device (comments added by me), showing the behaviour of one bit slice of the edge capture register:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Verilog&amp;quot; highlight=&amp;quot;8,9&amp;quot;&amp;gt;&lt;br /&gt;
assign edge_capture_wr_strobe = chipselect &amp;amp;&amp;amp; ~write_n &amp;amp;&amp;amp; (address == 3);&lt;br /&gt;
&lt;br /&gt;
  always @(posedge clk or negedge reset_n)&lt;br /&gt;
    begin&lt;br /&gt;
      if (reset_n == 0)&lt;br /&gt;
          edge_capture[0] &amp;lt;= 0;&lt;br /&gt;
      else if (clk_en)&lt;br /&gt;
          if (edge_capture_wr_strobe &amp;amp;&amp;amp; writedata[0])   // When writing a 1, clear the edge capture bit.&lt;br /&gt;
              edge_capture[0] &amp;lt;= 0;&lt;br /&gt;
          else if (edge_detect[0])       // When an edge is detected, set the edge capture bit.&lt;br /&gt;
              edge_capture[0] &amp;lt;= -1;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
//...[snip: Replicate once per edge capture bit]&lt;br /&gt;
&lt;br /&gt;
  always @(posedge clk or negedge reset_n)&lt;br /&gt;
    begin&lt;br /&gt;
      if (reset_n == 0)&lt;br /&gt;
        begin&lt;br /&gt;
          d1_data_in &amp;lt;= 0;&lt;br /&gt;
          d2_data_in &amp;lt;= 0;&lt;br /&gt;
        end&lt;br /&gt;
      else if (clk_en)&lt;br /&gt;
        begin&lt;br /&gt;
          d1_data_in &amp;lt;= data_in;&lt;br /&gt;
          d2_data_in &amp;lt;= d1_data_in;    // Two cycles of past history for the data inputs&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    assign edge_detect = ~d1_data_in &amp;amp; d2_data_in;   // two_cycles_ago=1 and one_cycle_ago=0 is an &amp;quot;edge&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Device-specific warnings}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=101</id>
		<title>Msg/DevGpio</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=101"/>
		<updated>2019-03-12T09:35:36Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about the warning messages that can are produced by the GPIO I/O devices. On the Altera University Program computer systems, the same GPIO device is used for switches, push buttons, LEDs, and the 40-pin expansion header.&lt;br /&gt;
&lt;br /&gt;
==== The GPIO device may not support byte, half-word, or misaligned stores. Use aligned word-sized stores. ====&lt;br /&gt;
&lt;br /&gt;
The GPIO devices only work correctly with word-sized accesses. Narrower stores produce undefined results.&lt;br /&gt;
&lt;br /&gt;
The GPIO device hardware ignores the byte-enable signals, so the device treats every access as if it were a word-sized access. This is generally ok with loads, because the device replies with the entire 32-bit value and the CPU extracts part of the word for a narrow (16 or 8 bit) load. This fails for narrow stores because the GPIO device will capture all 32 bits of data, but it is not known what the values of the unused data lines are. (It is probably not random, but it is almost certainly not what you want.)&lt;br /&gt;
&lt;br /&gt;
==== Each bit of the GPIO device&#039;s edge capture register is cleared when a 1 is written to the corresponding bit position. Writing 0 does not clear any edge capture register bits. ====&lt;br /&gt;
&lt;br /&gt;
The edge capture register hardware is designed to clear a bit only when a 1 is written to it. &lt;br /&gt;
&lt;br /&gt;
A long time ago (around Quartus version 13.1 and earlier), writing any value into the edge capture register would clear all bits of the GPIO port&#039;s edge capture register. This was changed somewhere around version 14.0 to require writing a 1 to clear (allowing partially clearing the register), but Altera&#039;s computer system manuals are &#039;&#039;still&#039;&#039; incorrect (as of version 18.0). This warning was added because a non-negligible number of users believed the incorrect documentation and wrote 0 to clear the edge capture register, causing wasted debugging effort.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a snippet of Verilog code from the GPIO port device (comments added by me), showing the behaviour of one bit slice of the edge capture register:&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Verilog&amp;quot; highlight=&amp;quot;8,9&amp;quot;&amp;gt;&lt;br /&gt;
assign edge_capture_wr_strobe = chipselect &amp;amp;&amp;amp; ~write_n &amp;amp;&amp;amp; (address == 3);&lt;br /&gt;
&lt;br /&gt;
  always @(posedge clk or negedge reset_n)&lt;br /&gt;
    begin&lt;br /&gt;
      if (reset_n == 0)&lt;br /&gt;
          edge_capture[0] &amp;lt;= 0;&lt;br /&gt;
      else if (clk_en)&lt;br /&gt;
          if (edge_capture_wr_strobe &amp;amp;&amp;amp; writedata[0])   // When writing a 1, clear the edge capture bit.&lt;br /&gt;
              edge_capture[0] &amp;lt;= 0;&lt;br /&gt;
          else if (edge_detect[0])       // When an edge is detected, set the edge capture bit.&lt;br /&gt;
              edge_capture[0] &amp;lt;= -1;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
...[snip]&lt;br /&gt;
&lt;br /&gt;
  always @(posedge clk or negedge reset_n)&lt;br /&gt;
    begin&lt;br /&gt;
      if (reset_n == 0)&lt;br /&gt;
        begin&lt;br /&gt;
          d1_data_in &amp;lt;= 0;&lt;br /&gt;
          d2_data_in &amp;lt;= 0;&lt;br /&gt;
        end&lt;br /&gt;
      else if (clk_en)&lt;br /&gt;
        begin&lt;br /&gt;
          d1_data_in &amp;lt;= data_in;&lt;br /&gt;
          d2_data_in &amp;lt;= d1_data_in;    // Two cycles of past history for the data inputs&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    assign edge_detect = ~d1_data_in &amp;amp; d2_data_in;   // two_cycles_ago=1 and one_cycle_ago=0 is an &amp;quot;edge&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Device-specific warnings}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=100</id>
		<title>Msg/DevGpio</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=100"/>
		<updated>2019-03-12T09:34:44Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Each bit of the GPIO device&amp;#039;s edge capture register is cleared when a 1 is written to the corresponding bit position. Writing 0 does not clear any edge capture register bits. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about the warning messages that can are produced by the GPIO I/O devices. On the Altera University Program computer systems, the same GPIO device is used for switches, push buttons, LEDs, and the 40-pin expansion header.&lt;br /&gt;
&lt;br /&gt;
==== The GPIO device may not support byte, half-word, or misaligned stores. Use aligned word-sized stores. ====&lt;br /&gt;
&lt;br /&gt;
The GPIO devices only work correctly with word-sized accesses. Narrower stores produce undefined results.&lt;br /&gt;
&lt;br /&gt;
The GPIO device hardware ignores the byte-enable signals, so the device treats every access as if it were a word-sized access. This is generally ok with loads, because the device replies with the entire 32-bit value and the CPU extracts part of the word for a narrow (16 or 8 bit) load. This fails for narrow stores because the GPIO device will capture all 32 bits of data, but it is not known what the values of the unused data lines are. (It is probably not random, but it is almost certainly not what you want.)&lt;br /&gt;
&lt;br /&gt;
==== Each bit of the GPIO device&#039;s edge capture register is cleared when a 1 is written to the corresponding bit position. Writing 0 does not clear any edge capture register bits. ====&lt;br /&gt;
&lt;br /&gt;
The edge capture register hardware is designed to clear a bit only when a 1 is written to it. &lt;br /&gt;
&lt;br /&gt;
A long time ago (around Quartus version 13.1 and earlier), writing any value into the edge capture register would clear all bits of the GPIO port&#039;s edge capture register. This was changed somewhere around version 14.0 to require writing a 1 to clear (allowing partially clearing the register), but Altera&#039;s computer system manuals are &#039;&#039;still&#039;&#039; incorrect (as of version 18.0). This warning was added because a non-negligible number of users believed the incorrect documentation and wrote 0 to clear the edge capture register, causing wasted debugging effort.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a snippet of Verilog code from one bit slice of the edge capture register from the GPIO port device (comments added by me):&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Verilog&amp;quot; highlight=&amp;quot;8,9&amp;quot;&amp;gt;&lt;br /&gt;
assign edge_capture_wr_strobe = chipselect &amp;amp;&amp;amp; ~write_n &amp;amp;&amp;amp; (address == 3);&lt;br /&gt;
&lt;br /&gt;
  always @(posedge clk or negedge reset_n)&lt;br /&gt;
    begin&lt;br /&gt;
      if (reset_n == 0)&lt;br /&gt;
          edge_capture[0] &amp;lt;= 0;&lt;br /&gt;
      else if (clk_en)&lt;br /&gt;
          if (edge_capture_wr_strobe &amp;amp;&amp;amp; writedata[0])   // When writing a 1, clear the edge capture bit.&lt;br /&gt;
              edge_capture[0] &amp;lt;= 0;&lt;br /&gt;
          else if (edge_detect[0])       // When an edge is detected, set the edge capture bit.&lt;br /&gt;
              edge_capture[0] &amp;lt;= -1;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
...[snip]&lt;br /&gt;
&lt;br /&gt;
  always @(posedge clk or negedge reset_n)&lt;br /&gt;
    begin&lt;br /&gt;
      if (reset_n == 0)&lt;br /&gt;
        begin&lt;br /&gt;
          d1_data_in &amp;lt;= 0;&lt;br /&gt;
          d2_data_in &amp;lt;= 0;&lt;br /&gt;
        end&lt;br /&gt;
      else if (clk_en)&lt;br /&gt;
        begin&lt;br /&gt;
          d1_data_in &amp;lt;= data_in;&lt;br /&gt;
          d2_data_in &amp;lt;= d1_data_in;    // Two cycles of past history for the data inputs&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    assign edge_detect = ~d1_data_in &amp;amp; d2_data_in;   // two_cycles_ago=1 and one_cycle_ago=0 is an &amp;quot;edge&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Device-specific warnings}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=99</id>
		<title>Msg/DevGpio</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/DevGpio&amp;diff=99"/>
		<updated>2019-03-12T09:30:39Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;This page is about the warning messages that can are produced by the GPIO I/O devices. On the Altera University Program computer systems, the same GPIO device is used for swit...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is about the warning messages that can are produced by the GPIO I/O devices. On the Altera University Program computer systems, the same GPIO device is used for switches, push buttons, LEDs, and the 40-pin expansion header.&lt;br /&gt;
&lt;br /&gt;
==== The GPIO device may not support byte, half-word, or misaligned stores. Use aligned word-sized stores. ====&lt;br /&gt;
&lt;br /&gt;
The GPIO devices only work correctly with word-sized accesses. Narrower stores produce undefined results.&lt;br /&gt;
&lt;br /&gt;
The GPIO device hardware ignores the byte-enable signals, so the device treats every access as if it were a word-sized access. This is generally ok with loads, because the device replies with the entire 32-bit value and the CPU extracts part of the word for a narrow (16 or 8 bit) load. This fails for narrow stores because the GPIO device will capture all 32 bits of data, but it is not known what the values of the unused data lines are. (It is probably not random, but it is almost certainly not what you want.)&lt;br /&gt;
&lt;br /&gt;
==== Each bit of the GPIO device&#039;s edge capture register is cleared when a 1 is written to the corresponding bit position. Writing 0 does not clear any edge capture register bits. ====&lt;br /&gt;
&lt;br /&gt;
The edge capture register hardware is designed to clear a bit only when a 1 is written to it. &lt;br /&gt;
&lt;br /&gt;
A long time ago (around Quartus version 13.1 and earlier), writing any value into the edge capture register would clear all bits of the GPIO port&#039;s edge capture register. This was changed somewhere around version 14.0 to require writing a 1 to clear (allowing partially clearing the register), but Altera&#039;s computer system manuals are &#039;&#039;still&#039;&#039; incorrect (as of version 18.0). This warning was added because a non-negligible number of users believed the incorrect documentation and wrote 0 to clear the edge capture register, causing wasted debugging effort.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Device-specific warnings}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=98</id>
		<title>Msg/FunctionNestCount</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=98"/>
		<updated>2019-03-11T08:49:01Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the function call depth to be very large. This warning tells you that you have exceeded 32 nested function calls.&lt;br /&gt;
&lt;br /&gt;
Deep function call nesting isn&#039;t technically an error. If your program really uses more than 32 nested functions, disable this warning. If not, this is likely indicative of a bug.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
	bl NotAFunction		// This is a function call, but the target doesn&#039;t behave like a function (no return).&lt;br /&gt;
    nop&lt;br /&gt;
NotAFunction:	&lt;br /&gt;
    b _start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
	call NotAFunction		# This is a function call, but the target doesn&#039;t behave like a function (no return).&lt;br /&gt;
    nop&lt;br /&gt;
NotAFunction:	&lt;br /&gt;
    br _start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The call at line 4 repeatedly calls a function that never returns. The function call depth increases by one every time the call is executed. The Call stack will show a stack of calls originating from line 4.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Make sure functions are returning, not stuck in an unending recursion.&lt;br /&gt;
* Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction.&lt;br /&gt;
* Use the [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Call stack window&#039;&#039;&#039;] (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call instruction in the function one nesting level up.&lt;br /&gt;
* The [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Trace window&#039;&#039;&#039;] may also be useful to see the last 200 instructions executed.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator tracks idiomatic call and return instructions and counts the function call nesting depth. This message is generated at a call instruction when the new call depth exceeds 32.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function nesting too deep}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=97</id>
		<title>Msg/FunctionNestCount</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=97"/>
		<updated>2019-03-11T08:47:22Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the function call depth to be very large. This warning tells you that you have exceeded 32 nested function calls.&lt;br /&gt;
&lt;br /&gt;
This isn&#039;t technically an error, but if this behaviour is not expected, it is likely indicative of a bug.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
	bl NotAFunction		// This is a function call, but the target doesn&#039;t behave like a function (no return).&lt;br /&gt;
    nop&lt;br /&gt;
NotAFunction:	&lt;br /&gt;
    b _start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
	call NotAFunction		# This is a function call, but the target doesn&#039;t behave like a function (no return).&lt;br /&gt;
    nop&lt;br /&gt;
NotAFunction:	&lt;br /&gt;
    br _start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The call at line 4 repeatedly calls a function that never returns. The function call depth increases by one every time the call is executed. The Call stack will show a stack of calls originating from line 4.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Make sure functions are returning, not stuck in an unending recursion.&lt;br /&gt;
* Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction.&lt;br /&gt;
* Use the [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Call stack window&#039;&#039;&#039;] (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call instruction in the function one nesting level up.&lt;br /&gt;
* The [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Trace window&#039;&#039;&#039;] may also be useful to see the last 200 instructions executed.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator tracks idiomatic call and return instructions and counts the function call nesting depth. This message is generated at a call instruction when the new call depth exceeds 32.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function nesting too deep}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=96</id>
		<title>Msg/FunctionNestCount</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=96"/>
		<updated>2019-03-11T08:32:41Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the function call depth to be very large. This warning tells you that you have exceeded 32 nested function calls.&lt;br /&gt;
&lt;br /&gt;
This isn&#039;t technically an error, but if this behaviour is not expected, it is likely indicative of a bug.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Make sure functions are returning, not stuck in an unending recursion.&lt;br /&gt;
* Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction.&lt;br /&gt;
* Use the [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Call stack window&#039;&#039;&#039;] (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call instruction in the function one nesting level up.&lt;br /&gt;
* The [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Trace window&#039;&#039;&#039;] may also be useful to see the last 200 instructions executed.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator tracks idiomatic call and return instructions and counts the function call nesting depth. This message is generated at a call instruction when the new call depth exceeds 32.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function nesting too deep}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=95</id>
		<title>Msg/FunctionNestCount</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FunctionNestCount&amp;diff=95"/>
		<updated>2019-03-11T08:29:38Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the function call depth to be very large. This warning tells you that you have exceeded 32 nested function calls.&lt;br /&gt;
&lt;br /&gt;
This isn&#039;t technically an error, but if this behaviour is not expected, it is likely indicative of a bug.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Make sure functions are returning, not stuck in an unending recursion.&lt;br /&gt;
* Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction.&lt;br /&gt;
* Use the [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Call stack window&#039;&#039;&#039;] (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call in the caller one nesting level up.&lt;br /&gt;
* The [https://cpulator.01xz.net/doc/#callstack &#039;&#039;&#039;Trace window&#039;&#039;&#039;] may also be useful to see the last 200 instructions executed.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator tracks idiomatic call and return instructions and counts the function call nesting depth. This message is generated at a call instruction when the new call depth exceeds 32.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function nesting too deep}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=94</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=94"/>
		<updated>2019-03-11T07:12:36Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
	str r0, [pc, #4]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop&lt;br /&gt;
	nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
	stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop						# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can pause the program (like a breakpoint) whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=93</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=93"/>
		<updated>2019-03-11T07:11:07Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* ARMv7 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
	str r0, [pc, #4]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop&lt;br /&gt;
	nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
	stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop						# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can pause the program (like a breakpoint) whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=92</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=92"/>
		<updated>2019-03-11T07:10:47Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Nios II */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
    str r0, [pc, #4]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop&lt;br /&gt;
    nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
	stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop						# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can pause the program (like a breakpoint) whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=91</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=91"/>
		<updated>2019-03-11T07:10:37Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Nios II */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
    str r0, [pc, #4]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop&lt;br /&gt;
    nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
	stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
	nop					# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can pause the program (like a breakpoint) whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=90</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=90"/>
		<updated>2019-03-11T07:10:06Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* ARMv7 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
    str r0, [pc, #4]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop&lt;br /&gt;
    nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
    stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop					# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can pause the program (like a breakpoint) whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=89</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=89"/>
		<updated>2019-03-11T07:08:20Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
    str r0, [pc, #0]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
    stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop					# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can pause the program (like a breakpoint) whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=88</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=88"/>
		<updated>2019-03-11T07:07:00Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
    str r0, [pc, #0]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
    stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop					# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. Also, the code currently shown in the disassembly window may not match the code that was originally loaded into memory. The objective is to find which part of the program stored values into the memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can interrupt the program whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=87</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=87"/>
		<updated>2019-03-11T07:04:20Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
    str r0, [pc, #0]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
    stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop					# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. The main objective is to find which part of the program stored values into memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can interrupt the program whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator keeps the most recently-loaded ELF executable in memory. During every instruction fetch, it compares the fetched opcode to the bytes in the ELF executable, and complains if they are different. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
If you are really using self-modifying code, you can disable this warning. But make sure you&#039;ve followed all of the prescribed rules regarding instruction cache flushing and pipeline flushing defined by the architecture. Nearly all architectures (except x86) will produce undefined results (unknown whether old or new instruction are executed) unless instruction cache and pipeline flushing is correctly done. The simulator does not model any of this complex behaviour: the simulator always executes the modified (new) instructions.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=86</id>
		<title>Msg/FetchSelfModifyingCode</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchSelfModifyingCode&amp;diff=86"/>
		<updated>2019-03-11T06:55:37Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&amp;#039;t be changed at runtime by directly...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from an executable file generated by an assembler or compiler. Normally, this code shouldn&#039;t be changed at runtime by directly modifying the instructions in memory. A program that (intentionally or unintentionally) modifies its own instructions and then executes them is called self-modifying code. This warning tells you that the instruction being executed came from an executable, and that the instruction is now different that what was in the executable.&lt;br /&gt;
&lt;br /&gt;
There are some cases where intentional self-modifying code is useful. But unintentional self-modifying code is almost certainly incorrect.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe2822001		// An opcode&lt;br /&gt;
    str r0, [pc, #0]		// Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop						// This instruction gets changed to an add (opcode 0xe2822001)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0x18c00044	# An opcode&lt;br /&gt;
    stw r2, 0x10(r0)		# Modify instruction at address 0x10. Click &amp;quot;Refresh&amp;quot; to see the new instruction.&lt;br /&gt;
	nop&lt;br /&gt;
    nop					# This instruction gets changed to an add (opcode 0x18c00044)&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the simulator, the highlighted instruction executes as an add (r3 gets incremented), and not the original nop, because the opcode was changed in memory before execution. On real hardware, the behaviour is typically undefined (you may execute the old or new instruction) until you&#039;ve flushed the instruction cache and flushed the instruction pipeline.&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
Unintended self modifying code is notoriously hard to debug. The modified code is not detected until it is next executed, and it may have been modified a very long time ago, so it is often not easy to find the part of the program that actually did the modification. The main objective is to find which part of the program stored values into memory space used by your program&#039;s instructions.&lt;br /&gt;
&lt;br /&gt;
* A common cause of this problem is a memory store somewhere in your program that uses a bad pointer value. This could be simply computing the pointer incorrectly, or overrunning an array bound and overwriting a large swath of memory. Look at the value of the new &amp;quot;opcode&amp;quot; and see if it matches any data pattern that you might have been writing.&lt;br /&gt;
* Use a data watchpoint ([https://cpulator.01xz.net/doc/#watchpoints &#039;&#039;&#039;Watchpoints window&#039;&#039;&#039;], located in the same panel as the registers window by default). A watchpoint can interrupt the program whenever a memory load or store occurs to a range of addresses. Use a watchpoint to look for memory writes to the range of addresses used by your code (set the start and end addresses), and set Pause on Write. Then reload and restart your program. The watchpoint will stop your program whenever a store occurs to your selected region (your instructions), which will hopefully get you much closer to finding the root cause of the problem.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Modified opcode}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=85</id>
		<title>Msg/FetchBadPC</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/FetchBadPC&amp;diff=85"/>
		<updated>2019-03-11T06:26:00Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;Normally, the CPU should execute code that came from a code section (such as &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt;) from an executable file generated by an assembler or compiler. This message te...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Normally, the CPU should execute code that came from a code section (such as &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt;) from an executable file generated by an assembler or compiler. This message tells you that the simulator thinks you&#039;re currently executing outside a code section.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
    nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	nop&lt;br /&gt;
.data&lt;br /&gt;
	nop&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the examples above show, one of the common reasons for encountering this warning is that the program runs past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section and starts executing in the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section. Although the first 32-bit word of the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is a valid opcode, executing instructions from the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is usually unintended.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* As in the examples above, make sure your program isn&#039;t executing past the end of the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section.&lt;br /&gt;
* Executing from a bad location could also be due to a branch with an incorrect target address. To find the offending branch, try using the [https://cpulator.01xz.net/doc/#callstack &amp;lt;b&amp;gt;Trace window&amp;lt;/b&amp;gt;] (located in the same panel as the registers window by default) to look backwards in the program execution.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
ELF executables contain &amp;quot;sections&amp;quot; of bytes that define where in memory each blob of bytes in the executable should be loaded. The ELF executable also includes information on whether each section is intended for executable code (e.g., the &amp;lt;code&amp;gt;.text&amp;lt;/code&amp;gt; section contains code) or for data (the &amp;lt;code&amp;gt;.data&amp;lt;/code&amp;gt; section is marked as containing data). The simulator tracks the sections defined in the most recently loaded ELF executable, and checks each instruction fetch against the sections. This message is generated at the instruction fetch.&lt;br /&gt;
&lt;br /&gt;
There may be uncommon cases where the simulator&#039;s idea of what is a code section doesn&#039;t match reality, and you may want to disable this warning. Some examples:&lt;br /&gt;
* Your program writes code into a data section and then executes it. In this case, executing from a data section really is the right thing to do.&lt;br /&gt;
* Your program has multiple ELF executables. The simulator uses the section boundaries defined in the most recently loaded ELF executable.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Instruction fetch: Outside a code section}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryNoDevice&amp;diff=84</id>
		<title>Msg/MemoryNoDevice</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryNoDevice&amp;diff=84"/>
		<updated>2019-03-11T05:51:31Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The computer system has a 32-bit address space (addresses are 32 bits, and there is 2&amp;lt;sup&amp;gt;32&amp;lt;/sup&amp;gt; bytes = 4 gigabytes of address space), but usually only part of that space actually contains memory or I/O devices. This message tells you that a memory access (or instruction fetch) tried to access a location within the address space that is not used by any memory or I/O devices.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe0000000		// Somewhere outside memory and I/O devices.&lt;br /&gt;
    ldr r1, [r0]			// Where is this reading from? Nothing.&lt;br /&gt;
&lt;br /&gt;
    bx r0					// Branch to nowhere&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0xe0000000	# Somewhere outside memory and I/O devices.&lt;br /&gt;
    ldw r3, 0(r2)			# Where is this reading from? Nothing.&lt;br /&gt;
&lt;br /&gt;
    jmp r2					# Branch to nowhere&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that these examples assume you&#039;re using a computer system other than the &amp;quot;generic&amp;quot; systems, which have 4 GB memory mapped to the entire 32-bit address space. Since there is memory mapped to the entire address space, there are no addresses that are mapped to nothing.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Check the address used for the memory access.&lt;br /&gt;
* For instruction fetches, it means that the PC value is very incorrect. This is often caused by a branch with an incorrect target address. To find the offending branch, try using the [https://cpulator.01xz.net/doc/#callstack &amp;lt;b&amp;gt;Trace window&amp;lt;/b&amp;gt;] (located in the same panel as the registers window by default) to look backwards in the program execution.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
For every memory access (including instruction fetches), the simulator needs to find the memory or I/O device that services the address used by the request, and complains if none is found. This warning is generated while executing the load, store, or instruction fetch.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory access out of range}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryNoDevice&amp;diff=83</id>
		<title>Msg/MemoryNoDevice</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryNoDevice&amp;diff=83"/>
		<updated>2019-03-11T05:35:28Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The computer system has a 32-bit address space (addresses are 32 bits, and there is 2&amp;lt;sup&amp;gt;32&amp;lt;/sup&amp;gt; bytes = 4 gigabytes of address space), but usually only part of that space actually contains memory or I/O devices. This message tells you that a memory access tried to access a location within the address space that is not used by any memory or I/O devices.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe0000000		// Somewhere outside memory and I/O devices.&lt;br /&gt;
    ldr r1, [r0]			// Where is this reading from? Nothing.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0xe0000000	# Somewhere outside memory and I/O devices.&lt;br /&gt;
    ldw r3, 0(r2)			# Where is this reading from? Nothing.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that these examples assume you&#039;re using a computer system other than the &amp;quot;generic&amp;quot; systems, which have 4 GB memory mapped to the entire 32-bit address space. Since there is memory mapped to the entire address space, there are no addresses that are mapped to nothing.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Check the address used for the memory access.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
For every memory access, the simulator needs to find the memory or I/O device that services the address used by the request, and complains if none is found. This warning is generated while executing the load or store.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory access out of range}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryNoDevice&amp;diff=82</id>
		<title>Msg/MemoryNoDevice</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryNoDevice&amp;diff=82"/>
		<updated>2019-03-11T05:33:16Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;The computer system has a 32-bit address space (addresses are 32 bits, and there is 2&amp;lt;sup&amp;gt;32&amp;lt;/sup&amp;gt; bytes = 4 gigabytes of address space), but usually only part of that space a...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The computer system has a 32-bit address space (addresses are 32 bits, and there is 2&amp;lt;sup&amp;gt;32&amp;lt;/sup&amp;gt; bytes = 4 gigabytes of address space), but usually only part of that space actually contains memory or I/O devices. This message tells you that a memory access tried to access a location within the address space that is not used by any memory or I/O devices.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldr r0, =0xe0000000		// Somewhere outside memory and I/O devices.&lt;br /&gt;
    ldr r1, [r0]			// Where is this reading from? Nothing.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;4&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movia r2, 0xe0000000	# Somewhere outside memory and I/O devices.&lt;br /&gt;
    ldw r3, 0(r2)			# Where is this reading from? Nothing.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that these examples assume you&#039;re using a computer system other than the base &amp;quot;4GB memory&amp;quot; systems, which have memory mapped to the entire 32-bit address space, so does not actually have any addresses that aren&#039;t mapped to something.&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Check the address used for the memory access.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
For every memory access, the simulator needs to find the memory or I/O device that services the address used by the request, and complains if none is found. This warning is generated while executing the load or store.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory access out of range}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryCacheBypass&amp;diff=81</id>
		<title>Msg/MemoryCacheBypass</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryCacheBypass&amp;diff=81"/>
		<updated>2019-03-11T05:02:33Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Nios II */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Memory accesses to memory-mapped I/O should not be cached (or the devices will not see the memory access), while accesses to regular memory should be cached (cache consistency problems if you bypass the cache and the requested address is in the cache). The Nios II uses software-controlled cache bypass, where the &amp;quot;io&amp;quot; variants of loads and stores (ldwio, stwio) bypass the cache and the regular versions (ldw, stw) do not. This message reports that either a regular load/store was done to an I/O device, or a cache-bypassing load/store was done to regular memory.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;3,6&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldwio r2, 0(r0)			# Read memory using ldwio: Cache bypass should not be used for memory.&lt;br /&gt;
	&lt;br /&gt;
    movhi r2, 0xff20		# DE1-SoC LEDs are at ff200000&lt;br /&gt;
    stw r0, 0(r2)			# Write to I/O using stw: Cache bypass should be used for I/O device.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Check that the load or store is accessing the correct address. If it is, consider whether it is an I/O device or regular memory, and choose the appropriate instruction type.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator knows the memory ranges used by the regular memory devices and I/O devices, and checks that the instruction type used (regular vs. I/O) matches the memory type (regular vs. I/O) at the accessed address. This warning is generated while executing the load or store.&lt;br /&gt;
&lt;br /&gt;
There is some flexibility in interpretation for what can and cannot be safely cached, so there are cases where the memory type assumed by the simulator may be inappropriate. If you&#039;re sure that the simulator&#039;s expectations do not match reality, you may disable the warning. (An example might be if you want to cache the VGA frame buffer for performance, and then manually flush the data cache at end of drawing each frame.)&lt;br /&gt;
&lt;br /&gt;
It is also possible that you wish the simulator to ignore the cacheability issue entirely, such as if you&#039;re using a computer system that does not have a data cache. If so, it is safe to disable this warning. The Altera University Program Nios II computer systems typically do not have a data cache, so the hardware doesn&#039;t actually care which instruction you use, but we still taught this concept at the University of Toronto and expected students to choose the right instruction type.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory: Suspicious use of cache bypass}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryCacheBypass&amp;diff=80</id>
		<title>Msg/MemoryCacheBypass</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/MemoryCacheBypass&amp;diff=80"/>
		<updated>2019-03-11T05:01:41Z</updated>

		<summary type="html">&lt;p&gt;Henry: Created page with &amp;quot;Memory accesses to memory-mapped I/O should not be cached (or the devices will not see the memory access), while accesses to regular memory should be cached (cache consistency...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Memory accesses to memory-mapped I/O should not be cached (or the devices will not see the memory access), while accesses to regular memory should be cached (cache consistency problems if you bypass the cache and the requested address is in the cache). The Nios II uses software-controlled cache bypass, where the &amp;quot;io&amp;quot; variants of loads and stores (ldwio, stwio) bypass the cache and the regular versions (ldw, stw) do not. This message reports that either a regular load/store was done to an I/O device, or a cache-bypassing load/store was done to regular memory.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	ldwio r2, 0(r0)			# Read memory using ldwio: Cache bypass should not be used for memory.&lt;br /&gt;
	&lt;br /&gt;
    movhi r2, 0xff20		# DE1-SoC LEDs are at ff200000&lt;br /&gt;
    stw r0, 0(r2)			# Write to I/O using stw: Cache bypass should be used for I/O device.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Check that the load or store is accessing the correct address. If it is, consider whether it is an I/O device or regular memory, and choose the appropriate instruction type.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator knows the memory ranges used by the regular memory devices and I/O devices, and checks that the instruction type used (regular vs. I/O) matches the memory type (regular vs. I/O) at the accessed address. This warning is generated while executing the load or store.&lt;br /&gt;
&lt;br /&gt;
There is some flexibility in interpretation for what can and cannot be safely cached, so there are cases where the memory type assumed by the simulator may be inappropriate. If you&#039;re sure that the simulator&#039;s expectations do not match reality, you may disable the warning. (An example might be if you want to cache the VGA frame buffer for performance, and then manually flush the data cache at end of drawing each frame.)&lt;br /&gt;
&lt;br /&gt;
It is also possible that you wish the simulator to ignore the cacheability issue entirely, such as if you&#039;re using a computer system that does not have a data cache. If so, it is safe to disable this warning. The Altera University Program Nios II computer systems typically do not have a data cache, so the hardware doesn&#039;t actually care which instruction you use, but we still taught this concept at the University of Toronto and expected students to choose the right instruction type.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Memory: Suspicious use of cache bypass}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/&amp;diff=79</id>
		<title>Msg/</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/&amp;diff=79"/>
		<updated>2019-03-10T23:33:34Z</updated>

		<summary type="html">&lt;p&gt;Henry: Redirected page to Msg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Msg]]&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=78</id>
		<title>Msg/ClobberedRA</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=78"/>
		<updated>2019-03-10T09:58:01Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should normally return to the instruction after the call instruction in the caller that called this function. This message tells you that this didn&#039;t happen: the function return is returning somewhere other than the instruction following the matching call.&lt;br /&gt;
&lt;br /&gt;
If you also clobbered sp, see also [[Msg/ClobberedSP]]&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop					// Should return here&lt;br /&gt;
    nop					// Actually returns here&lt;br /&gt;
    # ...&lt;br /&gt;
&lt;br /&gt;
MyFunction:&lt;br /&gt;
    add lr, #4				// Change LR&lt;br /&gt;
    bx lr					// return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop					# Should return here&lt;br /&gt;
    nop					# Actually returns here&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    addi ra, ra, 4			# Modify ra&lt;br /&gt;
    ret					# return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* This message is complaining that the return address (or link address for ARM) differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the return address (ra or lr) at both the function entry and return. Are they the same?&lt;br /&gt;
* Typically, the return address register is not used in a function body except for saving and restoring it to the stack when there is a nested function call. A common cause of the return address changing is a problem during save and restore, e.g., popping from a different location than the corresponding push, or modifying the value that was on the stack. Watch the return address&#039;s save and restore and ensure that both the location on the stack and values are the same.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies at return instructions that the return address matches the location of the matching call. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}}&lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=77</id>
		<title>Msg/ClobberedSP</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=77"/>
		<updated>2019-03-10T09:54:59Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should always ensure that the stack pointer is the same at the entry and exit of the function. This message tells you that this didn&#039;t happen: the stack pointer was different at the function return than when the function was first called.&lt;br /&gt;
&lt;br /&gt;
If you also clobbered ra, see also [[Msg/ClobberedRA]]&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    # ...&lt;br /&gt;
    &lt;br /&gt;
MyFunction:&lt;br /&gt;
    push {r4}				// Change SP&lt;br /&gt;
    bx lr					// SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    subi sp, sp, 4			# Modify SP&lt;br /&gt;
    ret					# SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* This message is complaining that the stack pointer differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the stack pointer at both the function entry and return. Are they the same?&lt;br /&gt;
* The most common way to use the stack pointer is to modify it while pushing and popping values on the stack. When pushes and pops are mismatched, there is a net change in the stack pointer in the function.&lt;br /&gt;
* The two places where stack pointer manipulations often occur are at the function prologue and epilogue, and allocating and deallocating arguments passed on the stack when calling a function. These operations are all matched. If your function modifies the stack pointer for other purposes, change your code so that this doesn&#039;t happen (e.g., copy the stack pointer to another register and modify that, instead of modifying the stack pointer).&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies that they haven&#039;t changed when executing the matching function return. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}} &lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=76</id>
		<title>Msg/ClobberedRA</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=76"/>
		<updated>2019-03-10T09:54:54Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should normally return to the instruction after the call instruction in the caller that called this function. This message tells you that this didn&#039;t happen: the function return is returning somewhere other than the instruction following the matching call.&lt;br /&gt;
&lt;br /&gt;
If you also clobbered sp, see also [[Msg/ClobberedSP]]&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop					// Should return here&lt;br /&gt;
    nop					// Actually returns here&lt;br /&gt;
    # ...&lt;br /&gt;
&lt;br /&gt;
MyFunction:&lt;br /&gt;
    add lr, #4				// Change LR&lt;br /&gt;
    bx lr					// return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop					# Should return here&lt;br /&gt;
    nop					# Actually returns here&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    addi ra, ra, 4			# Modify ra&lt;br /&gt;
    ret					# return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Fundamentally, this message is complaining that the return address differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the return address (ra or lr) at both the function entry and return. Are they the same?&lt;br /&gt;
* Typically, the return address register is not used in a function body except for saving and restoring it to the stack due to the need for a nested function call. A common cause of the return address changing is a problem during save and restore, e.g., popping from a different location than the corresponding push, or modifying the value that was on the stack. Watch the return address&#039;s save and restore and ensure that both the location on the stack and values are the same.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies at return instructions that the return address matches the location of the matching call. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}}&lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=75</id>
		<title>Msg/ClobberedRA</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=75"/>
		<updated>2019-03-10T07:40:18Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should normally return to the instruction after the call instruction in the caller that called this function. This message tells you that this didn&#039;t happen: the function return is returning somewhere other than the instruction following the matching call.&lt;br /&gt;
&lt;br /&gt;
If you clobbered sp, see also [[Msg/ClobberedSP]]&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop					// Should return here&lt;br /&gt;
    nop					// Actually returns here&lt;br /&gt;
    # ...&lt;br /&gt;
&lt;br /&gt;
MyFunction:&lt;br /&gt;
    add lr, #4				// Change LR&lt;br /&gt;
    bx lr					// return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop					# Should return here&lt;br /&gt;
    nop					# Actually returns here&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    addi ra, ra, 4			# Modify ra&lt;br /&gt;
    ret					# return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Fundamentally, this message is complaining that the return address differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the return address (ra or lr) at both the function entry and return. Are they the same?&lt;br /&gt;
* Typically, the return address register is not used in a function body except for saving and restoring it to the stack due to the need for a nested function call. A common cause of the return address changing is a problem during save and restore, e.g., popping from a different location than the corresponding push, or modifying the value that was on the stack. Watch the return address&#039;s save and restore and ensure that both the location on the stack and values are the same.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies at return instructions that the return address matches the location of the matching call. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}}&lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=74</id>
		<title>Msg/ClobberedSP</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=74"/>
		<updated>2019-03-10T07:40:15Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should always ensure that the stack pointer is the same at the entry and exit of the function. This message tells you that this didn&#039;t happen: the stack pointer was different at the function return than when the function was first called.&lt;br /&gt;
&lt;br /&gt;
If you clobbered ra, see also [[Msg/ClobberedRA]]&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    # ...&lt;br /&gt;
    &lt;br /&gt;
MyFunction:&lt;br /&gt;
    push {r4}				// Change SP&lt;br /&gt;
    bx lr					// SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    subi sp, sp, 4			# Modify SP&lt;br /&gt;
    ret					# SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* This message is complaining that the stack pointer differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the stack pointer at both the function entry and return. Are they the same?&lt;br /&gt;
* The most common way to use the stack pointer is to modify it while pushing and popping values on the stack. When pushes and pops are mismatched, there is a net change in the stack pointer in the function.&lt;br /&gt;
* The two places where stack pointer manipulations often occur are at the function prologue and epilogue, and allocating and deallocating arguments passed on the stack when calling a function. These operations are all matched. If your function modifies the stack pointer for other purposes, change your code so that this doesn&#039;t happen (e.g., copy the stack pointer to another register and modify that, instead of modifying the stack pointer).&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies that they haven&#039;t changed when executing the matching function return. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}} &lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=73</id>
		<title>Msg/ClobberedSP</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedSP&amp;diff=73"/>
		<updated>2019-03-10T07:27:26Z</updated>

		<summary type="html">&lt;p&gt;Henry: /* Debugging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should always ensure that the stack pointer is the same at the entry and exit of the function. This message tells you that this didn&#039;t happen: the stack pointer was different at the function return than when the function was first called.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    # ...&lt;br /&gt;
    &lt;br /&gt;
MyFunction:&lt;br /&gt;
    push {r4}				// Change SP&lt;br /&gt;
    bx lr					// SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop&lt;br /&gt;
    nop&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    subi sp, sp, 4			# Modify SP&lt;br /&gt;
    ret					# SP is different at return&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* This message is complaining that the stack pointer differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the stack pointer at both the function entry and return. Are they the same?&lt;br /&gt;
* The most common way to use the stack pointer is to modify it while pushing and popping values on the stack. When pushes and pops are mismatched, there is a net change in the stack pointer in the function.&lt;br /&gt;
* The two places where stack pointer manipulations often occur are at the function prologue and epilogue, and allocating and deallocating arguments passed on the stack when calling a function. These operations are all matched. If your function modifies the stack pointer for other purposes, change your code so that this doesn&#039;t happen (e.g., copy the stack pointer to another register and modify that, instead of modifying the stack pointer).&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies that they haven&#039;t changed when executing the matching function return. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}} &lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/StackDeallocatedParentFrame&amp;diff=72</id>
		<title>Msg/StackDeallocatedParentFrame</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/StackDeallocatedParentFrame&amp;diff=72"/>
		<updated>2019-03-10T07:24:28Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A stack frame is a region of memory used by an executing function. When calling a function, the child function&#039;s stack frame is at a lower address than the caller&#039;s stack frame. New stack space is allocated by decrementing the stack pointer, and stack space is deallocated by incrementing the stack pointer. However, a function should not deallocate the parent function&#039;s stack frame. In other words, the stack pointer should never be greater than the value at the beginning of the function. This warning tells you that the stack pointer has increased past the value it had at the beginning of the current function.&lt;br /&gt;
&lt;br /&gt;
This is a more stringent requirement than simply requiring the stack pointer to be restored to its original value at the end of the function. Because an interrupt can occur at any moment, if the stack pointer increases beyond the current stack frame (deallocating the parent&#039;s stack frame) even momentarily, the parent function may lose some of its stack values because an interrupt handler may have executed and used the &amp;quot;free&amp;quot; stack space below the stack pointer.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	mov sp, #0x1000			// Initialize SP to something sane    &lt;br /&gt;
    bl Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	add sp, #4				// Deallocated 4 bytes of the caller&#039;s stack frame&lt;br /&gt;
    sub sp, #4				// Can&#039;t do this even if the operation is reverted&lt;br /&gt;
    bx lr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight line lang=&amp;quot;Asm&amp;quot; highlight=&amp;quot;7&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
	movi sp, 0x1000			# Initialize SP to something sane    &lt;br /&gt;
    call Func&lt;br /&gt;
    &lt;br /&gt;
Func:&lt;br /&gt;
	addi sp, sp, 4				# Deallocated 4 bytes of the caller&#039;s stack frame&lt;br /&gt;
    subi sp, sp, 4				# Can&#039;t do this even if the operation is reverted&lt;br /&gt;
    ret&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above examples, the stack pointer is initialized to 0x1000. The child function Func can allocate and deallocate stack space below the stack pointer (currently 0x1000). It is not allowed to deallocate the parent&#039;s stack frame. The child function here attempts to move the stack pointer to 0x1004. This results in the warning: &#039;&#039;&#039;Stack pointer moved beyond current stack frame. sp at beginning of current function was 00001000&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The message also reminds you that the stack pointer was 0x1000 at the beginning of the function, and that the stack pointer has increased beyond this point (to 0x1004).&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Normally, all stack pointer manipulations are matched: decrease the stack pointer when entering a function, and increase the stack pointer immediately before returning. &lt;br /&gt;
* Carefully trace through any operations that change the stack pointer. Make sure they&#039;re all matched (every decrement is matched by an increment of the same amount). Ensure that the function prologue and epilogue only execute once (not accidentally part of a loop).&lt;br /&gt;
* The two places where stack pointer manipulations often occur are at the function prologue and epilogue, and allocating and deallocating arguments passed on the stack when calling a function. These operations are all matched. If your function uses the stack pointer for other purposes, this is an easy source of bugs.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and compares the current stack pointer to the stack pointer at the beginning of the function. This warning is generated at the instruction that modifies the stack pointer.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|SP moved beyond current stack frame}}&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
	<entry>
		<id>https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=71</id>
		<title>Msg/ClobberedRA</title>
		<link rel="alternate" type="text/html" href="https://cpulator.01xz.net/mw/index.php?title=Msg/ClobberedRA&amp;diff=71"/>
		<updated>2019-03-10T07:13:59Z</updated>

		<summary type="html">&lt;p&gt;Henry: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function should normally return to the instruction after the call instruction in the caller that called this function. This message tells you that this didn&#039;t happen: the function return is returning somewhere other than the instruction following the matching call.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
==== ARMv7 ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;11&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    mov sp, #0x1000		// Initialize SP to something sane&lt;br /&gt;
    bl MyFunction&lt;br /&gt;
    nop					// Should return here&lt;br /&gt;
    nop					// Actually returns here&lt;br /&gt;
    # ...&lt;br /&gt;
&lt;br /&gt;
MyFunction:&lt;br /&gt;
    add lr, #4				// Change LR&lt;br /&gt;
    bx lr					// return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==== Nios II ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Asm&amp;quot; line highlight=&amp;quot;10&amp;quot;&amp;gt;&lt;br /&gt;
.global _start&lt;br /&gt;
_start:&lt;br /&gt;
    movi sp, 0x1000		# Initialize SP&lt;br /&gt;
    call Function&lt;br /&gt;
    nop					# Should return here&lt;br /&gt;
    nop					# Actually returns here&lt;br /&gt;
    &lt;br /&gt;
Function:&lt;br /&gt;
    addi ra, ra, 4			# Modify ra&lt;br /&gt;
    ret					# return to a different location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
* Fundamentally, this message is complaining that the return address differs between the start of the function and at the function return. Use breakpoints and make a note of the value of the return address (ra or lr) at both the function entry and return. Are they the same?&lt;br /&gt;
* Typically, the return address register is not used in a function body except for saving and restoring it to the stack due to the need for a nested function call. A common cause of the return address changing is a problem during save and restore, e.g., popping from a different location than the corresponding push, or modifying the value that was on the stack. Watch the return address&#039;s save and restore and ensure that both the location on the stack and values are the same.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
The simulator identifies idiomatic call and return instructions executed at runtime. It records the values of registers when executing call instructions, and verifies at return instructions that the return address matches the location of the matching call. This warning is generated at the return instruction.&lt;br /&gt;
&lt;br /&gt;
{{DisableMsg|Function clobbered ra or sp}}&lt;br /&gt;
&lt;br /&gt;
ARMv7: &amp;lt;b&amp;gt;Function clobbered sp, or bad return&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Henry</name></author>
	</entry>
</feed>