All Questions
122 questions
0
votes
1
answer
516
views
Why are %rbp and %rax invalid operands for movl?
I'm trying to put the value of %rbp into the %rax register using __asm__ so that I can get a reference to the stack frame that won't be changed when I create an external variable.
I'm using the ...
0
votes
0
answers
65
views
Why does allocating 24 bytes not cause a segmentation fault but 16 does? [duplicate]
I'm writing some simple x64 assembly code and am having a bit of trouble understanding some fundamentals about how the stack frames are set up.
.section .data
infmt: .asciz "%d"
...
0
votes
0
answers
74
views
Trying to understand x86 GAS assembly, why doesn't this work?
For information, the assembly (.s) code wont work without the C (.c) code. The C code makes a call to asm_function() which in the assembly code is FUNC(asm_function).
I know C code well enough, but i ...
1
vote
0
answers
384
views
mov -8(%rbp), %rax not updating %rax value
Below is my assembly for the C code
int main() {
int a = 1;
int b = 2;
return a + b;
}
.globl main
main:
push %rbp
mov %rsp, %rbp
mov $1, %rax
push %rax
mov $2, %rax
...
0
votes
1
answer
2k
views
"movl" instruction in assembly
I am learning assembly and reading "Computer Systems: A programmer's perspective". In Practice Problem 3.3, it says movl %eax,%rdx will generate an error. The answer keys says movl %eax,%...
0
votes
0
answers
138
views
How do I change bytes in a string using pointers in x86 att? [duplicate]
#include <stdio.h>
extern char *printbin(unsigned char);
int main(void)
{
unsigned int x;
printf("enter the character's ascii value in hex: \n");
scanf("%x",&x);
...
0
votes
0
answers
75
views
How to increment %eax register and output in a c callable function?
#include <stdio.h>
extern int count(char *string, char c);
int main(void)
{
char s[100];
char c;
printf("Enter a string of characters:\n");
scanf("%s", s);
printf(&...
0
votes
1
answer
223
views
Trying to implement a spin-lock via "lock xchg" assembly
Basically, I'm trying to run void spinlock_counter(int) in two threads and count ought to be 2000(parameter doesn't do anything I'm just too lazy). However I made a breakpoint in the critical zone i.e....
0
votes
1
answer
1k
views
Error: operand size mismatch for `lea' (seems like syntax error)
I'm trying to add a function S_0x804853E in an assembly file compiled by GCC. And i'm trying to assemble the file to execuable file. The complete assembly file is followed.
.file "simple.c&...
1
vote
2
answers
417
views
Why does GDB say that this address is being called
I made a very simple C program to print "hello world" to the screen. But in the disassembly, I noticed something strange.
test.c:
#include <unistd.h>
#include <stdlib.h>
int ...
1
vote
1
answer
84
views
How this assembly code will be translated into c?
In C I have the following struct:
typedef struct _Node{
int data;
struct _Node *left;
struct _Node *right;
} Node;
and the following assembly code:
.section .text
.global _start
_start:
...
9
votes
2
answers
4k
views
What assembly language does gcc produce on my system?
I'm trying to learn a bit about assembly. I decided to start by looking at the generated assembly files from simple source code. Of course, I get bombarded by instructions that I have no idea what ...
1
vote
1
answer
99
views
Assembly Code to C, what are the arguments in the C code that will make the Assembly code
So I just signed up for this online course, and this was part of my first assignment, I have already found the missing pieces in the assembly code and have gotten this far.
This is the assembly code:
...
1
vote
1
answer
839
views
How to implement memmove, not just memcpy, in assembly?
I was trying to implement memmove from C into x86 assembly so I wrote:
start:
movb source(%eax), %cl
movb %cl, destination(%eax)
inc %eax
cmp num, %eax
jne start
end:
But this is ...
0
votes
1
answer
368
views
Hex Character bit rotation [duplicate]
I wrote the following x86-64 functions to be called in a C program:
The first one takes in a 2-digit hexadecimal character and rotates its bit towards the right by one bit, i.e, if '12'(means 0x12 but ...