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
Filter by
Sorted by
Tagged with
0 votes
1 answer
84 views

Issue with Writing to File in x64 Assembly using MASM on Windows

I'm trying to write to a file using x64 assembly with MASM on Windows, but the content is not being written correctly. I've included my code below, but I'm not sure where the issue is. I'm using the ...
0x1d's user avatar
  • 3
3 votes
1 answer
90 views

Are 2 consecutive statements sequenced-before each other?

I'm reading a part of the C Standard related to multi-threaded execution and highly confused by the definition of Sequenced-before which is used to define inter-thread happens before: 5.1.2.4/16: A is ...
St.Antario's user avatar
  • 26.8k
1 vote
0 answers
48 views

Need help making an Assembly program using records

In the following program, i'm trying to obtain the length of the longest name between the records. The program is a exercise from the book Learn to Program With Assembly. .section .data .globl people,...
Encephalonum's user avatar
0 votes
0 answers
63 views

Assembly (Intel's) code (32bit) doesn't behave as expected, reading command line arguments and using C code

I try to first see If I can recognize all the arguments that have -i and -o prefixes and merely print '-i' or '-o' to stdout when I recognize one. For the input: ./encoder -i -iewqfra -ods asr I would ...
Max's user avatar
  • 1
0 votes
0 answers
58 views

Number of memory accesses

What are the number of accesses of the code: MOV R1, R0 STR R4,[R1,#4]! LDR R3,[R1] R1-R4 are all 32 bits. The answer is five and I'm genuinely confused. Can anyone help me with that? So far ...
Nicho Roi's user avatar
3 votes
1 answer
73 views

Disassembling: How can I retrieve the address of a module's global variable via a function?

const char* BotArgs[4] bool UseBotArgs Knowing this function's address, is it possible to retrieve the address of these global variables as well? If yes, I would also like to know how to get the ...
Hattrick HKS's user avatar
0 votes
0 answers
24 views

How addressing works on Macos assembler

I have a program in assembler language that moves all characters back 1 character. It works fine under windows, but under macos it throws a segmentation fault. Here is the code that works under ...
Victor's user avatar
  • 1
3 votes
1 answer
68 views

How does CPU addressing the next instruction immediately after switching into protection mode?

I've been working on the Lab1 of MIT6.828. I've got a question about the code used for switching to protection mode. Here is the assembly code # Switch from real to protected mode, using a bootstrap ...
QZero's user avatar
  • 43
0 votes
0 answers
64 views

Set value of register to 64-bit integer in RISC-V

The task is to set the value of a0 to 0xbadcab1e. a0 is a 64-bit integer. I may only use sll, slli, srl, srli, sra, srai, add, addi, sub, lui. "Hint: The addi instruction sets the 12 bottom bits ...
emircg02's user avatar
6 votes
1 answer
185 views

Why two modular operations cannot be optimized as well as one modular operation

I'm reading a C++ function that handles timestamps, and there's an expression like this: t % (60 * 60) % 60 I thought this expression was strictly equivalent to: t % 60 However, when I entered this ...
2n8 asm's user avatar
  • 61
1 vote
0 answers
41 views

Preventing Arm Neon d8-d15 spilling in a function

I'm having a function to be called through function pointer, which uses all the 32 Arm Neon registers. The calling convention requires to spill and restore the bottom part of the registers d8-d15, ...
Aki Suihkonen's user avatar
0 votes
0 answers
45 views

"Symbol not defined : @STACK " error in ASM code for 8086. Compiled using DOSBOX ,MASM

This is a code to add all numbers between 50 and 150 and display the result in decimal form.I have created the stack segment .STACK 32 to store the remainders to convert the hex result to decimal ...
Bishal Lamichhane's user avatar
0 votes
0 answers
19 views

Cannot pass argument in execve [duplicate]

I am having a problem where I cannot pass an argument in the execve syscall. If I set the argv as null, execve is executed and my program also is executed. But if I run it setting an argument, the ...
João silva's user avatar
1 vote
0 answers
49 views

Cant understand why this code output in a result:ERROR

I think I'm using the right commands to do this task, but for some reason the result is wrong. I have already tried to change this string _res1 db 14 DUP(0),10,13. I also tried to change dword on ...
Bogdan Batyuk's user avatar
2 votes
0 answers
40 views

How to test J and B type RISCV instructions with random operands jumping to random memory locations?

I am using Verilator to simulate Ibex RISCV core. I have written a RISCV random instruction generator, which simply randomly generates RISCV instructions with random operands as well. All these ...
Sarah_lan's user avatar
2 votes
0 answers
69 views

Changing instruction that was misidentified in IDA Pro

I am trying to compare a source code to a disassembled version of a Sega Genesis (68000 processor) game. I ran the binary through IDA Pro to disassemble it, and when I was going through the code and ...
Chaos81's user avatar
  • 21
5 votes
1 answer
122 views

Type-traits for handling structs in Windows x64 calling convention

I'm trying to figure out how to detect if a certain c++-pass can be passed directly in a register, or whether an address has to be passed in the x64-calling convention. For reference, I have my own ...
Juliean's user avatar
  • 931
1 vote
0 answers
37 views

Assembly segmentation fault in example code [duplicate]

I am new to assembly and I have an AMD processor, so I've been learning x64 assembly from books and tutorials. After inspecting the code in GDB and LDD I see that GLibC is included in the linked ...
seanlum's user avatar
  • 93
1 vote
1 answer
92 views

Recursive Factorial of a number using C and NASM

I am trying to find the factorial of a user input number, and display it. The issue I am facing is that no mater what the input, output is always 1. The input and output part is done through the C ...
X_Abhishek_X's user avatar
0 votes
0 answers
44 views

Variable unexpectedly changing value in assembly

I'm doing some code that I'm running on a VM and this code does directly interact with memory addresses, (which might be the issue I'm not entirely sure) I've been finding that my variable has been ...
SCP-1762's user avatar
0 votes
2 answers
60 views

How are registers used to specify parameters for the SVC function in ARM Assembly?

I've seen assembly code where registers R0-R2 specify certain parameters for the SVC function, but don't know if that's always specific to those registers or not. Also, if the parameters are specific ...
Dawson Chitwood's user avatar
3 votes
1 answer
89 views

Performance advantage of 32bit registers in AArch64?

When doing integer operations in AArch64/ARM64, is there a performance difference when using 32bit W{n} registers versus 64bit X{n} registers? For example, is add W1, W2, W3 any faster than add X1, X2,...
DarkDust's user avatar
  • 91.6k
1 vote
1 answer
30 views

Change text color in Z80 assembly for Amstrad CPC 464

I am trying to code this program, similar to game: "The Typing of The Dead" in Amstrad CPC 464 using Assembly language for the Z80 processor. The program consists in when you see a string of ...
reymagnus's user avatar
  • 357
2 votes
1 answer
81 views

How does msfvenom shellcode actually work to execve sh -c ls

MOV RAX, 0x68732f6e69622f CDQ PUSH RAX PUSH RSP POP RDI PUSH RDX PUSH 0x632d PUSH RSP POP RSI PUSH RDX CALL FUN_0000001e INSB RDI, DX JNC FUN_0000001e FUN_0000001e: PUSH ...
Ricket's user avatar
  • 21
0 votes
0 answers
59 views

How to print a number in Arm Assembly on Mac M1

I am new to arm assembly and have been teaching myself from online resources. I am not able to figure out how to print a number while trying to code the classic FizzBuzz problem. This is my code: ....
Pranay's user avatar
  • 1
0 votes
0 answers
20 views

output won't print when code is ran, nasm x86 [duplicate]

I am trying to write a program in assembly that will add two numbers and display the output when ran, but somehow the output won't print when I run it. This is on NASM. I am very new to assembly. Any ...
kat's user avatar
  • 1
0 votes
0 answers
55 views

How do I get my code to stop having Segmentation Faults?

I'm trying to get this assembly code to print out an array of random numbers and then use an insertion sort algorithim to print out a sorted list. However, my code will only print out the unsorted ...
Jarvis's user avatar
  • 21
0 votes
1 answer
50 views

Get trace of executed Instructions in Spike simulator

Please provide various methods to generate a trace of executed instructions for C code using the Spike simulator. I have created a simple "Hello World" C file and generated hello.elf and ...
Vindhya Ejanthkar's user avatar
-3 votes
1 answer
149 views

What is the meaning of "ptr" in assembly?

Since [si] in brackets is like the value at the address si like the *si in C and since offset si is like &si what about ptr in mov dword ptr [si], ax ?
MatR's user avatar
  • 9
0 votes
1 answer
61 views

Can I execute an Assembly code in Motorola 68HC11 and other processors like ARM or x86?

My engineering teacher is a very stubborn man that wants to use a chip that has been gone for ages now. My question is: can I learn Assembly language for my computer and use it in Motorola or do I ...
S-ata-N's user avatar
  • 11
0 votes
0 answers
28 views

Understanding control flow in Assembly [duplicate]

This function is not iterating properly. The result of it just squares the base regardless of the exponent. I have commented my thoughts on what I think is happening. As an aside, is there an easy way ...
yaBoi's user avatar
  • 95
0 votes
0 answers
47 views

Seven Segment Display Counter

Use the MSP430 seven-segment daughter board (available in the IEEE office) to implement a hexadecimal up-down counter on a single digit of the seven-segment display. The counter should start at 0x0, ...
Logan LiVigni's user avatar
2 votes
0 answers
35 views

How can I use Make to build NASM-syntax assembly? (Windows)

Really new to this and I'm kind of clueless and new to doing anything in assembly. Like the title says, im using NASM as the assembler and using Make to build the project. every resource I've seen ...
user23492666's user avatar
0 votes
0 answers
46 views

G++ & NASM fails to compile code and work in Rocky 9 Linux but compiles fine with Centos 7

I have g++ code calling assembly code. This compiles in Centos 7 and works in Centos 7 & Rocky 9. However if I compile in Rocky 9 or Centos Stream 9 it fails and segmentation fault on first line ...
Jonathan's user avatar
0 votes
1 answer
135 views

How can I implement the C puts function in RISC-V assembly?

I am trying to implement puts in assembly. I have written a putchar function to write a char to STDOUT, but I am struggling to use that to create a loop to print out a whole string by calling putchar ...
scou1218's user avatar
-1 votes
1 answer
49 views

Unexpected behavior when running pop {r11,pc} [duplicate]

I am debugging a simple program using gdb, And I am getting unexpected behavior when I am running the instruction pop {r11,pc} The stack before the execution of the instruction is: Stack before the ...
Michael's user avatar
3 votes
0 answers
103 views

Why I can't call calc.exe but calc is ok in assembler x64 win32 API

I am currently studying shellcode writing. I have studied some assembly in the past but I jump from topic to topic in my studies and things are easily forgotten. (the setup) gcc --version gcc.exe (...
Andrei's user avatar
  • 31
1 vote
1 answer
81 views

Turbo Assembler (TASM) Undefined symbol error for extrn procedure

I am working on some Turbo Assembler which I was introduced to in my architecture class. The problem I am working on is using the extrn and include keywords to access a function/procedure from one ASM ...
Larry White's user avatar
-1 votes
1 answer
51 views

Converting from MASM to NASM

I've been working on converting some code from MASM format to NASM format for assembly. However I am not very educated in either, and I keep running into issues. I barely understand NASM as is so ...
Terrible Terror's user avatar
2 votes
0 answers
118 views

Sparse matrix / vector product, how come some code using knowledge about the matrix structure is a lot slower than naïve optimised code?

I have some sparse system of which I know the structure. I implemented a naïve sparse matrix / vector product, which has no informations on the structure of the matrix, and a version of that product ...
Roco Le Coquelicot's user avatar
0 votes
1 answer
63 views

Beginner in assembly language on even and odd parity

I am unable to answer this question in my homework. Can somebody sample a solution I can reference to understand how to tackle this? Initialize any random word in memory, e.g. 0x55555555. Only Bit 0 ...
Maverick Dasig's user avatar
1 vote
2 answers
98 views

What is the meaning of register1:register2 in assembly language?

What is the meaning of register1:register2 in assembly language. For example ax:bx, then which type of address will be used in this instruction. Obviously two registers AX and BX are involved in this ...
AshokDavid's user avatar
0 votes
0 answers
39 views

Assembler i8080 print result in decimal format

I need to write number of words that doesn't have (+,-,*,/) inside. The result must be given in dec. form like 04, 00, 15 etc. I have number of words inside the e. If the number of words is less than ...
matthews's user avatar
0 votes
1 answer
98 views

Loading negative values into RISC-V

I have an assignment where I have to load values into register s7 and everything is working fine until I get to -2999.` xor s7, s7, s7 # Clear s7 addi s7, s7, 29 # Add 29 to s7 # b. -214 xor s7, ...
Savage's Project's user avatar
0 votes
0 answers
52 views

Pushing and popping strings to and from stack NASM 64bit Windows assembly

I am busy implementing the stack on a project, and I got stuck. The goal is for it to display the message in MessageboxA, but not by using any variables, but by only pushing and popping from the stack....
Marnu van Sandwyk's user avatar
0 votes
1 answer
107 views

Can't index arrays in assembly

I've been trying to learn some assembly and was testing out arrays and found that when I tried to print out the value at the point indexed nothing happened, after experimenting further it appears that ...
SCP-1762's user avatar
0 votes
0 answers
44 views

Assembly draw line function

So, In my OS, I created a put pixel function. Im trying to make a draw line function with it. here's my code: org 0x7e00 [bits 16] _start: mov ah, 0x00 ; Set Video Mode mov al, 0x03 ; ...
XICreations's user avatar
0 votes
2 answers
67 views

My recursive RISCV assembly code returns the same value as the input

My task: Write an assembly program that uses recursion to add the number 42 to a sum 𝑛 times, where 𝑛 is given by the input. The problem I encountered is that every time I input a value, the same ...
Chris Wang's user avatar
2 votes
1 answer
94 views

"Cannot find bounds of current function" error in GDB while debugging bootloader code

I'm currently learning bootloader development and debugging with GDB to observe memory changes when the A20 line is disabled in real mode. Since QEMU automatically enables the A20 line, I'm attempting ...
Abhijith Ea's user avatar
9 votes
1 answer
322 views

Why do we set the least significant bit as part of converting a 64-bit unsigned integer to a 32-bit float on x86?

#include <cstddef> float cast(size_t sz){return sz;} Compiling the above code on Clang 13.0.1 with -mavx2 -O3 produces the following code: cast(unsigned long): # @...
Sea Erchin's user avatar

1
4 5
6
7 8
887