45,063 questions
Score of 2
1 answer
118 views
Why isn’t the stdout of my program redirected into a file? [duplicate]
I’m writing a C compiler and I want to test the produced assembly on some examples.
With a C program that prints the integer 10 followed by a newline, I get this assembly code (after a bit of cleaning)...
Score of 3
1 answer
149 views
How to use variadic system calls from assembly?
I found documentation about variadic libcalls (usually with printf() as example) but I didn't find docs about how variadic syscalls are done.
Docs say that the amount of fp registers must be set in ...
Score of -6
1 answer
134 views
Nasm : how do I get rid of segmentation fault (core dumped)? [duplicate]
I was trying to "mess around" with the CMP instruction NASM and then I was faced with
Segmentation fault (core dumped) ./cmp_jmp
I don't know what to specify besides that I am ...
Score of 2
2 answers
339 views
How to safely manipulate or inspect stack frames in C++ using inline assembly without triggering Undefined Behavior?
I am writing a low-level routine in C++ that mixes inline assembly (or an external .s file) to inspect or modify the current stack frame.
Here is an example:
#include <iostream>
extern "C&...
Score of -4
0 answers
80 views
How to run an executable using Win32 API in x86 ASM? [duplicate]
I'm coding a 32-Bits program in ASM, and now i'm wondering.
How can we run an executable like cmd.exe using Win32 API in an ASM Code?
I use nasm btw
Score of -3
0 answers
95 views
Assembler for zos addressability problem when using db2 (exec sql)
I wrote a program in HLASM (High level assembler for Mainframe) with one EXEC SQL instruction and I am getting the following errors caused by the DB2 Translator as follows:
The instruction I wrote is:
...
Score of 10
2 answers
1030 views
Why does the GCC compiler generate operands and mnemonics that specify just the low-order bytes instead of using the declared size?
In the book Computer Systems: A Programmer's Perspective an example from Section 3.5.3 shows us the different operations along with their assembly counterpart.
C code:
long arith(long x, long y, long ...
Score of 11
1 answer
516 views
Minimizing overhead for constant loading and composition with compilers for RISC architectures
An issue affecting most RISC architectures is the efficient creation of literal constants. When not loaded from memory, this usually requires a LOADHI instruction of some sort, plus an OR or ADD with ...
Score of 6
1 answer
230 views
What's the difference between Windows WriteFile and WriteConsole?
What's the difference between WriteFile and WriteConsole in Windows?
The documentation says:
For WriteFile, "Writes data to the specified file or input/output (I/O) device."
(https://learn....
Score of 4
1 answer
127 views
Xtensa callN usage in syscall handlers
I'm working on esp32 (with xtensa quemu emulation at the moment) creating an "OS" from scratch to learn low level and hardware.
So far i created syscal handlers (print uart, exec, and exit) ...
Score of 4
1 answer
193 views
Is scalar fmov guaranteed to clear the upper lanes to 0?
I ran a quick test:
typedef float __attribute__((vector_size(16))) simd_float4;
#include <stdio.h>
int main(void) {
simd_float4 test = {1, 2, 3, 4};
__asm__ ("fmov %s0, %s1" : &...
Score of 4
2 answers
397 views
Observed cycle/iter greater than what's expected in simple x86 loop kernel
I am on a Skylake-X machine. Here's a very simple loop:
%include "events_asm.inc"
section .data
fmt: db "CYCLES = %lu, RETIRED = %lu", 10, 0
section .text
global main
extern ...
Score of -2
1 answer
292 views
How to retrieve argv and argc in assembly language for x86_64 processors on Linux (SYSTEM V) OS
I was wondering how to retrieve argv and argc using x86_64 assembly language code on Linux (and SYSTEM V).
Score of 4
3 answers
204 views
Assembler linking or including
If your project is entirely in assembly, what would be better: %INCLUDEing everything in one main file, or declaring extern, global for every symbol you want to share between your files and linking it ...
Score of 25
1 answer
980 views
Removing an unused class member slows down program?
While implementing a simple data structure for more memory-efficient computation of a recurrence table, I noticed something odd: when the unused class member head_ below is removed, the program ...