I want make simple assembly code for some thing like this a^6+6a^2+2a and range of a is between -3 to 3. I tried but it is not working properly. As this is my first assembly program that I am going to try, I want some help with it.
I found this example online but i dont want this kind of complicated stuff. I just want to start of with simple programing by using function like call .mul, add, sub thatz all.
Code:
1 ; function quadratic
2 ; finds solutions to the quadratic equation:
3 ; a*x^2 + b*x + c = 0
4 ; C prototype:
5 ; int quadratic( double a, double b, double c,
6 ; double * root1, double *root2 )
7 ; Parameters:
8 ; a, b, c - coefficients of powers of quadratic equation (see above)
9 ; root1 - pointer to double to store first root in
10 ; root2 - pointer to double to store second root in
11 ; Return value:
12 ; returns 1 if real roots found, else 0
13
14 %define a qword [ebp+8]
15 %define b qword [ebp+16]
16 %define c qword [ebp+24]
17 %define root1 dword [ebp+32]
18 %define root2 dword [ebp+36]
19 %define disc qword [ebp-8]
132 CHAPTER 6. FLOATING POINT
20 %define one_over_2a qword [ebp-16]
21
22 segment .data
23 MinusFour dw -4
24
25 segment .text
26 global _quadratic
27 _quadratic:
28 push ebp
29 mov ebp, esp
30 sub esp, 16 ; allocate 2 doubles (disc & one_over_2a)
31 push ebx ; must save original ebx
32
33 fild word [MinusFour]; stack -4
34 fld a ; stack: a, -4
35 fld c ; stack: c, a, -4
36 fmulp st1 ; stack: a*c, -4
37 fmulp st1 ; stack: -4*a*c
38 fld b
39 fld b ; stack: b, b, -4*a*c
40 fmulp st1 ; stack: b*b, -4*a*c
41 faddp st1 ; stack: b*b - 4*a*c
42 ftst ; test with 0
43 fstsw ax
44 sahf
45 jb no_real_solutions ; if disc < 0, no real solutions
46 fsqrt ; stack: sqrt(b*b - 4*a*c)
47 fstp disc ; store and pop stack
48 fld1 ; stack: 1.0
49 fld a ; stack: a, 1.0
50 fscale ; stack: a * 2^(1.0) = 2*a, 1
51 fdivp st1 ; stack: 1/(2*a)
52 fst one_over_2a ; stack: 1/(2*a)
53 fld b ; stack: b, 1/(2*a)
54 fld disc ; stack: disc, b, 1/(2*a)
55 fsubrp st1 ; stack: disc - b, 1/(2*a)
56 fmulp st1 ; stack: (-b + disc)/(2*a)
57 mov ebx, root1
58 fstp qword [ebx] ; store in *root1
59 fld b ; stack: b
60 fld disc ; stack: disc, b
61 fchs ; stack: -disc, b
6.3. THE NUMERIC COPROCESSOR 133
62 fsubrp st1 ; stack: -disc - b
63 fmul one_over_2a ; stack: (-b - disc)/(2*a)
64 mov ebx, root2
65 fstp qword [ebx] ; store in *root2
66 mov eax, 1 ; return value is 1
67 jmp short quit
68
69 no_real_solutions:
70 mov eax, 0 ; return value is 0
71
72 quit:
73 pop ebx
74 mov esp, ebp
75 pop ebp
76 ret
I am currently looking into an os on developed on an x86 platformwhich contains certain assembly code written in .s files(NASM- compatible ) instead of using C I was wondering why C could not be used to do low level stuff instead? Do anyone have any idea or could enligthen me?Appreciate any help... (0 Replies)
Hey guys, well I'm extremely knew to Unix so any help advice is very appreciated.
What I am trying to do is assemble a source code (Programming from the Ground Up: Chapter 3: Your First Programs)
The source code named "FINDING A MAXIMUM VALUE" is the code I am trying to link and run, but I... (1 Reply)
Can someone explain how to compile assembly language code. I made my first assembly language code, but don't know how to run it. I know i can debug with gdb, but is there any way to just compile it and get the answer like in C and java compilers. (3 Replies)
When i run this with gcc filename.s -o filename. It is giving fatal error: Unknown opcode at define registers.
Anyhelp will be appreciated
.section ".data"
prompt: .asciz "\nThis program prints the Fibonacci sequence"
prompt2: .asciz "\nEnter a limit on the largest number to be displayed:"... (2 Replies)
Hi guys,
Assembly language is a low level language designed in 1950's, both system and application programs were written in assembly at that time. There is no question of assembly being very effecient compared to the other high level languages. But it is very cumbersome to write programs in... (9 Replies)
Hi eneryone,
Im trying to learn about assemply 8085 in order to make a project i have.
First of all which emulator to use? I work in linux and I currently istalled GNUSim8085.
Also, maybe somewhere I can find some simple examples?
The project is about making an array saved in specific... (8 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am having a hard time with this assignement i cant get the pfib value to print out the fib sequence.
... (1 Reply)
Hi everybody
I'm working on a list of registers(flip-flops to be exact), now i need to extract some value from this list and use them as arguments to pass them to some assembly code
for example i have:
118 chain79 MASTER (FF-LE) FFFF 1975829 /TCK F FD1TQHVTT1 ... (1 Reply)
As the title suggests, I want to better understand the following assembly code:
section .text
global main ; must be declared for linker (gcc)
main: ; tell linker entry point
mov edx, len ; message length
mov ecx, msg ; message to write... (2 Replies)
Discussion started by: Azrael
2 Replies
LEARN ABOUT DEBIAN
macpack
macpack(Mono 1.0) macpack(Mono 1.0)
NAME
macpack - Macintosh OS X Packager for managed gui assemblies
SYNOPSIS
macpack [options] assembly
DESCRIPTION
macpack is a tool used to package managed assemblies (like System.Windows.Forms or Cocoa#) that require gui availability for deployment on
Mac OS X.
macpack will prepare a OS X compatible bundle from the provided assembly and resources. The bundle will include the specified assembly as
well as any of the provided resources (specified with the -resource: switch).
Developers can specify the kind of application to produce using the -mode: argument. This controls how the environment in the Mono class
libraries is setup.
OPTIONS -a assembly
This option tells macpack where the managed assembly that you want to bundle resides. This option is also used to point to the shell
script to launch in the case of a X11/Gtk# application.
This is the same as just passing the assembly as an argument.
-m [winforms,x11,console,cocoa] or -mode:[winforms,x11,console,cocoa]
A value indicating the kind of application: WinForms is a Winforms application running on Quartz; X11 is an application that requires the
X11 server to run; console is a non-graphical application; cocoa is an application based on Cocoa#
-n NAME or -appname:NAME
This option specifies the application name of the emitted bundle. This is what you will see in Finder.
-o DIRECTORY or -output:DIRECTORY
This option specifies the path to output the generated Application.
-r RESOURCE or -resource:RESOURCE
This option can be specified multiple times. It will place a copy of each resource into the bundles resources directory. Alternatively,
you can use a comma separated list of resources.
AUTHOR
Geoff Norton
WEB SITE
Visit: http://www.mono-project.com for details
macpack(Mono 1.0)