Skip to main content
Filter by
Sorted by
Tagged with
17 votes
3 answers
1k views

I'm reading a GNU as introductory book for programs running on top of an OS. I'm at the stack memory part and I was curious how the stack looks like in a freestanding environment. I'm guessing that ...
mltm's user avatar
  • 605
1 vote
0 answers
56 views

Given the example of a simple program for GNU assembler on i386 architecture in Linux: .section .data msg: .ascii "Hi, People!\n" len = . - msg .section .text .global _start _start: # ...
Rodion Gorkovenko's user avatar
0 votes
1 answer
74 views

When developing a Rust no_std bootloader for my micro:bit v2.21 (Cortex-M4, nRF52833), I have encountered a weird error. The bootloader jumps to the main application using cortex_m::asm::bootstrap(sp, ...
Pavel Lobodinský's user avatar
1 vote
0 answers
104 views

I'm trying to learn more about memory and trying to dissect a stack frame. For reference here is the source code that I'm running through gdb. #include <stdio.h> void test_function(int a, int b,...
0xChris's user avatar
  • 21
-1 votes
1 answer
111 views

How can I address elements on the stack that are not on top of it? I am talking about for instance first executing stmfd sp!, {r0-r12} and then push {lr}. Now I want to work with the first address of ...
user avatar
2 votes
1 answer
122 views

I'm writing a mini OS for my STM32F0 board, which has a Cortex-M0 CPU based on the ARMv6-M architecture. In particular, I'm doing the msp/psp switch after I've created the process queue for the ...
France's user avatar
  • 21
3 votes
1 answer
94 views

I have been attempting to read through the ARM manual to gain an understanding of how ARM works architecturally. I know that there is a system register for SP at each EL, like SP_EL0, SP_EL1, etc. I ...
nexos's user avatar
  • 98
1 vote
1 answer
105 views

I was following a tutorial on operating system development, and as a bit of a fanatic, I came across a line in the code that caught my attention: bits 16 section _ENTRY CLASS=CODE extern _cstart_ ...
Novice's user avatar
  • 55
0 votes
4 answers
911 views

I have recently become interested in linker scripts and assembly coding for MCUs. I just discovered that the first thing we do in the reset_handler is set the stack pointer register (sp). My question ...
Rynxie's user avatar
  • 69
-1 votes
1 answer
57 views

I feel confused about the bytes the stack pointer changes when callq or retq is invoked? Here’s a little example ; Disassembly of leaf (long y) y in %rdi 0000000000400540 <leaf>: 400540: 48 8d ...
jeno jeff's user avatar
0 votes
1 answer
187 views

I am using https://www.qemu.org/docs/master/system/riscv/virt.html to compile some code that prints 'U' out the uart. My question is about stack initialization. I am assuming I can do this various ...
odnal's user avatar
  • 23
22 votes
2 answers
2k views

I'm trying to write an x86 bootloader and operating system completely in Rust (no separate assembly files, only inline assembly within Rust). My bootloader works completely as intended within the QEMU ...
suman's user avatar
  • 325
1 vote
1 answer
152 views

I'm trying to implement a poor man's call with current continuation for a program written in C. I can "easily" access and memcpy the relevant part of the C stack (obviously, that's not ...
Stefan's user avatar
  • 28.8k
2 votes
2 answers
143 views

I realized I never really thought of this. If I made a large enough recursive call chain, wouldn't the stack eventually grow down enough that it will overlap with other things, like shared libraries (...
natitati's user avatar
  • 167
1 vote
1 answer
635 views

I am trying to understand the ARM cortex-M hardware behavior on reset; particularly how the SP and PC values are written upon a cold start or hard reset. Basically, it would seem the hardware (aka PE ...
NeedToKnow's user avatar
5 votes
1 answer
454 views

According to Patterson & Hennessy's Computer Organization and Design (MIPS Edition), the stack pointer $sp is typically initialized to 0x7FFFFFFC. the stack pointer $sp is always pointing at the ...
Flandia Yingman's user avatar
2 votes
1 answer
173 views

In STM32L432KC(arm cortex-m4+FPU) there are two ram memory blocks. Following is a snippet from the linker script I use. _e_ram2_stack = ORIGIN(RAM2) + LENGTH(RAM2); _e_ram_stack = ORIGIN(RAM ) + ...
zenprogrammer's user avatar
3 votes
0 answers
261 views

This is related to an issue described in this question -- a reproducible example can be found there, as well as a description of the environment (briefly: Apple Silicon with macOS Sonoma and clang 15)....
swineone's user avatar
  • 3,000
0 votes
1 answer
305 views

It is possible to achieve this in a cortex-m4? What i mean is having PSP only on that intervals, and all the rest MSP when there is an interrupt? The objective is just to do the stacking and ...
AB3's user avatar
  • 3
0 votes
0 answers
98 views

in my system (x86_64), when I'm using GDB, both RBP and RSP point to the same memory address after pushing a new stack frame, therefore I can't reference the end of the stack with the register RSP ...
strjak's user avatar
  • 15
1 vote
1 answer
251 views

I am currently trying to write startup code in assembly for an STM8 without any vendor libraries. More specifically, I am using an STM8S103f3p6. I am still inexperienced in assembly and with startup ...
Alex's user avatar
  • 69
0 votes
1 answer
77 views

Stacking process When I talked about the stacking process I was talking about the frame that it would store the data of CPU registers like PC(Program counter) or LR but the advisor said it wasn't and ...
tta's user avatar
  • 1
0 votes
1 answer
107 views

Learning some reverse engineering and I came across some examples of loops in x86 assembly 00401036 mov [ebp+var_4], 0 0040103D mov [ebp+var_8], 0 00401044 loc_401044: 00401044 ...
Kenneth Cox's user avatar
2 votes
0 answers
567 views

I am experiencing a sporadic bug on some STM32F7s. While usually SP register takes its initial value from reset vector (stored in persistent read-only memory), sometimes it is initially set to an ...
Giuseppe Guerrini's user avatar
2 votes
0 answers
210 views

I am doing an energy profile of an ARM processor for an academic project. I managed to measure the power consumption of several assembly instructions by running them in a ~200 insts loop, e.g.: .rept ...
Alessandro Bertulli's user avatar
1 vote
0 answers
842 views

This question is related to this question: How can I access arguments 7+ using inline assembly? I understand that accessing the pointers myself is non-standard, potentially unsafe, and not portable. ...
Connor's user avatar
  • 1,146
1 vote
1 answer
152 views

I'm currently having trouble writing this recursive factorial assembly code in MIPS. I do not want to change the format of this code, as it is for a project, but I want to understand how to store or ...
kaili's user avatar
  • 13
0 votes
4 answers
456 views

I have a small C code which demonstrate Runtime Stack functionality by modifying data at a stack address. #include <stdio.h> int * fun() { int a = 10; return &a; } int * fun2() { ...
oneneozero oneneozero's user avatar
1 vote
2 answers
416 views

As a more specific question for assembly - Why make ISA be aware of the existence of "stack" concept? - Stack Overflow and suggested by @xiver77, what is the benefit of having a dedicated ...
tristone's user avatar
  • 125
0 votes
1 answer
538 views

I have been writing some code in assembly and i found a bug that was overwriting others memory locations and giving to me a segmentation fault, this trouble was made using the rbp register, but the ...
Rômulo peres de moraes's user avatar
0 votes
1 answer
292 views

To learn multithreading, I use code given by the teacher, that works for my classmates, but not for me. The error happens here: void fonction2(){ int compteur1 = 1; while(1){ ...
Amaury Lorin's user avatar
1 vote
1 answer
507 views

I was under the impression that the frame pointer $fp is set to the first word of stack according to Computer Organization and Design MIPS 5th ed page 103. int func(int g) { int f = 9; return ...
African_king's user avatar
3 votes
1 answer
334 views

im learning x86 assembly, using the code below for testing, i see in gdb console that the rsp register which points at the top of the stack starts at 0x7FFFFFFFDFD0, if i understand correctly, in the ...
Isaí's user avatar
  • 49
1 vote
1 answer
239 views

I am learning MS-DOS source code during that i am in difficulty with some line of code: BIOSSEG: EQU 40H BIOSLEN: EQU 2048 DOSLEN: EQU 8192 In the next page there are some lines of code, INIT: XOR BP,...
Shankar Tiwari ji's user avatar
1 vote
1 answer
693 views

why stack pointer is initialized to the maximum value? I only knows that It is the tiny register which stores the last program request’s address in a stack. It is the particular kind of buffer that ...
anonymouser's user avatar
1 vote
1 answer
847 views

I'm creating a program that shows the registers called dumpRegisters. The registers need to match what is shown in the Registers window in the debugger (using Visual Studio). The registers in the ...
user avatar
0 votes
1 answer
108 views

I'm using TI Code Composer Studio for the MSP430F1232. Starting from a template in assembler, a call to a routine doesn't work but when I put the routine directly in the code,it works. Why does the ...
user avatar
1 vote
0 answers
271 views

I have a question about the register file. As I know, the stack pointer is one of the special registers in the register file. Why it is determined specifically? I mean compiler can define any register ...
Ömer GÜZEL's user avatar
0 votes
1 answer
971 views

Considering the 8051 micro controller RAM organization, I would like to set my stack pointer to address 30h. I would like to know if I have to do it only once in the beginning of my program, or is it ...
OcR19's user avatar
  • 23
2 votes
1 answer
191 views

In Intel 8085 microprocessor, is there any way or instruction exist for find out, to where Stack Pointer currently points to?.
Mannar Amuthan's user avatar
3 votes
1 answer
1k views

What is the initial value of SS, SP, BP? Are they null (0x0) or for example does SP immediately set to 0xFFFE? When we write an assembly code without using pop and push statements does stack pointer ...
Huseyin Aydin's user avatar
8 votes
1 answer
325 views

I have observed that GCC's C++ compiler generates the following assembler code: sub $0xffffffffffffff80,%rsp This is equivalent to add $0x80,%rsp i.e. remove 128 bytes from the stack. Why does ...
Heygard Flisch's user avatar
1 vote
0 answers
53 views

still me. I am following the sample code given in a book but I got a segmentation fault error when linking extern asm file with cpp file Could someone tell me what the issue is: global _integer_add ; ...
not_here_to_play's user avatar
2 votes
0 answers
164 views

I'm testing some memory dumping routines in 8086 Assembly based on the one that Keith of Chibiakumas created for displaying registers and showing memory. This routine is a modified version of his that ...
puppydrum64's user avatar
  • 1,688
1 vote
1 answer
462 views

I am inspecting a process (which has no bugs actually) with gdb. However I noticed, when doing info registers, that RSP is higher than RBP, which is not consistent with the fact that the stack grows ...
Aaa Bbb's user avatar
  • 667
2 votes
2 answers
1k views

I'm messing around with the asm! macro on an embedded ARM (Thumb) target. I have an interrupt service routine that is designed to get the number that the svc instruction was called with: #[cortex_m_rt:...
laptou's user avatar
  • 7,107
-2 votes
1 answer
781 views

Under Visual Studio masm: mov ecx,270 l1: pop eax loop l1 push eax The point of this code is to find out if there is and what is the initial value of ESP. I try to pop immediately after ...
Zackham's user avatar
  • 45
0 votes
0 answers
744 views

I have already done that, but I don't seem to understand the $sp - Stack pointer fully. As it says that the Stack Pointer $ sp should always point to the last occupied memory cell of the stack. (when ...
S. Jilani's user avatar
0 votes
0 answers
2k views

It seems that, while a 32-bit program can push/pop either 2 or 4 bytes to the stack, a 64-bit program has no choice but to push/pop 8 bytes at a time. Is there really no way to push/pop a 4-byte value ...
user1636349's user avatar
0 votes
0 answers
265 views

Hi I am studying computer architecture. We learned that we usually use temporary registser($t) to temporarily store values ​​in registers. However, I saw a data that uses the stack pointer ($sp) to ...
user avatar