home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / sysv386 / 13401 < prev    next >
Encoding:
Text File  |  1992-08-21  |  5.4 KB  |  247 lines

  1. Newsgroups: comp.unix.sysv386
  2. Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!Chico.Chemie.FU-Berlin.DE!melchers
  3. From: melchers@Chico.Chemie.FU-Berlin.DE (Bernd Melchers)
  4. Subject: same assembler on all 386er Unix?
  5. Message-ID: <IL05IIL@math.fu-berlin.de>
  6. Sender: news@math.fu-berlin.de (Math Department)
  7. Organization: Free University of Berlin, Germany
  8. Date: Fri, 21 Aug 1992 12:17:08 GMT
  9. Lines: 236
  10.  
  11. Because I want to speed up some routines (and because I like 
  12. assembler, sorry), I want to know, if there are similar assembler
  13. on some or all 80386/80486-Unixsystems. Does they all use the same
  14. syntax and the same memory model, are they compatible among each
  15. other...
  16. Here is a simple C-Programm, compiled with 'cc -S file.c' on a
  17. DELL-Unix SVR4. I would like it, if you send me the same
  18. Programm assembled with your Unix-80386-assembler.
  19. ---------------program begin-------------------
  20.  
  21. void *Mips2Intel(void *from, void *to, int size, unsigned long num)
  22. /*
  23.     reverses the order of bytes in an array of datatypes
  24.     of size 'size'.
  25.     on different machines, e.g.:
  26.     double intel: 1 2 3 4 5 6 7 8          or 8 7 6 5 4 3 2 1 
  27.                   convert to                  convert to
  28.     double mips:  8 7 6 5 4 3 2 1          or 1 2 3 4 5 6 7 8
  29.     'num' variables of size 'size' are converted.
  30.     'SIZE' SHOULD BE EVEN. 'FROM' AND 'TO' COULD NOT POINT TO
  31.     THE SAME LOCATION! The pointer 'to' is returned.
  32. */
  33. {
  34.     char *source, *dest;
  35.     unsigned long n;
  36.     int m, size2;
  37.  
  38.     size2 = size << 1;
  39.     source = (char *)from;
  40.     dest = ((char *)to)-size-1;
  41.     for (n=0; n<num; n++)
  42.         {
  43.         dest += size2;
  44.         for (m=0; m<size; m++)
  45.             *dest-- = *source++;
  46.         }
  47.     return to;
  48. }/*Mips2Intel*/
  49.  
  50. void *Mips2Intel2(void *array, int size, unsigned long num)
  51. /*
  52.     reverses the order of bytes in 'array' of datatypes
  53.     of size 'size'.
  54.     double intel: 1 2 3 4 5 6 7 8          or 8 7 6 5 4 3 2 1 
  55.                   convert to                  convert to
  56.     double mips:  8 7 6 5 4 3 2 1          or 1 2 3 4 5 6 7 8
  57.     'num' variables of size 'size' are converted.
  58.     'size' should be even. 
  59.     The pointer 'array' is returned.
  60. */
  61. {
  62.     char *left, *rigth;
  63.     char tmp;
  64.     unsigned long n;
  65.     int m, loops, size15;;
  66.  
  67.     loops = size >> 1; /* size/2 */
  68.     size15 = size + loops;
  69.     left = (char *)array;
  70.     rigth = ((char *)array)+size-1;
  71.     for (n=0; n<num; n++)
  72.         {
  73.         /* reverse order of next element */
  74.         for (m=0; m<loops; m++)
  75.             {
  76.             tmp = *left;
  77.             *left++ = *rigth;
  78.             *rigth-- = tmp;
  79.             }
  80.         left += loops;
  81.         rigth += size15;
  82.         }
  83.     return array;
  84. }/*Mips2Intel2*/
  85. ------------------------end programm--------------------
  86. ----------------result from cc -S prgram.c : -------------
  87.  
  88.     .file    "le2be.c"
  89.     .version    "01.01"
  90.     .text
  91.     .globl    Mips2Intel
  92.     .align    4
  93. Mips2Intel:
  94.     jmp    .L12
  95. .L11:
  96.     movl    16(%ebp),%ebx
  97.     movl    %ebx,%eax
  98.     leal    (,%eax,2),%eax
  99.     movl    %eax,-12(%ebp)
  100.     movl    8(%ebp),%eax
  101.     movl    %eax,-4(%ebp)
  102.     movl    12(%ebp),%eax
  103.     subl    %ebx,%eax
  104.     decl    %eax
  105.     movl    %eax,%esi
  106.     movl    $0,-8(%ebp)
  107. /LOOP    BEG
  108.     jmp    .L5
  109. /LOOP    HDR
  110. .L2:
  111.     addl    -12(%ebp),%esi
  112.     xorl    %edi,%edi
  113. /LOOP    BEG
  114.     jmp    .L9
  115. /LOOP    HDR
  116. .L6:
  117.     movl    -4(%ebp),%eax
  118.     incl    -4(%ebp)
  119.     movb    (%eax),%al
  120.     movb    %al,(%esi)
  121.     decl    %esi
  122.     incl    %edi
  123. .L9:
  124. /LOOP    COND
  125.     cmpl    %ebx,%edi
  126.     jl    .L6
  127. /LOOP    END
  128.     incl    -8(%ebp)
  129. .L5:
  130. /LOOP    COND
  131.     movl    20(%ebp),%eax
  132.     cmpl    %eax,-8(%ebp)
  133.     jnae    .L2
  134. /LOOP    END
  135.     movl    12(%ebp),%eax
  136.     jmp    .L10
  137. /REGAL    0    AUTO    -12(%ebp)    4
  138. /REGAL    0    AUTO    -8(%ebp)    4
  139. /REGAL    0    AUTO    -4(%ebp)    4
  140. /REGAL    0    PARAM    20(%ebp)    4
  141. /REGAL    0    PARAM    12(%ebp)    4
  142. /REGAL    0    PARAM    8(%ebp)    4
  143. .L10:
  144.     popl    %ebx
  145.     popl    %esi
  146.     popl    %edi
  147.     leave
  148.     ret/1
  149. .L12:
  150.     pushl    %ebp
  151.     movl    %esp,%ebp
  152.     subl    $12,%esp
  153.     pushl    %edi
  154.     pushl    %esi
  155.     pushl    %ebx
  156.     jmp    .L11
  157.     .type    Mips2Intel,@function
  158.     .size    Mips2Intel,.-Mips2Intel
  159.     .globl    Mips2Intel2
  160.     .align    4
  161. Mips2Intel2:
  162.     jmp    .L24
  163. .L23:
  164.     movl    12(%ebp),%eax
  165.     sarl    $1,%eax
  166.     movl    %eax,-12(%ebp)
  167.     movl    -12(%ebp),%eax
  168.     addl    12(%ebp),%eax
  169.     movl    %eax,-16(%ebp)
  170.     movl    8(%ebp),%edi
  171.     movl    8(%ebp),%eax
  172.     movl    12(%ebp),%edx
  173.     leal    -1(%eax,%edx),%eax
  174.     movl    %eax,%esi
  175.     movl    $0,-8(%ebp)
  176. /LOOP    BEG
  177.     jmp    .L17
  178. /LOOP    HDR
  179. .L14:
  180.     xorl    %ebx,%ebx
  181. /LOOP    BEG
  182.     jmp    .L21
  183. /LOOP    HDR
  184. .L18:
  185.     movb    (%edi),%al
  186.     movb    %al,-1(%ebp)
  187.     movb    (%esi),%al
  188.     movb    %al,(%edi)
  189.     incl    %edi
  190.     movb    -1(%ebp),%al
  191.     movb    %al,(%esi)
  192.     decl    %esi
  193.     incl    %ebx
  194. .L21:
  195. /LOOP    COND
  196.     cmpl    -12(%ebp),%ebx
  197.     jl    .L18
  198. /LOOP    END
  199.     addl    -12(%ebp),%edi
  200.     addl    -16(%ebp),%esi
  201.     incl    -8(%ebp)
  202. .L17:
  203. /LOOP    COND
  204.     movl    16(%ebp),%eax
  205.     cmpl    %eax,-8(%ebp)
  206.     jnae    .L14
  207. /LOOP    END
  208.     movl    8(%ebp),%eax
  209.     jmp    .L22
  210. /REGAL    0    AUTO    -16(%ebp)    4
  211. /REGAL    0    AUTO    -12(%ebp)    4
  212. /REGAL    0    AUTO    -8(%ebp)    4
  213. /REGAL    0    AUTO    -1(%ebp)    1
  214. /REGAL    0    PARAM    16(%ebp)    4
  215. /REGAL    0    PARAM    12(%ebp)    4
  216. /REGAL    0    PARAM    8(%ebp)    4
  217. .L22:
  218.     popl    %ebx
  219.     popl    %esi
  220.     popl    %edi
  221.     leave
  222.     ret/1
  223. .L24:
  224.     pushl    %ebp
  225.     movl    %esp,%ebp
  226.     subl    $16,%esp
  227.     pushl    %edi
  228.     pushl    %esi
  229.     pushl    %ebx
  230.     jmp    .L23
  231.     .type    Mips2Intel2,@function
  232.     .size    Mips2Intel2,.-Mips2Intel2
  233.     .ident    "acomp: (SCDE) 5.0  09/24/90"
  234.     ----------------------------------------------------
  235. (I don't tested the c-program!)
  236. Please email me your results.
  237. Bernd
  238. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  239. Bernd Melchers                   | melchers@chico.chemie.fu-berlin.de
  240. Freie Universitaet Berlin        | Lieblingsessen: Pizza, aber nur
  241. Institut fuer Kristallographie   |              selbstgemachte...
  242. Takustr. 6                       |              und ohne Tierkadaver
  243. D 1000 Berlin 33                 |
  244. Earth                            |
  245. Tel.: 0049-30-8383612            |
  246. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  247.