-+-+-+-+-+-+-+-+ START OF PART 71 -+-+-+-+-+-+-+-+ X1$:`09ret X`09.end $ CALL UNPACK [.SOURCE.MACRO]INSERT.MAR;1 324356802 $ create 'f' X`09; X`09; Robert Koeneke X`09; September 1, 1984 X`09; MORIA subroutine X`09; Macro function for : X`09; X`09;`09MAX( MIN( x , y ) - 1 , z ) X`09;`09Arguments in order x, y, z X`09; X`09.title`09MAXMIN`09Retruns the max of a min and number. X`09.ident`09/maxmin/ X`09.psect misc1$code,pic,con,rel,lcl,shr,exe,rd,nowrt,2 X`09.entry`09maxmin,`5EM<> X`09movl`094(ap),r0 X`09movl`098(ap),r1 X`09cmpl`09r1,r0 X`09bgeq`091$ X`09movl`09r1,r0 X1$:`09decl`09r0 X`09cmpl`0912(ap),r0 X`09bgtr`092$ X`09ret X2$:`09movl`0912(ap),r0 X`09ret X`09.end $ CALL UNPACK [.SOURCE.MACRO]MAXMIN.MAR;1 2117230657 $ create 'f' X`09; X`09; Robert Koeneke X`09; September 1, 1984 X`09; MORIA subroutine X`09; Macro function for : X`09; X`09;`09MIN( MAX( y , x ) + 1 , z ) X`09; X`09.title`09MINMAX`09`09Returns the min of a max and a number. X`09.ident`09/minmax/ X`09.psect misc1$code,pic,con,rel,lcl,shr,exe,rd,nowrt,2 X`09.entry`09minmax,`5EM<> X`09movl`094(ap),r0 X`09movl`098(ap),r1 X`09cmpl`09r0,r1 X`09bgeq`091$ X`09movl`09r1,r0 X1$:`09incl`09r0 X`09cmpl`09r0,12(ap) X`09bgtr`092$ X`09ret X2$:`09movl`0912(ap),r0 X`09ret X`09.end $ CALL UNPACK [.SOURCE.MACRO]MINMAX.MAR;1 1163418226 $ create 'f' X`09; PUTQIO - contains two related functions, PUT_BUFFER and PUT_QIO. X`09;`09 PUT_BUFFER accepts an (row,col) cursor address, and a X`09;`09 string. Cursor positioning characters are added into X`09;`09 the buffer in front of the string. Buffer dumps if it X`09;`09 becomes too full. X`09;`09 PUT_QIO performs the buffer dump operation. It can be X`09;`09 called externally, or by PUT_BUFFER. X`09; X`09; X`09;`09Globals used:`09(Declared in MORIA pascal code) X`09;`09`09cursor_r:`09array of 24 strings (6 bytes) X`09;`09`09curlen_r:`09length of each row string X`09;`09`09cursor_c:`09array of 80 strings (6 bytes) X`09;`09`09curlen_c:`09length of each col string X`09;`09`09cursor_l:`09Total length of row and col X`09;`09`09row_first:`09Boolean (1,0) X`09;`09`09`09`091 - Row,Col format X`09;`09`09`09`090 - Col,Row format X`09; X`09;`09Registers: X`09;`09`09R0`09Used by MOVC X`09;`09`09R1`09Used by MOVC X`09;`09`09R2`09Used by MOVC X`09;`09`09R3`09Used by MOVC X`09;`09`09R4`09Used by MOVC X`09;`09`09R5`09Used by MOVC X`09; X`09;`09This IO routine does no index checking. X`09`09`09`09`09; X`09.title`09PUT_QIO`09`09Build and dump IO buffer\ X`09.ident`09/put_qio/ X`09.psect`09IOBUF$DATA X`09`09`09`09`09; X`09IO$_WRITEVBLK:`09.long`0948`09; See STARLET ($IODEF) X`09out_buf:`09.blkb`091024`09; Size in bytes of buffer X`09out_len:`09.long`090`09; Current length of buffer X`09`09`09`09`09; X`09`09`09`09`09; X`09.psect`09IO$CODE,pic,con,rel,lcl,shr,exe,rd,nowrt,2 X`09.entry`09PUT_BUFFER,`5EM X`09`09`09`09`09; X`09movab`09out_buf,r3`09`09; Address of output buffer. X`09addl2`09out_len,r3`09`09; Buffer may be partially full. X`09cmpl`09row_first,#0`09`09; Test for row first X`09bgtr`091$`09`09`09; Branch to row,col format X`09`09`09`09`09; Col,Row format X`09mull3`09#12,12(ap),r1`09`09; (8 bytes * index) for col. X`09movab`09cursor_c-10`5Br1`5D,r1`09; Address of needed col coord. X`09movc3`09curlen_c,(r1),(r3)`09; Move col cursor characters. X`09mull3`09#12,8(ap),r1`09`09; (8 bytes * index) for row. X`09movab`09cursor_r-10`5Br1`5D,r1`09; Address of needed row coord. X`09movc3`09curlen_r,(r1),(r3)`09; Move row cursor characters. X`09brb`092$`09`09`09; Branch to copy string X1$:`09`09`09`09`09; Row,Col format X`09mull3`09#12,8(ap),r1`09`09; (8 bytes * index) for row. X`09movab`09cursor_r-10`5Br1`5D,r1`09; Address of needed row coord. X`09movc3`09curlen_r,(r1),(r3)`09; Move row cursor characters. X`09mull3`09#12,12(ap),r1`09`09; (8 bytes * index) for col. X`09movab`09cursor_c-10`5Br1`5D,r1`09; Address of needed col coord. X`09movc3`09curlen_c,(r1),(r3)`09; Move col cursor characters. X2$:`09`09`09`09`09; Copy String X`09tstw`09@4(ap)`09`09`09; No string? X`09beql`093$`09`09`09; No move needed. X`09movl`094(ap),r1`09`09; Move address of string arg. X`09movc3`09@4(ap),2(r1),(r3)`09; Move string arg into output buff. X3$: X`09addw3`09cursor_l,@4(ap),r1`09; Total length of new output X`09addw2`09r1,out_len`09`09; Total length of saved output X`09cmpw`09out_len,#900`09`09; Buffer getting full? X`09bgtr`09DUMP_QIO`09`09; Output the buffer... X`09ret`09`09`09`09; return from PUT_BUFFER X`09`09`09`09`09; X`09`09`09`09`09; PUT_QIO entry point XPUT_QIO:: X`09.word`090 X`09`09`09`09`09; XDUMP_QIO: X`09$QIOW_S`09EFN=#6, -`09`09; Unique event flag X`09`09CHAN=channel, -`09`09; Output the buffer X`09`09FUNC=IO$_WRITEVBLK, -`09; Write virtual block X`09`09P1=out_buf, -`09`09; Address of buffer X`09`09P2=out_len`09`09; Buffers current length X`09`09`09`09`09; X`09movw`09#0,out_len`09`09; Clear buffer; X`09ret`09`09`09`09; Return from PUT_QIO X`09`09`09`09`09; X`09.end $ CALL UNPACK [.SOURCE.MACRO]PUTQIO.MAR;1 2019791587 $ create 'f' X`09; X`09; Macro function for : X`09; X`09;`09y := RANDINT(x) where y receives an integer X`09;`09`09`091 <= y <= x X`09; X`09; Seed is a global variable declared in PASCAL main. X`09; X`09.title`09randint`09`09Uniform random number generator X`09.ident`09/randint/ X`09.psect misc1$code,pic,con,rel,lcl,shr,exe,rd,nowrt,2 X`09.entry`09randint,`5EM<> X`09mull2`09#16807,seed X`09bicl2`09#`5EX80000000,seed X`09subl3`09#1,seed,r0 X`09emul`09r0,4(ap),#0,r0 X`09ediv`09#2147483647,r0,r0,r1 X`09addl2`09#1,r0 X`09ret X`09.end X $ CALL UNPACK [.SOURCE.MACRO]RANDINT.MAR;1 1047970647 $ create 'f' X`09; X`09; Macro function for : X`09; X`09;`09For i := 1 to y do sum := sum + randint(x) X`09; where RANDINT returns random integer 1 <= r <= x X`09; X`09; Seed is a global variable declared in PASCAL main X`09; X`09.title`09RAND_REP X`09.ident`09/rand_rep/ X`09.psect misc1$code,pic,con,rel,lcl,shr,exe,rd,nowrt,2 X`09.entry`09rand_rep,`5EM X`09movl`094(ap),r4 X`09cmpl`09r4,#0 X`09bleq`092$ X`09movl`09#0,r0 X1$:`09mull2`09#16807,seed X`09bicl2`09#`5EX80000000,seed X`09subl3`09#1,seed,r2 X`09emul`09r2,8(ap),#0,r2 X`09ediv`09#2147483647,r2,r2,r3 X`09addl`09r2,r0 X`09sobgtr`09r4,1$ X`09addl`094(ap),r0 X`09ret X2$:`09movl`09#0,r0 X`09ret X`09.end X $ CALL UNPACK [.SOURCE.MACRO]RANDREP.MAR;1 225796726 $ v=f$verify(v) $ EXIT