All Questions
734
questions
-1
votes
1
answer
44
views
Does stack work differently in assembly than how it works in C?
I just started learning assembly code. As far as I understand, when a functions calls in assembly code, the main variables are stored to stack from registers and stored back to registers after ...
-1
votes
0
answers
53
views
Why does gcc not allocate space for local variable in this example? [duplicate]
This is the C code I compiled with gcc -
#include <stdio.h>
#include <stdlib.h>
int sum(int arr[20]) {
int s = 0;
for (int i = 0; i < 20; i++)
s += arr[i];
return s;...
2
votes
4
answers
163
views
Does little endian impact arrays?
given the following command in C language:
unsigned char myID[10] = "123456789"
And given the fact I'm using little endianness with x86 architecture, how would that be saved in memory?
is it:...
1
vote
2
answers
84
views
Is there an already implemented stack in x86 linux assembly?
I am learning x86 assembly using Nasm on Linux(Debian 12).
I already know what is stack, so I thought when we code in assembly, we implement it ourselves.
But I saw instructions like push and pop ...
2
votes
1
answer
54
views
Why is this effective pointer giving a seg fault?
I am writing a compiler into NASM assembly for fun and am stuck trying to implement indexing into an array on the stack.
My compiler generates the following assembly from the input below. I've added ...
0
votes
1
answer
121
views
Using `and rsp,-16` for stack alignment in x86
Consider this "Hello world" x86 program:
bits 64
global main
extern puts
section .text
main:
push rbp
mov rdi, msg
call puts
pop rbp
ret
section ....
1
vote
0
answers
55
views
Assembly code problem : invalid use of register
I am trying to write a function in assembly (x86_64) that returns the scalar product of two vectors (signed chars). The two first arguments of the function are the two vectors and the third one is ...
2
votes
0
answers
53
views
Clarification on Memory Allocation Direction: Data Section vs. Stack [duplicate]
I'm a bit confused about the direction of memory allocation in different memory segments in x86_64 architecture. When I initialize variables in the data section, they seem to be allocated in ...
0
votes
1
answer
46
views
Purpose of stack register(s) in holding 0x7c00
I have a problem in understanding the curtain part of the code, how it works and what's behind the operating stack register(s).
; that part i'm referring to
mov ss, ax
mov sp, 0x7c00
I need an ...
3
votes
0
answers
119
views
Why I can't call calc.exe but calc is ok in assembler x64 win32 API
I am currently studying shellcode writing. I have studied some assembly in the past but I jump from topic to topic in my studies and things are easily forgotten.
(the setup)
gcc --version
gcc.exe (...
0
votes
0
answers
69
views
Pushing and popping strings to and from stack NASM 64bit Windows assembly
I am busy implementing the stack on a project, and I got stuck. The goal is for it to display the message in MessageboxA, but not by using any variables, but by only pushing and popping from the stack....
0
votes
0
answers
56
views
Moving integers to the Stack in x86 Assembly
I'm learning to work with the Stack by trying to move integers to the Stack to then print them out in stdout. This is my code:
global _start
_start:
sub esp, 2
mov [esp], byte 1
mov [esp+1], byte 2
...
0
votes
0
answers
43
views
Why doesn't pushing a character to the stack without an explicit nul-char look like an underfined behaviour? [duplicate]
The following snippet comes from the lesson 7 on asmtutor.com :
;------------------------------------------
; void sprintLF(String message)
; String printing with line feed function
sprintLF:
call ...
0
votes
0
answers
27
views
how to save reserved data to register than push it to stack, clear that reserved data and than pop that data from register to print
section .text
global _start
_start:
mov rcx, mesLen
mov rbx, message
mov rax, 0
mov r8, 0
loop1: ; fill buffer
mov dl, byte [rbx+rax]
mov byte [buf+r8], dl ; Use r8 as an index ...
1
vote
1
answer
110
views
Segmentation fault at the `pop rbp` instruction
The following assembly code causes a segmentation fault exiting from the main function at the pop rbp instruction. This code was generated by a compiler I'm writing, so don't mind the superfluous ...