home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.sysv386
- Path: sparky!uunet!mcsun!Germany.EU.net!news.netmbx.de!zrz.tu-berlin.de!math.fu-berlin.de!Chico.Chemie.FU-Berlin.DE!melchers
- From: melchers@Chico.Chemie.FU-Berlin.DE (Bernd Melchers)
- Subject: same assembler on all 386er Unix?
- Message-ID: <IL05IIL@math.fu-berlin.de>
- Sender: news@math.fu-berlin.de (Math Department)
- Organization: Free University of Berlin, Germany
- Date: Fri, 21 Aug 1992 12:17:08 GMT
- Lines: 236
-
- Because I want to speed up some routines (and because I like
- assembler, sorry), I want to know, if there are similar assembler
- on some or all 80386/80486-Unixsystems. Does they all use the same
- syntax and the same memory model, are they compatible among each
- other...
- Here is a simple C-Programm, compiled with 'cc -S file.c' on a
- DELL-Unix SVR4. I would like it, if you send me the same
- Programm assembled with your Unix-80386-assembler.
- ---------------program begin-------------------
-
- void *Mips2Intel(void *from, void *to, int size, unsigned long num)
- /*
- reverses the order of bytes in an array of datatypes
- of size 'size'.
- on different machines, e.g.:
- double intel: 1 2 3 4 5 6 7 8 or 8 7 6 5 4 3 2 1
- convert to convert to
- double mips: 8 7 6 5 4 3 2 1 or 1 2 3 4 5 6 7 8
- 'num' variables of size 'size' are converted.
- 'SIZE' SHOULD BE EVEN. 'FROM' AND 'TO' COULD NOT POINT TO
- THE SAME LOCATION! The pointer 'to' is returned.
- */
- {
- char *source, *dest;
- unsigned long n;
- int m, size2;
-
- size2 = size << 1;
- source = (char *)from;
- dest = ((char *)to)-size-1;
- for (n=0; n<num; n++)
- {
- dest += size2;
- for (m=0; m<size; m++)
- *dest-- = *source++;
- }
- return to;
- }/*Mips2Intel*/
-
- void *Mips2Intel2(void *array, int size, unsigned long num)
- /*
- reverses the order of bytes in 'array' of datatypes
- of size 'size'.
- double intel: 1 2 3 4 5 6 7 8 or 8 7 6 5 4 3 2 1
- convert to convert to
- double mips: 8 7 6 5 4 3 2 1 or 1 2 3 4 5 6 7 8
- 'num' variables of size 'size' are converted.
- 'size' should be even.
- The pointer 'array' is returned.
- */
- {
- char *left, *rigth;
- char tmp;
- unsigned long n;
- int m, loops, size15;;
-
- loops = size >> 1; /* size/2 */
- size15 = size + loops;
- left = (char *)array;
- rigth = ((char *)array)+size-1;
- for (n=0; n<num; n++)
- {
- /* reverse order of next element */
- for (m=0; m<loops; m++)
- {
- tmp = *left;
- *left++ = *rigth;
- *rigth-- = tmp;
- }
- left += loops;
- rigth += size15;
- }
- return array;
- }/*Mips2Intel2*/
- ------------------------end programm--------------------
- ----------------result from cc -S prgram.c : -------------
-
- .file "le2be.c"
- .version "01.01"
- .text
- .globl Mips2Intel
- .align 4
- Mips2Intel:
- jmp .L12
- .L11:
- movl 16(%ebp),%ebx
- movl %ebx,%eax
- leal (,%eax,2),%eax
- movl %eax,-12(%ebp)
- movl 8(%ebp),%eax
- movl %eax,-4(%ebp)
- movl 12(%ebp),%eax
- subl %ebx,%eax
- decl %eax
- movl %eax,%esi
- movl $0,-8(%ebp)
- /LOOP BEG
- jmp .L5
- /LOOP HDR
- .L2:
- addl -12(%ebp),%esi
- xorl %edi,%edi
- /LOOP BEG
- jmp .L9
- /LOOP HDR
- .L6:
- movl -4(%ebp),%eax
- incl -4(%ebp)
- movb (%eax),%al
- movb %al,(%esi)
- decl %esi
- incl %edi
- .L9:
- /LOOP COND
- cmpl %ebx,%edi
- jl .L6
- /LOOP END
- incl -8(%ebp)
- .L5:
- /LOOP COND
- movl 20(%ebp),%eax
- cmpl %eax,-8(%ebp)
- jnae .L2
- /LOOP END
- movl 12(%ebp),%eax
- jmp .L10
- /REGAL 0 AUTO -12(%ebp) 4
- /REGAL 0 AUTO -8(%ebp) 4
- /REGAL 0 AUTO -4(%ebp) 4
- /REGAL 0 PARAM 20(%ebp) 4
- /REGAL 0 PARAM 12(%ebp) 4
- /REGAL 0 PARAM 8(%ebp) 4
- .L10:
- popl %ebx
- popl %esi
- popl %edi
- leave
- ret/1
- .L12:
- pushl %ebp
- movl %esp,%ebp
- subl $12,%esp
- pushl %edi
- pushl %esi
- pushl %ebx
- jmp .L11
- .type Mips2Intel,@function
- .size Mips2Intel,.-Mips2Intel
- .globl Mips2Intel2
- .align 4
- Mips2Intel2:
- jmp .L24
- .L23:
- movl 12(%ebp),%eax
- sarl $1,%eax
- movl %eax,-12(%ebp)
- movl -12(%ebp),%eax
- addl 12(%ebp),%eax
- movl %eax,-16(%ebp)
- movl 8(%ebp),%edi
- movl 8(%ebp),%eax
- movl 12(%ebp),%edx
- leal -1(%eax,%edx),%eax
- movl %eax,%esi
- movl $0,-8(%ebp)
- /LOOP BEG
- jmp .L17
- /LOOP HDR
- .L14:
- xorl %ebx,%ebx
- /LOOP BEG
- jmp .L21
- /LOOP HDR
- .L18:
- movb (%edi),%al
- movb %al,-1(%ebp)
- movb (%esi),%al
- movb %al,(%edi)
- incl %edi
- movb -1(%ebp),%al
- movb %al,(%esi)
- decl %esi
- incl %ebx
- .L21:
- /LOOP COND
- cmpl -12(%ebp),%ebx
- jl .L18
- /LOOP END
- addl -12(%ebp),%edi
- addl -16(%ebp),%esi
- incl -8(%ebp)
- .L17:
- /LOOP COND
- movl 16(%ebp),%eax
- cmpl %eax,-8(%ebp)
- jnae .L14
- /LOOP END
- movl 8(%ebp),%eax
- jmp .L22
- /REGAL 0 AUTO -16(%ebp) 4
- /REGAL 0 AUTO -12(%ebp) 4
- /REGAL 0 AUTO -8(%ebp) 4
- /REGAL 0 AUTO -1(%ebp) 1
- /REGAL 0 PARAM 16(%ebp) 4
- /REGAL 0 PARAM 12(%ebp) 4
- /REGAL 0 PARAM 8(%ebp) 4
- .L22:
- popl %ebx
- popl %esi
- popl %edi
- leave
- ret/1
- .L24:
- pushl %ebp
- movl %esp,%ebp
- subl $16,%esp
- pushl %edi
- pushl %esi
- pushl %ebx
- jmp .L23
- .type Mips2Intel2,@function
- .size Mips2Intel2,.-Mips2Intel2
- .ident "acomp: (SCDE) 5.0 09/24/90"
- ----------------------------------------------------
- (I don't tested the c-program!)
- Please email me your results.
- Bernd
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Bernd Melchers | melchers@chico.chemie.fu-berlin.de
- Freie Universitaet Berlin | Lieblingsessen: Pizza, aber nur
- Institut fuer Kristallographie | selbstgemachte...
- Takustr. 6 | und ohne Tierkadaver
- D 1000 Berlin 33 |
- Earth |
- Tel.: 0049-30-8383612 |
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-