The majority of forums are now only available as archives, which means posting/editing is disabled.
The Anything and Everything forum is still open.
Time: 2013-05-20, 11:55pm
Please
login or
register to post a reply.
|
|
| Subject: assembler assignment · Posted: 2004-11-24, 03:20pm |
|
|
|
Rank: Unregistered
|
hey all,
i need to program a function in intel's assembly language that adds to doubles (IEEE64) and displays the result
our prof gave us this sample code that does the work in c++, we can check our answers with the results that his program displays
Code:
#include <iostream.h>
- #include <iomanip.h>
-
- // macros
- #define HEX8 setw(8) << setfill('0') << hex
- #define NL cout << endl
- #define REAL15 hex << setprecision(15)
-
- // Variables globales
- union huitoctets
- {
- unsigned int ival[2];
- double dval;
- };
- huitoctets a, b, c;
-
- // Prototype de fonction
- void display (char *str);
- int Add (huitoctets & ma, huitoctets & mb, huitoctets & result);
-
- void main (void)
- {
- int ret;
-
- //a.ival[1] = 0x35EE0674;
- a.ival[1] = 0x701FF674;
- a.ival[0] = 0x567ACDCF;
-
- //b.ival[1] = 0x35AEFBBB;
- b.ival[1] = 0xF01FF67B;
- b.ival[0] = 0xDA6FDF56;
-
- // Visualisation des données sous forme R�EL et IEEE64
- NL;
- cout << "Valeur de a : ";
- cout << setprecision(15) << a.dval ;
- NL; NL;
- cout << HEX8 << a.ival[1] << " " << HEX8 << a.ival[0];
- NL; NL;
-
-
- cout << "Valeur de b : ";
- cout << setprecision(15) << b.dval ;
- NL; NL;
- cout << HEX8 << b.ival[1] << " " << HEX8 << b.ival[0] ;
- NL; NL;
-
- // addition en IEEE
- c.dval = a.dval + b.dval;
- display ("a + b");
-
- // Résultat avec l'assembleur
- ret = Add (a, b, c);
- display ("c");
-
- // Mettre ici tous les autres tests
-
- };
-
- void display (char *str)
- {
- NL; NL;
- cout << "Valeur de " << str << " : ";
- cout << setprecision(15) << c.dval ;
- NL; NL;
- cout << HEX8 << c.ival[1] << " " << HEX8 << c.ival[0] ;
- NL; NL;
- }
-
- int Add (huitoctets & ma, huitoctets & mb, huitoctets & result)
- {
- int ret=0;
- __asm
- {
- //--- votre code ---
- }
- return ret;
- }
he explained to us that we needed to push all the ?registers? (in french we call them "des régistres" such as EAX, ESP and EBX)
and that we had to pop them back at the end... can someone clear me up maybe?
thanks!
in case, my email is sinstone@gmail.com
|
|
|
| Subject: Re: assembler assignment · Posted: 2004-11-30, 08:59am |
|
|
|
Rank: Unregistered
|
 tricheuuuuur de luniversité laval!!!
|
|
|
| Subject: Re: assembler assignment · Posted: 2004-12-05, 12:06am |
|
|
|
Rank: Unregistered
|
Humm je ne suis pas le seul a etre dans la merde a ce que je vois
|
|
|
| Subject: Re: assembler assignment · Posted: 2004-12-05, 02:09pm |
|
|
|
Rank: Unregistered
|
Vive Bui Minh Duc
|
Pages: 1
Please
login or
register to post a reply.