Help with sort 
Author Message
 Help with sort

Someone please help me.

I writen a vax assembly language program that reads 12 integers, that the
user enters, to an array.
I then need to sort the array and then print the sorted array. I have been
trying to do it all week long
Is there a certain technique or routine to code an exchange ( bubble ) sort
in assembly.
If anyone can help me I be forever gratefull.

MBaltoda



Mon, 06 Sep 1999 03:00:00 GMT  
 Help with sort


Quote:
>Someone please help me.
>I writen a vax assembly language program that reads 12 integers, that the
            ===
>user enters, to an array.
>I then need to sort the array and then print the sorted array. I have been
>trying to do it all week long
>Is there a certain technique or routine to code an exchange ( bubble ) sort
>in assembly.
>If anyone can help me I be forever gratefull.
>MBaltoda


VAX assembly --> comp.lang.asm370 ?!?!?

Michel Castelein,
MVS (OS/390) System Engineer & Education Consultant
---------------------------------------------------

Home page: http://www.*-*-*.com/ ~pub00543/
company:   JEEVES CONSULTING N.V.
           Mechelses{*filter*}weg 277
           B - 1800 Vilvoorde (Belgium)
           phone +32-2-2516650 / fax +32-2-2525755



Mon, 06 Sep 1999 03:00:00 GMT  
 Help with sort


Quote:

> Someone please help me.

> I writen a vax assembly language program that reads 12 integers, that the
> user enters, to an array.
> I then need to sort the array and then print the sorted array. I have been
> trying to do it all week long
> Is there a certain technique or routine to code an exchange ( bubble ) sort
> in assembly.
> If anyone can help me I be forever gratefull.

> MBaltoda


Since this is the asm370 newsgroup, I'll give an S/370 example which
you'll have to translate back to VAX assembler:

SORT     CSECT ,             a simple bubble sort routine
***************************************************************
*   On entry, reg 1 must point to a 2-word parameter list:    *
*        first word    =    address of array to be sorted     *
*        second word   =    number of elements in array       *
*   Called via:             BALR  14,15                       *
*   Register usage:                                           *
*        Reg   01           pointer to parmlist               *
*        Reg   03           pointer to array                  *
*        Reg   04           branch counter                    *
*        Reg   15           routine base register             *
*   Other registers not used                                  *
*   Routine input:          Unsorted array                    *
*   Routine output:         Sorted array                      *
*   Exceptional conditions: None                              *
***************************************************************      
         SAVE  (14,12)           save caller's regs
         USING *,15              establish addressability
SORT01   EQU   *
         MVI   SORTFLAG,0        turn off sort flag
         LM    3,4,0(1)          load array pointer and ...
         BCTR  4,0               ... element count minus 1
         USING ARRAYDS,3         estab. addressibility
SORTLOOP EQU   *
         CLC   ARRAY1,ARRAY2     compare adjacent elements
         BNH   SORTNEXT          first element is LE second; OK
         XC    ARRAY1,ARRAY2     swap ...
         XC    ARRAY2,ARRAY1     ... in ...
         XC    ARRAY1,ARRAY2     ... ... place
         MVI   SORTFLAG,RESORT   flag another pass needed
SORTNEXT EQU   *
         LA    3,ARRAY$(,3)      point to next element
         BCT   4,SORTLOOP        continue thru array
         CLI   SORTFLAG,RESORT   any elements swapped?
         BE    SORT01            ... yes, do it all again
         DROP  3                 release arrayds DSECT
SORTDONE EQU   *
         RETURN (14,12),RC=0     restore regs and rtn to caller
*
ARRAYDS  DSECT ,                 structure of array
ARRAY1   DS    F                 first element
ARRAY2   DS    F                 next element
ARRAY$   EQU   *-ARRAY2          size of an element
*
SORT     CSECT ,                 continue CSECT
SORTFLAG DS    X                 sort flag
RESORT   EQU   255               indicates not finished
         END   SORT              end of routine

      -jc-



Mon, 06 Sep 1999 03:00:00 GMT  
 Help with sort


Quote:


>>Someone please help me.

>>I writen a vax assembly language program that reads 12 integers, that the
>            ===
>>user enters, to an array.
>>I then need to sort the array and then print the sorted array. I have been
>>trying to do it all week long
>>Is there a certain technique or routine to code an exchange ( bubble ) sort
>>in assembly.
>>If anyone can help me I be forever gratefull.

>>MBaltoda

>VAX assembly --> comp.lang.asm370 ?!?!?

It would seem obvious, that the original poster is not 'playing with a full DEC'

OTOH, the 'obvious' way to do asm370 sorting on a VAX is _clearly_ described,
see:   'man SYNCSORT'



Mon, 06 Sep 1999 03:00:00 GMT  
 Help with sort


Quote:

>> Someone please help me.

>> I writen a vax assembly language program that reads 12 integers, that the
>> user enters, to an array.
>> I then need to sort the array and then print the sorted array. I have been
>> trying to do it all week long
>> Is there a certain technique or routine to code an exchange ( bubble ) sort
>> in assembly.
>> If anyone can help me I be forever gratefull.

>> MBaltoda


 Use the stack to exchange integers in registers:

 PUSHR   R1
 PUSHR   R2
 POP     R1
 POP     R2



Thu, 09 Sep 1999 03:00:00 GMT  
 Help with sort


Quote:



>>>Someone please help me.

>>>I writen a vax assembly language program that reads 12 integers, that the
>>            ===
>>>user enters, to an array.
>>>I then need to sort the array and then print the sorted array. I have been
>>>trying to do it all week long
>>>Is there a certain technique or routine to code an exchange ( bubble ) sort
>>>in assembly.
>>>If anyone can help me I be forever gratefull.

>>>MBaltoda


 Use the stack to exchange registers:

 PUSHR    R1
 MOV      R2,R1
 POPR     R2



Thu, 09 Sep 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Please Help with sort pr

2. Help with sorting CLF email in OE

3. Need help with sort

4. Help with sorting list of numbers

5. Help: factored sorting

6. Help with sort

7. Help with sorting program

8. NEED HELP WITH - SORT TABLE PROGRAM

9. NEED HELP FOR SORTING TABLES

10. Help w/SORT please.

11. Help on SORT sequential file in Cobol

 

 
Powered by phpBB® Forum Software