Free2Code
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
assembler assignment
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:
  1. #include <iostream.h>
  2. #include <iomanip.h>
  3. // macros
  4. #define HEX8 setw(8) << setfill('0') << hex
  5. #define NL cout << endl
  6. #define REAL15 hex << setprecision(15)
  7. // Variables globales
  8. union huitoctets
  9. {
  10. unsigned int ival[2];
  11. double dval;
  12. };
  13. huitoctets a, b, c;
  14. // Prototype de fonction
  15. void display (char *str);
  16. int Add (huitoctets & ma, huitoctets & mb, huitoctets & result);
  17. void main (void)
  18. {
  19.     int ret;
  20.     //a.ival[1] = 0x35EE0674;
  21.     a.ival[1] = 0x701FF674;
  22.     a.ival[0] = 0x567ACDCF;
  23.     //b.ival[1] = 0x35AEFBBB;
  24.     b.ival[1] = 0xF01FF67B;
  25.     b.ival[0] = 0xDA6FDF56;
  26.     // Visualisation des donn&Atilde;ƒ&Acirc;&copy;es sous forme R&Atilde;ƒ&iuml;&iquest;&frac12;EL et IEEE64
  27.     NL;
  28.     cout << "Valeur de a : ";
  29.     cout << setprecision(15) << a.dval ;
  30.     NL; NL;
  31.     cout << HEX8 << a.ival[1] << " " << HEX8 << a.ival[0];
  32.     NL; NL;
  33.     cout << "Valeur de b : ";
  34.     cout << setprecision(15) << b.dval ;
  35.     NL; NL;
  36.     cout << HEX8 << b.ival[1] << " " << HEX8 << b.ival[0] ;
  37.     NL; NL;
  38.     // addition en IEEE
  39.     c.dval = a.dval + b.dval;
  40.     display ("a + b");
  41.     // R&Atilde;ƒ&Acirc;&copy;sultat avec l'assembleur
  42.     ret = Add (a, b, c);
  43.     display ("c");
  44.     // Mettre ici tous les autres tests
  45. };
  46. void display (char *str)
  47. {
  48.     NL; NL;
  49.     cout << "Valeur de " << str << " :  ";
  50.     cout << setprecision(15) << c.dval ;
  51.     NL; NL;
  52.     cout << HEX8 << c.ival[1] << " " << HEX8 << c.ival[0] ;
  53.     NL; NL;
  54. }
  55. int Add (huitoctets & ma, huitoctets & mb, huitoctets & result)
  56. {
  57.     int ret=0;
  58.     __asm
  59.     {
  60.         //--- votre code ---
  61.     }
  62. return ret;
  63. }


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
 
  Reply to this ·  Post link ·  Top
Subject: Re: assembler assignment  ·  Posted: 2004-11-30, 08:59am
Rank: Unregistered
tricheuuuuur de luniversité laval!!!
 
  Reply to this ·  Post link ·  Top
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
 
  Reply to this ·  Post link ·  Top
Subject: Re: assembler assignment  ·  Posted: 2004-12-05, 02:09pm
Rank: Unregistered
Vive Bui Minh Duc
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

Penguino AVR

Want to learn about robotics or microcontrollers?
Check out the Penguino AVR from our friends at
Icy Labs