Sponsored Content
Top Forums Programming x86 help value being store passes data type range Post 302520482 by godofdoom999 on Saturday 7th of May 2011 02:05:39 PM
Old 05-07-2011
x86 help value being store passes data type range

Hi im very new to x86 programming and was wonder if there a function or ways to solve my problem. I believe the reason for my inaccurate result are from passing floating point number beyond what a SWORD could hold.
So far I been looking for a function that would allow me to round the floating point number but I cant seem to find any of that info on google. Any help would be appreciated. Thank you.

result from this...
sRoot(4/1) = 2/1
sRoot(9/1) = -13543/4096
sRoot(2/1) = 24023/-14336


Code:
;Find the square root and display the new frac. This uses the babylonian algorithm.

sRoot proc USES ebx, num:SWORD, den:SWORD, num2:SWORD, den2:SWORD
LOCAL dholder:SWORD ;store the past result
LOCAL nholder:SWORD ;store the past result
LOCAL counter:SDWORD

mov counter,0
invoke divFrac, num2,den2,10,1

mov num,cx
mov den,dx
invoke addFrac, 10,1,num,den
mov num,cx
mov den,dx
invoke mulFrac, 1,2,num,den
mov num,cx
mov den,dx

top:
invoke divFrac, num2,den2,num,den
mov nholder,cx
mov dholder,dx
invoke addFrac, num,den,nholder,dholder
mov nholder,cx
mov dholder,dx
invoke mulFrac, 1,2,nholder,dholder
mov num,cx
mov den,dx
inc counter
cmp counter,10
je done
jne top

done:
ret

sRoot endp

;addFrac and mulFrac accept similar value as divFrac

; divides two fractions puts numerator in ecx and denominator in edx
divFrac PROC USES eax ebx, num1:SWORD, den1:SWORD, num2:SWORD, den2:SWORD
LOCAL rNum:SDWORD ;store orignal value
LOCAL rDen:SDWORD
    mov ax,0		;set ax to 0
    mov ax,num1		;move num1 to ax register
    imul ax,den2	;sign multiply den2 to ax
    movsx ecx,ax	;mov ax with sign ext (SWORD) to ecx register
    mov ax,0
    mov ax,num2
    imul ax,den1
    movsx edx,ax
    mov rNum,ecx
    mov rDen,edx
    invoke gcd,rNum,rDen
    ret			;return address

divFrac ENDP

 

9 More Discussions You Might Find Interesting

1. Programming

FILE data type

Hi all, Can anyone tell me a little about the datatype FILE, which represents stream. What does its structure look like, and in which header file is it defined and so on... Ex : FILE *fp ; fp = fopen("filename", "w") ; (6 Replies)
Discussion started by: milhan
6 Replies

2. Programming

data type limitation

I am writing some code to do analysis on the file system (HP-UX 11.11). I am using stat(..) to get file information. My problem is that the file-size may exceed the data types defined in 'sys/stat.h' & 'sys/types.h' respectively. Thus file-sizes in the Giga-byte range are not read correctly.... (2 Replies)
Discussion started by: ALTRUNVRSOFLN
2 Replies

3. Shell Programming and Scripting

How to store Data in a File

I want to read a data from a read command and store it in a file...... Plz send me how I can do that Ex: read val and I want to store this val in a file called temp. (2 Replies)
Discussion started by: krishna_sicsr
2 Replies

4. Shell Programming and Scripting

Perl data type checking

I am using perl 5.8.0. I need to check some values to see it they are floats. Our system does not have Data::Types so I can't use is_float. Is there something else that I can use? The only thing in Data is Dump.pm. I am not allowed to download anything to our system so I have to use what I have.... (3 Replies)
Discussion started by: ajgwin
3 Replies

5. Solaris

Can not type in textbox ( Solaris 10 x86 )

My X86-Solaris 10- server after installed some softwares now has a bug. We can not type anything on the text box of Java applications or CDE such as Add printer or Raid Controller etc.. but i can type on the Command Line Terminal or Star Office applications :eek: I want to ask for a system... (4 Replies)
Discussion started by: tien86
4 Replies

6. Web Development

Data type to use for prices with commas

Hi everybody, I`m very new with PHP and Databases and I having the follow issue with prices data.. The original information is in CSV files. The prices have formatted with commas and dots as follow: 12,300.99 -->(thousands separated by commas) 3,500.25 -->(thousands separated... (10 Replies)
Discussion started by: cgkmal
10 Replies

7. Programming

help with data type sizes

i'm using a C program and running it on a linux server, i got 2 adressess of 2 variables, and 2 addresses of 2 chars, and compared it. and got the size of a int and the size of a char. why is a size of a int (4 bytes) bigger then the size of a char (1 byte)? also if i do &a-&b i get 1, but if i... (30 Replies)
Discussion started by: omega666
30 Replies

8. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

9. Programming

Incompatible data type fpos_t in C

This is from a program I wrote over in 1998 that I am trying to compile on a linux machine: void write_line (FILE *fp, int rec_no, line_rec *arec) { fpos_t woffset; woffset = (rec_no - 1) * sizeof(line_rec); fsetpos(fp,&woffset); fwrite(arec,sizeof(line_rec),1,fp); }On the line... (2 Replies)
Discussion started by: wbport
2 Replies
INTRO(3)						     Library Functions Manual							  INTRO(3)

NAME
intro - introduction to library functions SYNOPSIS
#include <stdio.h> #include <math.h> DESCRIPTION
This section describes functions that may be found in various libraries, other than those functions that directly invoke UNIX system primi- tives, which are described in section 2. Functions are divided into various libraries distinguished by the section number at the top of the page: (3) These functions, together with those of section 2 and those marked (3S), constitute library libc, which is automatically loaded by the C compiler cc(1) and the Fortran compiler f77(1). The link editor ld(1) searches this library under the `-lc' option. Declara- tions for some of these functions may be obtained from include files indicated on the appropriate pages. (3M) These functions constitute the math library, libm. They are automatically loaded as needed by the Fortran compiler f77(1). The link editor searches this library under the `-lm' option. Declarations for these functions may be obtained from the include file <math.h>. (3S) These functions constitute the `standard I/O package', see stdio(3). These functions are in the library libc already mentioned. Declarations for these functions may be obtained from the include file <stdio.h>. (3X) Various specialized libraries have not been given distinctive captions. The files in which these libraries are found are named on the appropriate pages. FILES
/lib/libc.a /lib/libm.a, /usr/lib/libm.a (one or the other) SEE ALSO
stdio(3), nm(1), ld(1), cc(1), f77(1), intro(2) DIAGNOSTICS
Functions in the math library (3M) may return conventional values when the function is undefined for the given arguments or when the value is not representable. In these cases the external variable errno (see intro(2)) is set to the value EDOM or ERANGE. The values of EDOM and ERANGE are defined in the include file <math.h>. ASSEMBLER
In assembly language these functions may be accessed by simulating the C calling sequence. For example, ecvt(3) might be called this way: setd mov $sign,-(sp) mov $decpt,-(sp) mov ndigit,-(sp) movf value,-(sp) jsr pc,_ecvt add $14.,sp INTRO(3)
All times are GMT -4. The time now is 09:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy