1,827 questions
1
vote
2
answers
193
views
Call Stack - What is stored in the call stack between the declaration of a caller function's last variable and a callee function's first variable?
I am using an Ubuntu 16.04 a 32-bit Virtual Machine OS.
I executed
sysctl -w kernel.randomize_va_space=0
to disable ASLR in root prior to gcc.
I have also compiled this using the command:
gcc -g -fno-...
-2
votes
1
answer
91
views
Translating flags into memory addresses ram map pokemon [closed]
I'm trying to understand how to get memory addresses from the page https://datacrystal.tcrf.net/wiki/Pok%C3%A9mon_Gold_and_Silver/Flags in order to put them in my pyboy project.
For instance I want to ...
0
votes
1
answer
86
views
Function parameter memory address assignment [closed]
I want to understand how memory is allocated to function params in c. I compiled the same program twice with gcc -g except I interchanged the first and second params of a function on_menu for the ...
2
votes
1
answer
101
views
how does the cpu find static/global objects on x86?
I know the stack pointer can be used to find stack allocated objects, but how does the cpu find global/static objects? From what I could tell from the disassembly, it uses absolute/immediate ...
1
vote
0
answers
77
views
I can not read the FIFO of Semtech SX1231
#include <stdint.h>
#include <stdbool.h>
#include <reg_mg82f6d64.h>
#define RegFifo 0x00
#define RegIrqFlags1 0x27
#define RegIrqFlags2 0x28
void wrb(uint8_t dat);
...
4
votes
1
answer
202
views
Understanding the behavior of $ Location Counter - var1 DWORD $ assembles to start of data section in MASM, not start of line
Program Code - 1
.386
.model flat
.data
Array1 DWORD 1,2,3,4,5
var1 DWORD $
.code
start PROC
MOV EAX, OFFSET Array1
MOV EBX, var1
LEAVE
RET
start ENDP
END
Program Code - 1 ...
1
vote
3
answers
380
views
Difference between effective and physical address
I am learning assembly programming on the 8086 microprocessor, and I would like to understand the difference between the effective address and the physical address
My teacher said that the effective ...
-4
votes
3
answers
242
views
Why can't I change the value of a constant using pointers in C++?
I'm working on code examples that demonstrate how you can "shoot yourself in the foot" using pointers in C++.
It's easy to create code that crashes. But now I'm trying to write code that ...
1
vote
0
answers
145
views
Why is the BIOS designed to be near 0xFFFFF instead of 0xF0000?
I am currently doing an experiment for S6.828 and I am facing a problem.
+------------------+ <- 0xFFFFFFFF (4GB)
| 32-bit |
| memory mapped |
| devices |
| |...
1
vote
1
answer
91
views
How can this code know exactly that pMem will always be the value of MAGIC_NUM?
I'm working on a legacy MUD codebase, and I've been getting the bug message in this block of code. I'm trying to understand it, but also I'm wondering how it's even able to ever work? Aren't addresses ...
0
votes
0
answers
88
views
Confusion regarding addresses and references in C++. What are the data types of addresses and references respectively? [duplicate]
I understood that the & operator is context dependent,
int var = 5;
int* ptr = &var;
In the above code, &var returns the address of var, then gives it to the pointer.
On the other hand
...
1
vote
0
answers
185
views
How does DPDK guarantee fixed/pinned physical address for huge pages
According to this DPDK blog, physical addresses of huge pages are "pinned":
Whenever a memory area is made available for DPDK to use, DPDK figures out its physical address by asking the ...
2
votes
2
answers
258
views
Why is an "address-of" expression not an lvalue?
The C Standard defines lvalue as:
An lvalue is an expression (with an object type other than void) that potentially designates an object;64) if an lvalue does not designate an object when it is ...
0
votes
1
answer
121
views
What happens when a memory adress is casted like this?
I wanted to look at the byte-representation of different objects in memory and found this function to do it:
template <typename T>
void print_bytes(const T& input, std::ostream& os = std:...
0
votes
2
answers
75
views
How C variable usage changes its memory address?
This code shows that b variable is placed right after a variable:
#include <stdio.h>
int main(void)
{
int a;
int b;
a=15;
b=2654;
printf("%d %d\n", a, b);
&...
1
vote
2
answers
114
views
How to know if I look at an address or a local variable just by the bits?
Is it even possible? I was asked about the values that appear on the stack, in a way that without knowing the var type, just by analyzing the bytes I should be able to recognize if it's an address or ...
0
votes
1
answer
84
views
How does memory allocation work in C language regarding addresses allocated
#include <stdio.h>
int main(void){
int a;
int b;
printf("%d %p %d %p", a, b, &a, &b);
return 0;
}
I have writen this C program trying to explore the ...
0
votes
2
answers
177
views
9 Digit Addresses in Hexadecimal System in MacOS
I am practicing on C programming language. I had Win 10 systems and I was practicing on it and I always get addresses which are multiples of 2. Know, I am practicing on Macbook Pro M3 and I get 9 ...
1
vote
0
answers
29
views
Understanding virtual to physical memory translation in Android
I am using a simple shell script to read out data from /proc/pid/mem.
Setup: This is done through android studio by using adb shell and su.
Then, I use /proc/pid/maps to read out a memory range, ...
0
votes
1
answer
152
views
Where are real mode address contents located in protected mode?
In real mode, an x86 CPU can only see address space that ranges 0x00000 to 0xFFFFF. MBR code is loaded into 0x07C00 by the BIOS. If that MBR code immediately switched into protected mode, where in the ...
-2
votes
1
answer
101
views
Why doesnt decremented pointers return the right value?
I am trying to decrement a pointer while setting values to what the pointer is poiting to.
When setting the values they show that they have been properly set, but when trying to retrieve them again it ...
1
vote
1
answer
37
views
Why Visual Studio memory addresses shuffle based on view?
When viewing memory addresses in Visual Studio, I noticed the arrangement changes depending on how the memory is viewed. Example:
int a = 3;
int* b = &a;
1 byte: 0x 03 00 00 00
2 byte: 0x 0003
4 ...
2
votes
2
answers
158
views
How do I initialize an array at a specific address for CANbus RX/TX FIFO start address register (ATSAME51)?
The register for the CAN RX & TX buffer/FIFO start address (F0SA/TBSA) only consider the lower 16 bits of an address but a RAM address can span from 0x20000000 to 0x20040000 (18 bits).
Link to ...
5
votes
2
answers
302
views
How do I answer the question of whether a standard library function is an "addressable function"?
I've recently come across Can I take the address of a function defined in standard library? and was shocked by the fact that the answer is fundamentally No. I surely have written &std::...
0
votes
2
answers
109
views
The address of `a` (a variable inside the loop) not changing
Here is the C code snippet.
#include<stdio.h>
int N = 10;
while (N--) {
int *a;
printf("%p\n", &a);
}
The running results(Compiler: tdm-gcc 4.9.2 64-bit release, os: ...