Push instruction

From SEGGER Knowledge Base
Jump to navigation Jump to search

The push instruction places (pushes) data onto the stack.

Overview

The PUSH instruction is an instruction that can be found in almost all CPUs. It is used to place data onto the stack. In most CPU architectures, the stack is a region of memory that operates in a last-in, first-out (LIFO) manner. The PUSH instruction is used to store register values, return addresses, or other data onto the stack.

Functionality

When the PUSH instruction is executed, it decreases the stack pointer (assuming it grows from top to bottom, as is very common) and writes the specified value to the new top of the stack. This is commonly used before calling a subroutine to save register values, or during interrupt handling to store the current execution context.