Category "assembly"

How can I get a string returned from a function executed from a byte array?

I have a working C program that has the simple function that returns a d character encoded in a byte array. char foo() { return 'd'; } char byte_array[] = {0

MASM SHA256 running from C#

I received a task in college to compare execution time for calculating SHA256 in C# and assembly. It is supposed to be a simple WPF app with file input and 2 bu

Why don't compilers optimize trivial wrapper function pointers?

Consider the following code snippet #include <vector> #include <cstdlib> void __attribute__ ((noinline)) calculate1(double& a, int x) { a += x

Can compilers break control dependencies used for LoadStore memory ordering or similar, in any real use-cases?

I'm reading the mail list about LKMM: Add volatile_if(). The control dependency is somewhat subtle since it is easily forgotten by us developers. So I wonder i

Total Average Grade Calculator emu8086

I'm new to this assembly language emo8086 and I just wanna ask if there's something wrong about this code because I want to display the average grade, but the o

MOVZBQ equivalent in NASM

Background: I have been learning x86_64 assembly using NASM on a Linux system and was writing a subroutine for strlen(const char *str) I wanted to copy one byte

Load only first byte into a register, from a string at a label

I am trying to load only the first byte in a register after data is passed into it for example if I have the following ASM code global _start section .data stri

Why didn't x86 implement direct core-to-core messaging assembly/cpu instructions?

After serious development, CPUs gained many cores, gained distributed blocks of cores on multiple chiplets, numa systems, etc but still a piece of data has to p

RISC-V build 32-bit constants with LUI and ADDI

LUI (load upper immediate) is used to build 32-bit constants and uses the U-type format. LUI places the U-immediate value in the top 20 bits of the destinati

How to move the cursor with x86 BIOS calls?

I'm doing some operating system tutorials from the book "Operating systems from 0 to 1". One of the exercises is to set the cursor to a position on the screen i

Why are rbp and rsp called general purpose registers?

According to Intel in x64 the following registers are called general purpose registers (RAX, RBX, RCX, RDX, RBP, RSI, RDI, RSP and R8-R15) https://software.inte

Is it possible to have a switch/case with mips using a JumpTable for non sequential options?

I want to practice using switch/cases and JumpTables in MIPS. Currently, I am able to achieve a similar logic via stacking several BEQ commands after each other

Getting MS-DOS SMARTDrive version from interrupt call 2F/AX=4A10h/BX=0000h

I'm trying to write an assembly procedure to get the SMARTDrive version on a given system. The code to detect if SMARTDrive is loaded works correctly, but I ca

Is it possible to read a value from memory being written by another thread, so that it's neither the original nor final?

Suppose we have a variable in memory, which is constantly being updated by a thread of execution by doing something like MOV into it with alternating values (si

Assembly 2 digit 7 segment display

I have got a little problem of understanding how is suppose to work. Basically all what I need is to light up a led on each side of 7 segment display. They over

How to get the beginning address of a string instead of the address of a whole string

SORRY if i make you confuse about the question, but i don't know a better to describe it i'm trying to write a NASM program to reverse a string in place. i ha

IDA patching, How to add new code, create new variable?

I have a very basic knowledge about IDA and patching. From my understanding, I can change a line of code by doing Edit -> Patch program -> Assembly. But h

Tool to compare control flow of disassembly and C

Is there a tool to compare the control flow of some disassembly and some C? Here's my situation: I started with the disassembly (x86_64) of a function. In some

Apparent no-op in Rust assembly output?

I was studying the x86_64 assembly for the following function: /// Returns the greatest power of two less than or equal to `self`, or 0 otherwise. pub const fn

Bit-twiddling Wizardry for Index of Min or Max Element in XMM/YMM/ZMM

Is there an instruction or efficient branchless sequence of instructions to figure out the INDEX of (not the value of) the largest (or smallest) element of an u