incdir "include:" include "system.gs" bsr Start ;otevření okna a alokace vseho bsr Generuj bsr vypis bsr utrid bsr vypis konec3 move.l vystup,d1 CALLDOS Close konec2 move.l _DOSBase,a1 CALLEXEC CloseLibrary konec1 rts *** Podprogramy *** utrid ;inicializujeme si ukazatele move.l #ukpp,a0 move.l #pompole,a1 moveq #16-1,d7 utlab1 move.l a1,(a0)+ add.l #200,a1 dbra d7,utlab1 moveq #0,d6 utlab7 ;nulujeme pocty prvku v prihradkach moveq #16-1,d7 move.l #ukpp,a0 utlab8 move.l (a0)+,a1 move.w #0,(a1) dbra d7,utlab8 ;a rozřaďujeme moveq #100-1,d7 ;přes všechny udaje v poli move.l #ukpp,a1 move.l #pole,a0 utlab2 move.w (a0,d7*2),d0 ;hodnotu do d0 move.w d0,d1 ;pro pozdejsi ukladani lsr.w d6,d0 and.w #$000F,d0 ;a v d0 mame jen hodnotu v potrebnem radu move.l (a1,d0*4),a2 ;adresa prihradky add.w #1,(a2) ;budeme pridavat - je jich tedy o 1 vic move.w (a2),d3 ;pocet prvku v teto prihradce move.w d1,(a2,d3.w*2) ;zapisujem d1 dbra d7,utlab2 move.l #ukpp,a0 move.l #pole+200,a2 moveq #16-1,d7 utlab5 move.l (a0)+,a1 move.w (a1)+,d3 ;pocet prvku -> d3 beq utlab9 ;neni tam zadnej - specialni pripad sub.w #1,d3 ;kvuli spravnemu poctu pruchodu cyklem utlab4 move.w (a1)+,-(a2) ;zapiseme do pole dbra d3,utlab4 utlab9 dbra d7,utlab5 addq #4,d6 cmp #16,d6 bne utlab7 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/Radix/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 ukpp dcb.l 16,$0000 pompole dcb.w 100*16,$00