All Questions

59 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3votes
2answers
991views

Call C function from Assembly code using as88 Assembler

I'm working on a Floating Point calculator for 16bits processors, specifically 8086/8088. I'm using as88 Tracker which doesn't implement floating points, not allowing me to use sscanf with "%f". I ...
user avatar
2votes
0answers
69views

Why does the Windows x64 calling convention require XMM (FP) args copied to integer registers, for variadic functions like printf?

I am trying to assemble following code using NASM on Windows. The printf function is supposed to take xmm0 through xmm2 for fractional point arguments. Why do I have to place fractional arguments in ...
user avatar
  • 175
2votes
0answers
753views

x86_64 asm calculate floating point to power of another floating point

Okay so I have to calculate this kind of calculation: 10^(some floating point value) where the floating point value (the exponent) is stored as double in xmm0 register calculated before with divsd ...
user avatar
2votes
0answers
78views

How does the "r" suffix correspond to a floating point number when using MASM?

When using MASM I find no information on how a value is formatted in floating point hex. For example: What is a decimal value of 50.1 equal to when using the "r" suffix? Also according to the MASM ...
user avatar
2votes
0answers
226views

NASM Assembler Floating Point Addition

I'm going through Computer Architecture course in my college and we are writing currently NASM codes linked with C. We have a task to code 32-bit IEEE-754 Addition, i.e 2.0 + 0.1 = 2.1. Requirements ...
user avatar
  • 21
2votes
0answers
250views

PowerPC: what does 0 / 0 do when floating point exceptions are disabled?

I don't have access to a physical PowerPC system but am writing an emulator for the 603e model. The programming manual describes the floating point exception model in some detail but is unclear about ...
user avatar
  • 91
2votes
0answers
519views

ARM: Floating point (VFP) instructions won't work when pushing into the stack

I am trying to print some floating point values in ARM Assembly. As long as I don't push stuff into the stack the value gets printed correctly. If I push something it just prints 0. This code works ...
user avatar
2votes
0answers
143views

Stalled cycles due to fldz instruction

I am trying to interpret some perf results on a Xeon x5675 processor. I have a program where a large percentage of the cycles are stalls (from perf stat). Using perf record -e stalled-cycles-...
user avatar
  • 1,855
1vote
0answers
120views

Floating point operation in x86 assembly

I have questions about the floating point number operations in x86 assembly. With Irvine library, I use ReadFloat to read two floating point numbers from the user, and store each number in fpA and fpB....
user avatar
  • 11
1vote
0answers
60views

What is the x86 equivalent of VCVT instruction on ARM when converting between floating-point and fixed-point elements of a vector?

I am learning some assembly and was disassembling some ARM code and then I found this: vcvt.s32.f32 q8, q8, #0xf So I started going over the ARM reference manual and I am now struggling to find the ...
user avatar
1vote
0answers
45views

how to read value from file then make comparison to the respective requirement? the compare/jump command does not work

this is for masm assembly. here it reads from file. file contents is put into buffer mov edx, OFFSET buffer mov ecx, SIZEOF buffer call ReadFromFile mov buffer[eax],0 ...
user avatar
  • 71
1vote
0answers
117views

When I compile my code with nasm -f elf64 -o I get the error "parser:instruction expected"

I'm trying to calculate a * x^2+b * x+c, with a,b,c,x known. I'm building this code in Linux. When I assemble my NASM code with nasm -f elf64 -o I get the error "parser:instruction expected"...
user avatar
1vote
0answers
69views

AMD64 Assembly: Correctly returning a float from function

As a learning exercise/small project i am writing a simple compiler. This is the source code i am compiling (my own language): fn: main(arg: float) ~ float { return arg * 4.0; } As seen, this ...
user avatar
  • 520
1vote
0answers
75views

How can I change the precission of a floating point number in ARM Assembly?

I am currently studying computer sciense and in one of my classes (Computer Arquitecture) i am asked to make a function (in ARM assembly) that shows te result of multipying euler to a power (input). ...
user avatar
  • 55
1vote
0answers
329views

Computing powers in 64-bit assembly

I know that in 32-bit assembly, one can compute a power (the equivalent of pow(double, double) in C) using a combination of the x87 instructions FYL2X, F2XM1 and FSCALE. In 64-bit assembly, however, ...
user avatar
  • 2,234
1vote
0answers
95views

MIPS ASSEMBLY, printing out values, sudden breaks

I have to make a program where I input 3 decimal values, and it returns floats of those decimal values. It then is supposed to compute and print the max for the first two values, and print out the sum ...
user avatar
1vote
0answers
54views

RISC-V SiFive HiFive Unleashed FMSUB.S(32) underflow flag behaves differently depending on rounding

Here's the situation. I am executing instruction FMSUB.S on mentioned in the title hardware. I am using operands values as such: 0xB3800000*0x00500000-0x80800000, with rounding to nearest-even. If I ...
user avatar
1vote
1answer
524views

Why the cos function in math.h faster than x86 fcos instruction

The cos() in math.h run faster than the x86 asm fcos. The following code is compare between the x86 fcos and the cos() in math.h. In this code, 1000000 times asm fcos cost 150ms; 1000000 times cos() ...
user avatar
  • 71
1vote
0answers
247views

How to write inline assembly with floating points

I am writing a simple program where I am assigning value of one float to another. float a = 1; float b = 2; b=a; I want to convert the "b=a" line to inline assembly. I have written the following: ...
user avatar
  • 123
1vote
0answers
708views

Finding the exponent of a binary number written in scientific notation in MIPS

Say I have the number 12 in decimal. This would be equal to 1100 in binary. I know that this can be written as 1.100 * 2^3 How in MIPS can I get the exponent value 3 and store it in a register?
user avatar
  • 309
1vote
0answers
306views

x86 Assembly, how to reproduce fscale in C

Having float numbers 31.0 and 0.85842... how can I reproduce following fscale operation in C to get the same result of 1843450267.9 ? (gdb) info float R7: Valid 0x3fff8000000000000000 +1 R6: ...
user avatar
  • 11
1vote
2answers
494views

Nasm floating point reading and printing error

This is the code I wrote for reading 2 floating point numbers and stored it in the memory. Then I load it from memory and print it. However, I'm getting wrong value for first number when printing it. ...
user avatar
1vote
0answers
2kviews

LLVM IR and floating point numbers

I'm trying to figure out how to write out non-exact floating point numbers in LLVM (such as 1.3). This is what the documentation has to say about them: The assembler requires the exact decimal ...
user avatar
  • 593
1vote
0answers
726views

Modulus a double precision floating point in MIPS?

OK, so basically I am having trouble getting one part of an RSA encryption program to work correctly. I am writing the program in MIPS and am trying to take the modulus of a number raised to another ...
user avatar
1vote
0answers
154views

"fsub infinity, infinity" gives 0 in st0 in gcc optimized code

I have a code that works fine in -O0 mode and but gives wrong results with -O2. Basically it's something like double x1 = std::numeric_limits<double>::infinity(); double x2 = std::...
user avatar
  • 15.1k
0votes
0answers
75views

How to Initialise 16-bit Half Floats (GAS for ARM32)?

When writing an ARM assembly program one can use data type directives to initialise some values. For example, in the example below we are initializing a single float: label: .single 0.0 However, when ...
user avatar
  • 181
0votes
0answers
34views

How do I modify my display function to accept floating-point numbers via the stack?

I am trying to print a floating-point number with x86_64 assembly on MacOS using Clang, with Intel syntax: clang -masm=intel float.asm. I was told that I should pass a floating-point argument through ...
user avatar
0votes
0answers
40views

Working with float values in MASM and getting them into variables

I am trying to get the value from ST(0) register and get it stored in the variable. But my attempts are failing horribly. Here is part of code, where I am interacting with the float values. The ...
user avatar
  • 5
0votes
0answers
46views

Floating point algorithm instruction (FYLXP1) returns 0

I am attempting to use the instruction FYL2XP1, but it seems the result is always 0, so I do not know what I am doing wrong. Keep in mind, I am a beginner in assembly. Here is my code. I use MASM and ...
user avatar
0votes
0answers
93views

Assembly floating control output

Is there any way to output the floating point number to the sixth decimal place in assembly? How to write? I use Irvine32. The general output is +x.xxxxxxxE+xxx I know the x87 control word can set ...
user avatar
  • 41
0votes
0answers
70views

Converting a cpp code to an appropriate assembly language for the 8085 simulator

I wrote a cpp code for applying Newton Raphson method for a polynomical function (ax^6 + bx^5 + cx^4 + dx^3 + ex^3 + fx^2 + gx + h) (I assumed all variables were 1, so I just defined a) and I want to ...
user avatar
0votes
0answers
187views

How to write a sequence of MIPS instructions to divide the floating number at X by (-4), without using any floating-point instruction.

I didn't understand how it is possible to load floating point into integer later diving with -4 without using any floating-point instruction.We assume that there is no overflow.I'am asking this ...
user avatar
  • 317
0votes
0answers
56views

How to print floating point numbers in assembly without c library?

How to print floating point number in assembly without library function i have try this but it it did not work for large numbers and i don't know this is correct way or not. code: global ...
user avatar
0votes
0answers
302views

MIPS assembly language programming

Hello I am currently learning MIPS assembly language programming. I am trying to print the answer truncated to only one decimal place. For example 127.0 instead of 127.000000 but it is still printing ...
user avatar
0votes
0answers
93views

nasm x86 a way to calculate e^x

I wrote a code that works for calculating e^x: (where x is a float) mov ebx, x fld dword [ebx] fldl2e fmulp f2xm1 fld1 faddp it uses f2xm1 which calculates 2^st0 but st0 ...
user avatar
0votes
0answers
363views

How can I perform a floating point multiplication in assembly without using mul

I'm trying to perform a floating point number multiplication in assembly code but without using a mul instruction. Based on the concept of multiplication, A*B is A added B number of times but I don't ...
user avatar
  • 1
0votes
0answers
50views

finding surface area of hexgonal prism in assembly language

I am trying to find the surface area using this equation. A = 6*a*h+3*sqrt(3)*a^2 I do not fully understand how co-processor instructions actually work. Here is currently by subprogram enter ...
user avatar
0votes
1answer
79views

How do I convert an integer, stored in a variable, into a floating point, and store it in a different variable (assembly)?

I'm working on converting a decimal to a binary digit in NASM. I've got the integer 234 stored in a variable, let's call it dcml, and I want to convert to .234. What do I have to do? I'm very new to ...
user avatar
0votes
0answers
120views

get exponent of float by assembly instruction from c on Intel Core i5/7

I'm reading a book bottom up and it have instruction to get exponent of float on c compiled via GCC: asm ("getf.exp %0=%1" : "=r"(exp) : "f"(d)); saying it works on Itanium. On my Core i7 GCC ...
user avatar
  • 646
0votes
0answers
94views

masm pass floating point to function

I'm trying to draw a triangle on my screen, it works fine with calling winapi Polygon function (https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-polygon) .data xy POINT <350,...
user avatar
  • 3
0votes
0answers
420views

MIPS program won't print out correct floating point numbers

I'm doing a homework assignment where I have to prompt the user to enter a certain amount of floating point numbers, store them in an array and print out the first number that contains duplicates. ...
user avatar
0votes
0answers
66views

MIPS MARS: Weird bug with floating points

I'm getting a weird bug when I try to set a float register to a float in a label. I'm basically trying to calculate the average of the sorted array I created that has 5 values. I add the five values ...
user avatar
0votes
0answers
559views

How do you manipulate a REAL8 value in x86 Assembly to store to a buffer? (Including Irvine32)

I need to write a REAL8 value to a file in x86 assembly (I have access to Irvine32 routines.) To do this, I need to place the value in a buffer so that it represents the correct decimal number. I've ...
user avatar
0votes
1answer
640views

Printfing a FPU register value

I want to somehow get the value from FPU register and printf it. I've got this code: #include <stdio.h> void change(); void single_precision(); int main() { float a = 3.14; printf("%f",...
user avatar
0votes
1answer
2kviews

Arm Assembly Floating Point

Hi I was wondering if anyone here could point me in the direction of solving this problem. Write and run an ARM VFP assembly program to calculate the volume of a sphere: 4(pi*r^3)/3 if r = 25.5. ...
user avatar
0votes
0answers
251views

Segmentation Fault after float division in 64bit NASM

I am having trouble trying to get a simple miles per gallon program working that inputs floats, divides them, and prints the result. I have not yet used floats in NASM, so I'm not sure if it isn't ...
user avatar
0votes
0answers
477views

Reset variable assembly

How do I reset a Real4 variable back to it's original state? I have Value Real4 ? in my data section and I performed an FADD operation and stored the result like so FST Value. I want to use Value ...
user avatar
0votes
0answers
170views

NASM x87 Floating Point Arithmetic Evaluates To 0

I'm new too NASM assembly and I don't know why my assembly code returns 0. Could anyone offer assistance or advice? The code simulates dot product based on the C function: double dot(long int n, ...
user avatar
0votes
0answers
2kviews

Converting float to binary in MIPS

I'm writing a code for an assignment and I need to convert a decimal number to its IEEE754 representation. For example: input "8.855" and output "0 10000010 00011011010111000010100". I store the ...
user avatar
0votes
0answers
743views

Moving Immediate values to Floating Point Registers and performance issues

I am trying to convert an ARM assembly code to use the Floating Point registers instead of ARM registers (due to performance issues I want to avoid push and pop to save the state of current registers.)...
user avatar

15 30 50 per page