45,199 questions
1
vote
0
answers
88
views
interrupt(): gate descriptor is not valid sys seg (vector=0x0X)
I am making my own UNIX like OS called Connor's UNIX and I am implementing kernel and userspace separation and I have been all day and this is as far as I can get it to work and if you need any more ...
-1
votes
0
answers
67
views
i686-elf-gcc "Error: invalid instruction suffix for 'push'/'pop'" [closed]
I'm following the barebones guide on OSDev Wiki and I'm trying to compile my kernel.c file with
i686-elf-gcc -ffreestanding -O2 -m32 -c kernel.c -o kernel.o
but I constantly get the following ...
Tooling
4
votes
3
replies
94
views
An alternative software to Visual Studio for x86 Assembly programming on Windows 10
I'm starting to learn x86 Assembly but Visual Studio refuses to be installed ("Sorry, something went wrong. The install operation failed") on my (Windows 10) machine; I've researched and ...
-2
votes
0
answers
109
views
Bootloader freezes if kernel is larger than 512B
I have added some stuff in the new-stuff branch, and when I try to boot, it gets to the last "Entering protected mode..." step, but if I revert my kernel to how it was, it works just fine ...
-7
votes
0
answers
90
views
How do I reproduce this CRC32 logic from assembly [closed]
You are given an assembly program that generates a CRC-32 lookup table and then computes a CRC-32–style hash over four input bytes.
The task is to:
Understand how the table is generated
Follow the ...
-2
votes
0
answers
55
views
Learning sources and strategies for CoreWars8086 [closed]
I'm going to take part in a competition like CoreWars8086. I know basic assembly, but I need sources to prepare to this specific type of contest. I did'n find a lot of information in the Internet and ...
Advice
0
votes
4
replies
184
views
Why does GCC transform a >= 4 into a > 3 at -O0? JG seems to be more complex than JGE
Title: Why does GCC transform a >= 4 into a > 3 at -O0? JG seems more complex than JGE
I'm analyzing a simple C code on godbolt and found GCC's code generation puzzling:
long a;
a = a >= 4;
...
2
votes
2
answers
117
views
Printing to VGA in protected mode crashes system
As you can see down at bottom on my stage 2 boot loader, I have a VGA write thing (Prints out "Starting kernel...", but when I use it, the system starts to boot loop, I have no idea why this ...
1
vote
0
answers
77
views
Can't assemble bare-metal i586 protected mode no paging code using openwatcom1.9
I'm trying to compile code in OpenWatcom 1.9 written in assembly.
On Windows, utils in use:
wasm
msys2
command:
/d/Maksym/WATCOM/binnt/wasm.exe -5p kstart.asm -fo=kstart.obj
output:
Open Watcom ...
2
votes
1
answer
56
views
powerpc qemu refuses to load my simple bios file
I would like to make a very simple qemu test with a generic powerpc 32 cpu, bare metal (no ROM or bios)
I have a (stupid) BIOS code (it doesn't matter how simple and non-functional it is, as I'm not ...
2
votes
1
answer
84
views
Using udf (undefined instruction) to check if the behavior is defined?
During debugging of some native code, I jumped into the assembly of calloc() on my MacOS (ARMv8). And I see some interesting technique, that seems to be checking if the instructions are defined at ...
2
votes
2
answers
175
views
I am trying to translate my C code into assembly but my code is not working. What is wrong with it?
I am trying to use an MSP-EXP3430G2ET with a Buzzer and a potentiometer on CCS. The goal of the program is to have 2 modes, a high frequency mode and a low frequency mode. If you press the button, it ...
5
votes
1
answer
78
views
Bootloader crashing when jumping to 0x100000
I am having a problem with a bootloader I made. Mostly used code snippets from wiki.osdev.org, and screeck (on Github and Youtube) . The issue is: the bootloader cannot jump farther than 0xFFFFF, and ...
2
votes
1
answer
84
views
How and why does my program change its input buffer? Using GDB to find out where. (Converting string to int in NASM x86 32bit)
%macro mov_dd 2
push eax
push ebx
mov dword eax, [%1]
mov ebx, [eax]
mov dword [%2], ebx
pop ebx
pop eax
%endmacro
section .data
text db "Enter first Number: &...
1
vote
1
answer
110
views
Does Intel CPU have instruction for paging translation result
I wonder if Intel (and Intel compatible) CPUs have an instruction (for diagnostic/debugging purposes) which, for a given linear address, returns the result of paging translation (i.e. the ...
Best practices
1
vote
2
replies
100
views
Loading a byte: Partial register stall for intel cpus (r8 vs r64)
My assembly program reads characters in a text file by loading them one by one in register 'al'. However I sometime need to use rax fully, and I think this causes a partial register stall. Now I think ...
-1
votes
0
answers
82
views
Why does my Brainfuck interpreter read user input instead of outputting a char? [closed]
I am making a Brainfuck clone and my interpreter isn't working:
// _ dicrement the instruction pointer by 3 if the current cell value is 0
// <, >, +, -, ,, . are the same as in bf
.global ...
0
votes
1
answer
90
views
How does the LDA instruction interact with RAM and IR on MU1 architecture? [closed]
I am trying to understand this LDA instruction.
After the fetch instruction, IR holds LDA S.
1 - In the first step, DIN = [IR], IR is supposed to be interpreted as an address (because of the brackets),...
3
votes
1
answer
113
views
PowerPC/PPC64: The actual bit-ordering/numbering of the POWER9 registers from the programmer POV
Consider the following MSR register (the register's value is for the sake of example):
0x0400000000000000 -> MSR[58] = 1 -> Instruction Relocation for MMU is activated.
Now imagine I want to ...
5
votes
1
answer
69
views
Trying to print a number in MacOS ARM Assembly (M3 Chip)
I'm brand new to Assembly, and I'm trying to figure out how to get my fibonacci program to work. However, it only prints 0's, no matter what I put in the x1 register. What am I doing wrong (or ...
Advice
2
votes
1
replies
82
views
Definition of the DEFINE instruction used in the source for Microsoft BASIC
Does anyone know where I can find the definition of the DEFINE keyword/instruction used in the source code of the Microsoft BASIC interpreter released to the public by Microsoft here: https://github....
4
votes
1
answer
108
views
nasm bios int 13h read sector issue [duplicate]
im trying to make a simple bootloader that loads a simple kernel and the problem is that the kernel code doesnt run i do see prints from the bootloader but not from the kernel here is my code:
boot....
Advice
1
vote
2
replies
132
views
How the Computer Handles Interrupts
What is the difference between an interrupt and a context switch?
I understand the concept of an interrupt and how it occurs. However, I'm digging deeper into the topic.
I studied Computer ...
4
votes
1
answer
118
views
Invalid Operation with Arm64 fcmp and simd
Consider the following snippet:
ldr q0, [x0]
cmeq v0.16b, v0.16b, #0
shrn v0.8b, v0.8h, #4
fcmp d0, #0.0
This is a common way to implement functions such as strlen with SIMD. According to the Arm64 ...
2
votes
1
answer
65
views
PIC-AS locations and debugging for 10F202 with OSCCAL at reset vector?
I am quite new to the PICs and especially with XC8 pic-as and MPLAB-X
I have a ultra minimal project i am working on, and i have some questions regarding the OSCCAL values located at the reset vector, ...
0
votes
1
answer
72
views
STM32 - I2S: Read signal from INMP441
I'm using STM32F103C8T6 to receive the signal from INMP441 with I2S. Using Standard Periph Library with keilC. I configured GPIO, I2S, Usart, I want to get data from INMP441 then send it to esp32 ...
Advice
1
vote
2
replies
147
views
How many general purpose registers are on an x86-64 processor, including alias registers?
I was curious and wondering how many registers are on an x64 processor. I know there are 16 general purpose registers available to the user, but there are supposedly general purpose alias registers ...
Best practices
2
votes
10
replies
288
views
How to tell the C compiler that data pointed to by a pointer won't be constantly modified by another thread after being passed to a function?
In C, when I pass a pointer to a function, the compiler always seems to assume that the data pointed to by that pointer might be continuously modified in another thread, even though in actual API ...
-2
votes
1
answer
73
views
BCM2835 Bare Metal Assembler [closed]
I have a file with the literal Hex content vectors.bin = "12345678900000000"
.data
.align 1
vectors:
.incbin "vectors.bin"
.text
# main variables we don't want changed by ...
0
votes
1
answer
66
views
Why does MOVZ x2, #0x10, LSL 32 appear to have no effect in LEGv8 assembly? [closed]
I’m experimenting with LEGv8 assembly and trying to build a 64-bit constant using MOVZ and MOVK
MOVZ x2, #0x10, LSL 32
MOVK x2, #0x0600, LSL 16
MOVK x2, #0xC614
Decimal: 100714004
So if I ...
0
votes
0
answers
60
views
ATMega328 gets stuck after initial keypress on a keypad (using interrupt)
I successfully implemented a keypad matrix in an atmega328 through polling in the main loop and now my goal is to do it only on key press (using pin change interrupt).
I'm using PORTB[3...0] for rows ...
5
votes
1
answer
142
views
How to access global C variables from within standalone assembler modules with the GCC toolchain for Atmel AVR32?
I am currently developing software for the Atmel AVR32 AT32UC3C0512C. The software consists of C modules (.c files) as well as standalone assembler modules (.S files). My IDE is Microchip Studio 7.0....
2
votes
0
answers
214
views
how to execute x64 ABI assembly code on heap from C
I am creating heap allocated memory with execute rights using windows.h VirtualAlloc and VirtualProtect.
void* write_into_executable(uint8_t code[]) {
SYSTEM_INFO info;
GetSystemInfo(&info)...
3
votes
1
answer
116
views
write(2) syscall doesn't work in Minix 3.3.0 i386 assembly program
I'm writing hello-world program for Minix 3.3.0 i386 in assembly. The exit(2) call works (and the exit code is propagated), but the write(2) call doesn't work. What am I doing wrong, and how do I fix ...
2
votes
1
answer
183
views
Is it possible to call x86 `idiv r/m8` from MSVC2022 using C++ directly?
I am trying to call idiv r/m8 using MSVC2022's current Microsoft Visual C++ Compiler 17.4.33403.182 and C++.
Using the most straightforward approach:
struct cdiv_t
{
// char
std::int8_t quot;
...
4
votes
1
answer
150
views
Qemu Bios; Configuring VGA
I'm trying to write a simple hello world bios for Qemu as an academic exercise, and I've gotten Qemu to believe the display is initialized. I see a black screen upon boot, but writing to character ...
1
vote
2
answers
161
views
How exactly does recursion work in x86 assembly?
My question is focused specifically on assembly (intel). In C for example, recursion can be done with a simple return command but in assembly I feel like there's a lot more things going on, especially ...
-2
votes
4
answers
207
views
How can I see the assembly generated for my code?
I have a case where I have a bitfield that I know starts off as all zeros. And then I then I have something like:
if (isTrue)
bitfield |= flag;
And what I wanted to do was to set it without ...
1
vote
1
answer
107
views
Trouble setting up Interrupts in custom Assembly based Kernel
I am working on an assembly kernel, using the OSDev Wiki and a PDF from Nick Blundell. I have set up my GDT and it seems to work fine. I am also able to load the IDTR as well. However, when I try to ...
2
votes
2
answers
150
views
Location of the first value pushed onto stack in assembly (x86 I386 assembly) (gdb) (AT&T)
Consider the assembly program below:
.section .data
.section .text
.global _start
_start:
pushl $85 #make it obvious in memory
popl %ebx
movl $1, %eax
int $0x80
It ...
2
votes
1
answer
137
views
OSDev: Stuck at adding GDT
I've followed the book OS01 by Tuhdo, kind of made a simple bootloader, that loads the kernel. Then I tried to add some code to set up GDT, but I've witnessed unusual behavior in gdb.
Here I stopped ...
2
votes
2
answers
148
views
Why would MSVC 2022 create two idiv calls for one std::div without any optimizations?
Using CMAKE_BUILD_TYPE="Debug" my MSVC 2022 [17.4.33403.182] produced one idiv call for the quotient and an identical idiv call for the remainder. The code was simply [see here for the ...
0
votes
0
answers
65
views
Multiplication of 2-digit decimal no.s in 8085 asm
We were assigned to write an 8085 assembly language program to multiply two 2-digit decimal numbers after being introduced to the DAA instruction in our microprocessor course. Here are the example ...
4
votes
0
answers
412
views
Why does a simple C++ const array loop break GCC 11.2 assembly output on Compiler Explorer, but not GCC 15 or MSVC/ICX?
I've been investigating the assembly output for a simple C++ loop involving a const array and const size, and I've encountered peculiar version-specific behavior with GCC on Compiler Explorer.
My ...
3
votes
2
answers
154
views
Why does code under a label execute even if I don't branch to it, for an if/else selecting two constants?
I'm learning Assembly through the "Easy 6502 by skilldrick" website.
I have one question. I'm in the part about branching. I wrote the following code:
LDA #$FA
ADC #$01
BCS ...
3
votes
1
answer
146
views
How to catch EXCEPTION_PRIV_INSTRUCTION from RDPMC directly in Assembly (and without SEH)?
I'm experimenting with measuring CPU's instructions latency and throughput on P and E cores using RDPMC on Win 11, something like that:
MOV ECX, 0x40000000 ; Instructions Counter
RDPMC ; Read ...
1
vote
0
answers
43
views
Why does +JSUB in SIC/XE behave differently from LDA regarding dereferencing?
I’m learning SIC/XE assembly and I ran into a confusing behavior with addressing modes. Consider these two examples:
MOJPRG START 0
+JSUB #WRREC
HALT J HALT
WRREC RSUB
MOJPRG START 0
+JSUB ...
0
votes
1
answer
148
views
x86_64 assembly program segfaults if push/pop rdx is removed
writing some simple assembly code, the program segfaults at the second call of subroutine _printint. This only happens if i remove push rdx and pop rdx from either the _printint subroutine or the ...
2
votes
0
answers
77
views
Problem with characters and cmp in x86_64 assembly language (AT&T) [duplicate]
I'm having trouble writing what should be a simple character counting program. Here's the file with the .data section, as given by the author of Learn to Program with Assembly, which I'm following (I ...
2
votes
2
answers
123
views
Pointers, referencing, and dereferencing static strings in assembly language
I'm writing a little toy program to try to help myself better understand this language (AT&T syntax, x86_64 assembly language). Consider this code, if you'll be so kind:
.section .data
mystring: ....