All Questions
6,265
questions
1
vote
0
answers
31
views
How can i use functions from libc in NASM 64 bit
im making my own programming language and i wanted to call some functions from libc (es strcat and printf) but im unsure on how to call them correctly(i dont which cpu registry to use and if i have to ...
2
votes
2
answers
57
views
Using printf from c in Nasm causes the string to add random end line statment
this morning i tried to make a simple output library for my asm projects, i realized using the sys call each time is a waste of time and so i decided to automatize the program using printf function ...
0
votes
0
answers
27
views
pwntools p32(arg1) got issue when arg1=10, maybe because 0xa
I was tring to learn stackoverflow so I wrote me a program, here's the source code:
# include <stdio.h>
void pwn(int a, int b) {
printf("Pwned! arg1 = %d, arg2 = %d\n", a, b);
}
...
2
votes
0
answers
52
views
ARM Cortex M4 context switching: How does the hardware know where xPSR, PC, LR, R12, R3-R0 are on the stack?
I'm working on a context switching mechanism for my RTOS which runs on Cortex-Ms.
When I initialize a task's stack, I have it like this
Then, I decrement the stack pointer 8 times to fit R11-R4.
I ...
3
votes
2
answers
127
views
Why does this assembly implementation of strcmp behave unexpectedly?
I've been writing my own naive implementation of the strcmp function in x86_64 assembly.
I've written a c test program to compare the behavior with the real strcmp from the C library.
Even if both ...
1
vote
2
answers
105
views
When an embedded c program is created, why is there extra machine code around my compiled c program?
This C program blinks an LED attached to an AVR ATmega32u4.
ISR(TIMER1_OVF_vect) // attach Interrupt Sub Routine to TIMER1
{
// toggle LED
PIND = (1 << PIND5); // #define PIND (*(...
0
votes
0
answers
47
views
signal SIGSEGV: address access protected in __run_exit_handlers
I'm trying to do a packer project for my school, it is made in C and ASM, and for the moment it is supposed to target only ELF files.
I have managed to do my section injection, correctly align my new ...
1
vote
1
answer
60
views
What are the binary representations for the flags used in the Linux open() syscall?
I am learning NASM and currently unsure what values should be used for the flags argument for open() as shown in the man page. I'm mainly asking this for clarification so I don't mess something up, ...
1
vote
1
answer
84
views
What is the difference between these two functions in x64 assembly?
I'm playing around with lower level stuff in C on Windows (x64) to try and learn low level concepts. I ran across something I don't understand and just wonder if someone could explain something to me....
3
votes
0
answers
52
views
How to pass arguments to a windows syscall in NASM assembly? [duplicate]
I am learning how to implement direct system calls using nasm assembly and c code, I have created a funcs.asm that contains
section .text
global NtOpenProcess
NtOpenProcess:
mov rax, 26h
...
1
vote
1
answer
91
views
Why do I get multiple ASM instructions per addition? (Visual Studio 2022 Community)
Here's the C program, I use Visual Studio Community 2022 with MSVC compiler. What are all those mov instructions, I don't use any compiler optimization flags.
#include <stdio.h>
int main(void) {...
1
vote
1
answer
48
views
E2028: _small_code_ is an undefined reference
I am working on my own bootloader. I want it to print "Hello world". For some reason, I get an error: Error! E2028: small_code is an undefined reference
Hello! I am working on my own ...
2
votes
0
answers
76
views
How does this assembly code perform the source code b = a/3 when a = 2? [duplicate]
I'm trying to trace this C source code (when a = 2):
b = a/3;
To this ARM assembly code (for unsigned 1 byte value):
ldrb r2, [fp, #-6] @ zero_extendqisi2 @ tmp162, a
ldr r3, .L34 @ tmp164,
...
2
votes
0
answers
55
views
Native API Processor information
When I send the first parameter as 1, i.e. SystemProcessorInformation via the ntdll!NtQuerySystemInformation function, I get the output:
Processor Architecture: 9
Processor Level: 25
Processor ...
0
votes
0
answers
99
views
By default compiler generates assembly code or object code [duplicate]
In conpiler design, in books, it is written that compiler generates assembly code then assembler convert that assembly code into object code.
But assembly code is not used, so todays compiler ...