732 questions
1
vote
0
answers
79
views
cuda & cpp - compilation and linking using cmake
I want to create a skeleton for a project in which there are multiple cuda and cpp files. They will be compiled individually and then linked together to form a single executable.
Currently I have the ...
1
vote
0
answers
145
views
Dallas DS18B20 - problem with address decoding
I am implementing my own SW for getting data from DS18B20, but I've been stuck on decoding address for a while - "receiving" only zeros as a result. Here is my code:
#include <avr/io.h>...
2
votes
1
answer
101
views
how does the cpu find static/global objects on x86?
I know the stack pointer can be used to find stack allocated objects, but how does the cpu find global/static objects? From what I could tell from the disassembly, it uses absolute/immediate ...
2
votes
1
answer
148
views
Does risc-v require memory address 0 to be invalid?
So in risc-v, for a virtual memory system, I imagine it's up to the kernel to decide if 0 is a valid memory address or not? But for machine mode, or supervisor mode, is memory address 0 valid to ...
1
vote
0
answers
78
views
How to insert a character from a virtual keyboard into the focused window using Tauri and pure JS?
I'm building a virtual keyboard using Tauri and pure JavaScript. My application is already set up, but I want to insert the character from the virtual keyboard into the focused window when a key is ...
2
votes
0
answers
77
views
How do I resolve the recursive dependency in my page frame allocator (custom OS)?
I’m developing a custom OS and facing a chicken-and-egg problem with my page frame allocator. I need to map a specific page, but if the corresponding PML4 entry is NULL, I must allocate a PDPT. ...
2
votes
1
answer
121
views
Low level I/O in C
I am trying to solve a problem from the K&R C programming book that requires one to write a low level I/O program which reads text from a file and prints it on screen, if no input file is given in ...
1
vote
0
answers
178
views
How to directly access BCM2835 registers in C programming for GPIO control on a Raspberry Pi running FreeBSD 14.2
I am trying to control GPIO pins of a Raspberry Pi 3/4 running FreeBSD, using direct access to the BCM2835 registers. My code is based on Mike McCauley's C library.
It works fine on Linux (Raspberry ...
94
votes
10
answers
7k
views
How do I create a "spacer" in a C++ class memory structure?
The issue
In a low level bare-metal embedded context, I would like to create a blank space in the memory, within a C++ structure and without any name, to forbid the user to access such memory ...
66
votes
12
answers
92k
views
Divide by 10 using bit shifts?
Is it possible to divide an unsigned integer by 10 by using pure bit shifts, addition, subtraction and maybe multiply? Using a processor with very limited resources and slow divide.
1
vote
1
answer
69
views
Optimizing low-level structure for CPU memory performance in my game simulator [closed]
I am writing a world simulator for a turn-based game. The key feature is that there will be many NPCs with detailed psychology modelling, perhaps 20,000 - 30,000 of them. I want all NPCs to make their ...
-1
votes
2
answers
1k
views
Compiler for Z80 CPU
I'm a student at an engineering college, and I have encountered a problem while working on a project. In this project, I am designing a microcontroller. I opted to use the Z80 CPU due to its ...
1
vote
1
answer
103
views
Why a string disappear from the stack when exiting from a function
I'm experimenting with the stack in C to test some things and learn more in the language.
I know that a function has a stack frame created by moving the rsp/rbp pointer.
What I don't understand is ...
82
votes
8
answers
55k
views
Why bit endianness is an issue in bitfields?
Any portable code that uses bitfields seems to distinguish between little- and big-endian platforms. See the declaration of struct iphdr in linux kernel for an example of such code. I fail to ...
1
vote
2
answers
111
views
MIPS Assembly--> BEQ
I'm using MARS 4.5 like editor to coding in Assembly Mips.
Today I'm learning BEQ, however I have a problem with this code:
.data
Message_1: .asciiz "I numeri sono uguali"
Stampa:
li $...
2
votes
0
answers
111
views
I can't run this assembly code on my Windows
I want to do the typical Hello World in assembler from my Windows with 64-byte architecture, and it simply doesn't show me anything when running the executable program.
extern printf ...
1
vote
1
answer
170
views
Cannot Log Multiple Outputs with WriteConsoleA in Windows 10 (64-bit) Assembly Program
I am learning assembly development on Windows 10 (64-bit) and using IntelliJ IDEA to write my assembly code. I'm trying to log multiple outputs using WriteConsoleA, but only the first log message ...
3
votes
1
answer
425
views
int_fast8_t size vs int_fast16_t size on x86-64 platform
I already learned that on the x86-64 platform using any 64-bit register would need a REX prefix, and any address less than 64 bits would require an address-size prefix.
On x86-64 bit:
E3 rel8 is jrcxz
...
35
votes
25
answers
52k
views
What is the best way to add two numbers without using the + operator?
A friend and I are going back and forth with brain-teasers and I have no idea how to solve this one. My assumption is that it's possible with some bitwise operators, but not sure.
49
votes
25
answers
24k
views
How are Operating Systems "Made"?
Creating an OS seems like a massive project. How would anyone even get started?
For example, when I pop Ubuntu into my drive, how can my computer just run it?
(This, I guess, is what I'd really ...
2
votes
1
answer
266
views
Why is there low-level and high-level assembly
I want to learn assembly, but the kind of tutorials i com across seem to adhere to one of two sides: either [relatively] high level or everything built from scratch. Personally, i want to learn from ...
0
votes
1
answer
269
views
Where exactly is the first data sector on a FAT file system?
I don't really understand where the first data sector is supposed to be on a FAT formatted disk (especially for FAT-12 and FAT-16). I already read the Microsoft documentation for FAT systems, which ...
0
votes
1
answer
66
views
Vec clears, when I use rust workspaces with my crate [closed]
I have recently created a tool, that allows me to access struct from anywhere in the code, just by the structs name.
The way it works is pretty simple, allocate enough space to hold the desired ...
2
votes
0
answers
591
views
static link ffmpeg to rust binary
I use the library fffmpeg_next from crates.io/ffmpeg-next in my project,
which is a bindings to ffmpeg.
I compile it on windows 11 with msys2 ucrt64 and windows-gnu compiler of rust.
I would like to ...
1
vote
1
answer
240
views
Bochs Panicing After Not Finding Speaker In WSL
I am making my own basic operating system and I obviously face some bugs, until now I have been just using the build logs but as the OS gets more complex it becomes very hard to debug. That's why I ...