incdir "include:" include "system.gs" bsr Start ;oteverni okna a alokace vseho bsr Generuj bsr vypis move.w #200,-(sp) ;pravy kraj celeho (jedeme po dvou) move.w #2,-(sp) ;levy kraj bsr utrid bsr vypis konec3 move.l vystup,d1 CALLDOS Close konec2 move.l _DOSBase,a1 CALLEXEC CloseLibrary konec1 rts *** Podprogramy *** utrid moveq #0,d7 moveq #0,d6 move.w 4(sp),d6 ;v d6 levy okraj move.w d6,d3 move.w 6(sp),d7 ;v d7 pravy move.w d7,d4 move.l (sp),4(sp) add.l #4,sp cmp.w d6,d7 bls ut5 move.l #pole-2,a0 move.w (a0,d6),d5 ;v d5 pivot - nejlehci je vybrat hned krajniho ut2 cmp.w (a0,d6),d5 bls ut1 ;jedem dokud nenarazime na prvek addq #2,d6 ;vetsi nez pivot bra ut2 ut1 cmp.w (a0,d7),d5 bcc ut3 ;jedem dokud nenarazime na prvek subq #2,d7 ;mensi nebo rovny pivotovi bra ut1 ut3 cmp d6,d7 bcs ut4 ;nemenit jestli d6>d7 move.w (a0,d7),d0 move.w (a0,d6),(a0,d7) move.w d0,(a0,d6) addq #2,d6 ;a posunout indexy subq #2,d7 ;kvuli ukonceni cyklu cmp.w d6,d7 bcc ut2 ;a znova od zacatku ut4 move.w d4,-(sp) move.w d6,-(sp) move.w d7,-(sp) move.w d3,-(sp) bsr utrid bsr utrid ut5 rts vypis move.l #pole,a5 moveq #100-1,d6 vyplab2 moveq #4-1,d7 moveq #0,d0 move.w (a5)+,d0 ;v d0 je cislo move.l #cislo,a1 ;adresa vypisovaneho bufferu swap d0 vyplab1 rol.l #4,d0 add.w #48,d0 cmp.w #58,d0 bcs noch add.w #7,d0 noch move.b d0,(a1)+ clr.w d0 dbf d7,vyplab1 move.l vystup,d1 move.l #cislo,d2 moveq #5,d3 CALLDOS Write dbf d6,vyplab2 move.l vystup,d1 move.l #odrad,d2 move.l #2,d3 CALLDOS Write rts Generuj ;procedura vygeneruje nahodna cisla - 100 wordu moveq #100-1,d7 move.l #pole,a0 move.l #$FFFF,d0 genlab bsr Rnd move.w d1,(a0)+ dbf d7,genlab rts ; D0 - Range (0 - x) ; D1 - Returns Number (Long Word, But Only Grab Word!) Rnd Move.w .seed(pc),d1 ;rnd by Ballfrog Mulu #9377,d1 Add.w #1,d1 ;9439 Move.w d1,.seed ; Store Value For Seed Next Time And.l #$7FFF,d1 ; Make Sure Positive Word Divu d0,d1 Swap d1 ; Make Remainder Low Word Rts .seed dc.w 1 Start move.l (sp)+,a5 ;vybereme navratovou adresu moveq #39,d0 move.l #dosname,a1 CALLEXEC OpenLibrary tst.l d0 beq konec1 move.l d0,_DOSBase move.l #newvystup,d1 move.l #MODE_NEWFILE,d2 CALLDOS Open tst.l d0 beq konec2 move.l d0,vystup jmp (a5) ;vse v poradku - vyskocime ***Data*** dosname dc.b 'dos.library',0 newvystup dc.b 'con:0/0/624/250/Quicksort/close/wait',0 _DOSBase ds.l 1 vystup ds.l 1 cislo dc.b 0,0,0,0,32,0 cnop 0,2 odrad dc.b 10,10 pole dcb.w 100,00