Skip to main content

Questions tagged [assembly]

Assembly language questions. Please tag the processor and/or the instruction set you are using, as well as the assembler, a valid set should be like this: ([assembly] [x86] [gnu-assembler] or [att]). Use the [.net-assembly] tag instead for .NET assemblies, [cil] for .NET assembly language, [wasm] for web assembly, and for Java bytecode, use the tag java-bytecode-asm instead.

assembly
0 votes
0 answers
27 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 (*(...
Johnny Jones's user avatar
-1 votes
0 answers
22 views

Difference between comiss and comisd in x64 asm

I wrote some code to compare the value of xmm10 and xmm6 using: comiss xmm10, xmm6 and then comisd xmm10, xmm6 The first one works, and the second one doesn't. I tried using subss xmm10, xmm6 followed ...
Angad Warhadpande's user avatar
0 votes
0 answers
39 views

Why is my array value not equal to a literal?

I am new to assembly and was trying to work with an array. However, I was geting caught when try to compare the array value to a constant stored in a register. From the following code I was expecting ...
Jeremy's user avatar
  • 1
2 votes
0 answers
23 views

Printing 2D array in MIPS

I have been using a few other posts on here to try and figure out what I am doing wrong but I am stuck and could use some help. I am making a game that has an 8x8 "board" (2d array) similar ...
Sara Malos's user avatar
-1 votes
1 answer
29 views

What is wrong with this control for the brightness of a lamp in ATmega328P?

I'm new to assembly and I'm trying to develop a control for the brightness of a lamp for my college. The lamp must have 5 distinct levels of brightness, one off and four levels with gradual increase. ...
Eric Naiber's user avatar
0 votes
0 answers
43 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 ...
Maxence Gama's user avatar
0 votes
1 answer
38 views

CMake does not compile asm-files (cross-compile)

We set up our build system with CMake and besides C and C++-files we need to compile asm-files (.s). We use a tiarmclang-compiler (LTS3.2.0) and thus need to crosscompile. While everything works for C ...
NetoBF's user avatar
  • 159
1 vote
1 answer
88 views

multidimensional slice access performance in golang

I am working on a little and simple game-of-life in Golang and stumbled on a performance problem during slice access. This is the primary data structure for the game: type Neighbor struct { X, Y ...
Tom's user avatar
  • 119
-1 votes
0 answers
53 views

Why does gdb combine byte values when examining memory as words? [closed]

While examining 4 addresses from $rip as bytes in GDB, it shows 4 individual values. However, when I examine the same addresses as words, it combines that 4 byte values into a single word value. Why ...
Naresh Kumar's user avatar
2 votes
0 answers
54 views

NASM ORG doesn't like SECTION [closed]

Looks like NASM ORG directive doesn't behave correctly in the presence of SECTION directive, in spite that it's compiled to the binary format. I wonder if there's an alternative for ORG in NASM which ...
Ruslan's user avatar
  • 105
1 vote
0 answers
35 views

I'm trying to build a nand2tetris assembler but the ply.lex library in python keep breaking my assembly instructions to different lines

the first thought I had was that I didn't manage to handle the new line character properly because it keeps throwing the new line character "\n" whenever I try to append the instructions for ...
ali eltaib's user avatar
1 vote
0 answers
32 views

Unable to compile NASM without -no_pie on macOS

I'm trying to follow the tutorial for NASM and I made a few adjustments (like changing the entrypoint function from "start" to "_main") to get the following hello.asm to compile ...
Christopher Rybicki's user avatar
1 vote
1 answer
47 views

data segment of AVR store nonsense after compiling

So i'm trying to change the first element of an array that i'm storing in sram and i checked if the data after compile is equal to the value of pre-initialaztion and it wasn't equal. so this my code: ....
user25562504's user avatar
0 votes
0 answers
42 views

Why do I keep getting a Segmentation Fault from trying to access /dev/mem in ARM64 on the Raspberry Pi 4?

I've been working at this program for months, and I've fixed many errors, errors with alignment, other segmentation faults, and I've gotten down to this one, where it throws a segmentation fault when ...
Linklordofgaming 's user avatar
1 vote
1 answer
54 views

gnu inline assembly constraint `i` for memory address

Recetly, this function rip_rel_ptr has been added to Linux kernel. https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/asm.h#L118. I can compile the kernel, but when I copy this ...
amrzar's user avatar
  • 365
-1 votes
0 answers
24 views

How to run an LC-3 Assembly program

I am creating an LC-3 Assembly program. I have managed to assemble it into an obj file. I'm not sure what linker to use / what arguments to use from here. Any help would be much appreciated. I tried ...
NonzeroCornet34's user avatar
0 votes
0 answers
49 views

How can I get this STDIN to work in GAS Assembler running on Linux?

I am new to Assembler and am currently reading a book about it by Jonathan Bartlett called 'Learn to Program with Assembly'. On pages 160-1 he gives the following sample program to demonstrate the use ...
Digital Samizdat's user avatar
0 votes
0 answers
32 views

Is there a library to reassemble and rebuild Windows PE binary? [closed]

I want to disassemble a x64 PE binary, add my own inline assembly code somewhere inside the .text section (or any other executable section), and then assemble the binary back and expect it to work. I'...
abdul's user avatar
  • 13
0 votes
0 answers
30 views

Why is my assembly code giving extra output? [duplicate]

Before I start, it's important to say I am a complete beginner to Assembly, so I might be missing something very obvious. I was trying to make an Assembly program where it prints the following output ...
Spyros's user avatar
  • 101
1 vote
0 answers
48 views

Assembly jump instructions don't seem to work

bits 64 default rel section .data fmt db "%s", 0xd, 0xa, 0 err db "Correct usage: echo <string>" section .text extern printf extern ExitProcess global ...
Angad Warhadpande's user avatar
0 votes
2 answers
56 views

RISC V : I don't understand what the GNU assembler does with labels in the .data segment

I am making my own risc V core as a personal project using the RV32I ISA, I am using a Harvard memory architecture meaning I have a program memory that starts at address 0x0 and a separate data memory ...
user25773352's user avatar
1 vote
1 answer
40 views

how to use speaker (msdos) in new computers? [closed]

I'm programming in assembly, and want to use the speaker, I can do that with out 43, al and out 61, al, this in Dosbox. But i've a notebook with DOS 6.22 in hd, all the program works well, but the ...
Mario Augusto's user avatar
0 votes
1 answer
56 views

Updating an element in array in AVR Assembly

so i'm trying to update an element in array which get used to print the value inside it but after updating the array, what gets printed is still same, the printer used array buffer and i wanna get the ...
user25562504's user avatar
1 vote
1 answer
56 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, ...
dundermouse's user avatar
-2 votes
1 answer
38 views

Code in assembly printing alphabets twice instead of next line. (emu8086)

My code in assembly emu 8086 displays alphabets in lower case but it displays them twice instead of displaying them in new line a single time each. Ive tried everything from AI etc but could not find ...
Moeez Ahmad's user avatar
0 votes
1 answer
30 views

Order in which instructions are printed/executed

Why the output is in diffrent order than it is declared? Shouldnt the output be in this order? aaaa bbbb cccc Instead it is: I assume the issue is in assigning "bbb" value to the text ...
RudyChemik's user avatar
-5 votes
0 answers
82 views

x86 mulss result is diffrent over time [closed]

I am trying to make C++ neural network library and I noticed, that sometimes model with same inputs and same parameter values drastically changes output for no reason. I have no idea why it happens, ...
ZDibLO's user avatar
  • 5
-2 votes
1 answer
81 views

How can we read program counter through assembly code in 68k microcontroller

Can anybody please explain how program counter can be read using assembly instruction in MC68000 controller. Following instruction set gave error - undefined addressing mode MOVE.L %PC, %D0 Also ...
V C Prathap's user avatar
0 votes
0 answers
21 views

how to add an additional dll to an exe file and force it to use

I have an exe file in which I want to make some corrections to the binary code, but I want to do this not just by editing bytes but by using an additional dll, which should patch the current ...
VeryDobro's user avatar
0 votes
1 answer
37 views

How to read the Marie Programme table? [closed]

I want to know how i can read the Marie Simulator table. Im still a beginner to this so can someone explains how the output works in this following example code? Load x add y store z halt x, hex 008E ...
Pivot112's user avatar
1 vote
1 answer
82 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....
Stephen Francis's user avatar
0 votes
0 answers
30 views

System.IO.FileNotFoundException for System.Management Assembly in WPF Application but Works Fine in Console Application

I'm a novice C# developer working with .NET 8.0. I have encountered an issue where my code works perfectly in a dedicated console application but throws an exception when included in my existing WPF ...
MaximeO's user avatar
3 votes
0 answers
51 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 ...
RAT's user avatar
  • 199
4 votes
0 answers
59 views

Why does Intel x86 manual use +rd instead of +ro or +rq for 64-bit registers?

The description of the PUSH instruction in the Intel manual (PDF, Volume 2, Chapter 4.3, PUSH) contains the line 50+rd PUSH r64. It seems +rd is used throughout most of the instruction descriptions ...
user2468852's user avatar
1 vote
0 answers
31 views

Link function calls against reverse engineered binary

I created an windows x86 .exe file that I reverse engineer. Imagine I only have the .exe file and I reverse engineered some functions. The goal is to create a dll that links with this .exe so the dll ...
Edward Gynt's user avatar
0 votes
1 answer
47 views

Debugging assembly to call IUnknown::Release - is shadow space right?

I am getting a bug where sometimes this code works sometimes it does not: 48 8B 41 08 ; MOV RAX, [RCX + 0x08] gets the refcount 48 FF C8 ; DEC RAX ; decrement ...
Greedo's user avatar
  • 5,355
1 vote
1 answer
50 views

My bootloader isn't printing after switching to Protected Mode

I'm trying to print the character "C" after switching to the Protected Mode, but it isn't working, and I don't know why. I'm using Assembly AT&T/GAS syntax Here is the code: .code16 ....
user avatar
0 votes
0 answers
67 views

Game freezes when i call a function in it from a C++ .dll

In IDA Pro, i found a function in the game that writes text to console. Here is the function: ; void __cdecl write_to_console(char *Format, char ArgList) write_to_console proc near ; CODE ...
Ali Alghamdi's user avatar
-1 votes
0 answers
25 views

Writing x64 nasm assembly for windows [duplicate]

I would like to learn how to write x64 nasm assembly for windows but I can't find any resources for that. And also how to compile the assembly into executable program. So if anyone knows of a ...
Matyn's user avatar
  • 1
-1 votes
0 answers
50 views

lmc program division assembly languange

I'm trying to solve this challenge: create a simple LMC program to determine if a number evenly divides another one: Input 2 numbers If they do not evenly divide, then the program outputs 0 and asks ...
milf43 Dining's user avatar
1 vote
1 answer
89 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) {...
CupOfGreenTea's user avatar
1 vote
0 answers
64 views

How to Fix IMUL and DIV Errors in Assembly Calculator Code?

I'm currently learning assembly language and trying to write a simple calculator program. The program is supposed to read two numbers and an operator (+, -, *, /) from stdin, perform the specified ...
권민서's user avatar
-2 votes
0 answers
33 views

objcopy says one of input files was not recognized as a valid object file

Im trying to objcopy two files together but its just not working... I tried the following: objcopy -I bootloader.bin extendedprogram.bin -O bootloader.flp The result was: llvm-objcopy: error: '...
hav0x's user avatar
  • 1
2 votes
1 answer
36 views

Monitor memory modification between instructions in GDB

Is there any way I can check the memory change before and after si, s or something similar commands? First came out with the idea of dump memory for diff, but haven't dig in how to do it. Or maybe ...
XMRHRX's user avatar
  • 123
3 votes
1 answer
63 views

How to get NASM to encode `push` with a sign-extended 16-bit immediate?

When assembling the following with NASM: BITS 64 push 32767 I get 68 ff 7f 00 00. This is interesting to me, since this is the 32b encoding (push dword). Any ideas why it doesn't resort to the 16b ...
Goubermouche's user avatar
1 vote
1 answer
73 views

RISC-V assembly: global pointer set to a weird value

I am experimenting with RISC-V assembly language on an emulator (qemu64, ubuntu for RISC-V). Here is a simple program, its function is to convert the instr string to uppercase, outstr is the resulting ...
Wheatley's user avatar
  • 214
0 votes
1 answer
36 views

x86 NASM Crash - Iterate over string

How to iterate over individual characters of a string in x86 assembly and print them? global _main ; declare _main entry point extern _printf ; extern method section ....
OutOfBrainExcepction's user avatar
0 votes
0 answers
40 views

How can I disassemble a whole obj file in valid asm, amend some sections of such asm code and reassemble to obj?

Is it possible on Linux to use objdump (or any other utility) to fully disassemble an obj file to asm code, modify such code and then pass the asm to as? The challenge I have with objdump is that it ...
Emanuele's user avatar
  • 1,428
20 votes
2 answers
1k views

How to prepare stack pointer for bare metal Rust?

I'm trying to write an x86 bootloader and operating system completely in Rust (no separate assembly files, only inline assembly within Rust). My bootloader works completely as intended within the QEMU ...
suman's user avatar
  • 305
5 votes
1 answer
116 views

Logical shift right without dedicated shift instruction

I am working with an assembly language that does not contain either multiply, divide, or bit-shift instructions. I am aware that a left bit-shift can be achieved by just adding the same number to ...
Kestrel's user avatar
  • 73

15 30 50 per page
1
2 3 4 5
893