All Questions
1,035
questions
1
vote
1
answer
57
views
gnu inline assembly constraint `i` for memory address
Recetly, this function rip_rel_ptr has been added to Linux kernel.
https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/asm.h#L118.
I can compile the kernel, but when I copy this ...
1
vote
0
answers
78
views
Question about String Reversal in C Code: Why does the string appear reversed at the end?
I have this C code where I am trying to reverse a string using inline assembly. However, I am curious to know how the reversed string is displayed at the end:
printf("Reversed string: %s\n", ...
1
vote
1
answer
78
views
Assembly error when compiling C code with ASM instructions
I'm new to assembly language programming and I'm having a problem with a C program that incorporates assembly instructions (ASM) to reverse a string. The code works without errors on my Debian virtual ...
-1
votes
1
answer
96
views
Issue with string length validation in assembly and C
I'm new to assembly language and I'm working on a program that combines assembly language with parts written in C. My goal is to prompt the user to input a string of characters and ensure that it does ...
1
vote
0
answers
51
views
Accessing a pointer stored in memory without loading it into a register
arch i386; syntax GAS
I have a pointer variable called active, to which I have tried to copy a register value in assembly. I have found out pretty quickly that movl %esp, (active) did not set the ...
1
vote
0
answers
45
views
Can't convert .o file created by NASM to .exe using GCC on Windows
I am trying to learn how to make apps using x86. I am using NASM to convert a .asm file to a .o file, then GCC to convert that .o file to a .exe file.
Here are the commands I used in Windows CMD:
nasm ...
2
votes
0
answers
56
views
Custom kernel: Stack unaligned, fault on compiler-generated SSE movaps [duplicate]
I'm seeing a weird problem with my kernel where XMM instructions fail as RSP 16 byte alignment constraint is unmet.
The function frame starts with an aligned value but as it makes space for the buffer,...
0
votes
0
answers
48
views
Compiled i686-linux-gnu glibc on x86_64 not working
On my x86_64 machine, when I configure the glibc (cloned from this) with (I want to build a 32bit sysroot),
../configure --prefix=/sysroot-coulson --host=i686-linux-gnu --build=i686-linux-gnu\
...
0
votes
0
answers
63
views
I can't make in my xv6. I just edited proc.h and proc.c, but 'inb' function which is in x86.h didn't declared well
I'm in Operating System class and doing homework with xv6.
My job was to make MLFQ scheduler so i was editing proc.h and types.h.
But when i try to make my xv6,error like this happens.
root@123:/OS/...
0
votes
0
answers
55
views
IDT returns a General Protection Fault / CPU Exception
I am currenty writing a OS, and using the James Molloy Kernel Dev tutorial, and am stuck on the IDT/ISR section. I know that a general protection fault is happening when I press on a key.
idt.asm
[...
3
votes
1
answer
146
views
Why is there no push instruction in the PLT table?
I have written a sample C code as below
#include<stdio.h>
int foo(void);
int main()
{
puts("Hello World");
int x = 10;
fprintf(stdout,"Hello World 22");
...
0
votes
0
answers
43
views
the difference between two style of inline ASM
My code print FAIL as follow:
Need someone to explain the difference.
I want to know the difference between
__asm__ __volatile__(
"addl %1,%0;"
:"=r"(sum)
:"r"...
1
vote
0
answers
82
views
Making portable execution errors
Making portable execution errors.
I have two files: kernel.c and boot.asm:
boot.asm
[bits 32]
section .text
align 4
dd 0x1BADB002
dd 0x00
dd - (0x1BADB002 + 0x00)
global start
...
0
votes
0
answers
31
views
Why does mov fail to set dynamic section sizes when used on a function using GCC [duplicate]
I'm working on implementing threads in x86_64 Intel assembly, and when using GCC, I receive the following error on compilation, even when I use the -fPIE flag.
/usr/bin/ld: /tmp/cc7xDzsl.o: relocation ...
1
vote
0
answers
168
views
Does this simple code not containing any loop generate a loop in assembly?
I was playing with this code to check if an integer is a power of 4:
// C++ version
bool is_pow_4(unsigned a) {
return (std::popcount(a) == 1) && (std::countr_zero(a) % 2 == 0);
}
// C ...