harlow@plains.UUCP (Jay B. Harlow) (03/24/90)
Allen, I felt other people may like to hear about this (thats what net is for...) I got this in the 'mail': >From: "Allen J. Hainer" <ajhainer@violet.waterloo.edu> >Message-Id: <9003231914.AA13585@violet.waterloo.edu> >To: harlow@plains.uucp >Subject: Re: 'New' Functions for hp42s >Status: R > > Thanks for an interesting post. Some of this is new information to me. >I have one questions though: > >> 500b8 ptr to top of stack, >> this is indirect, & points to last byte of stack, >> go left or lower in memory >> CAN HAVE MORE THAN ST X, ST Y, ST Z, ST T, ST L > > Can I really increase the stack? I played around with it and found that >each number on the stack requires 1b (27 decimal), but adding this to >the pointer of a full stack caused a memory reset. Could you give me >a bit more detail? What i found with the stack is the 1B is length of a stack entry a stack entry ( reading right to left in memory) 0001b length of stack entry (real & complex check out....) value 16 nybbles for a real or str 32 for an complex ?? for array xxxxx tag - 02933 real number, 02977 complex 0 ?? tag also appears with variable stored in memory now someplace in memory is the referance to where ST X, ST L.... are.. err, that the 41 type stack has values in it at all, the machine stack (above) is not always the 41 stack... (follow this?) do your favorite long calculation using the 41 stack a lot, go into the memory scanner & look though the stack, you should find (not sure what does clean up MEM?, ARRAY funcs?) more then 5 numbers on the machine stack, now the 41 style interpreter (thats what it is isn't it?) will only allow access to ST X, ST L,.... which appear to be special referances off of the machine stack... one note the [FIND] function is a do if true... 00 { 56-Byte Prgm } 01 LBL "FINDREG" ; needs value to look for in ST X 02 INDEX "REGS" ; Change to your favorite array 03 [FIND] 04 GTO 01 05 "NOT FOUND" ; here if not found in array 06 AVIEW 07 RTN 08 LBL 01 09 "FOUND AT " ; found it print out where 10 RCLIJ 11 X<>Y 12 AIP 13 +":" ; append a colon 14 X<>Y 15 AIP 16 AVIEW 17 END any one want a short sort routine? input: ST X - array to sort ST Y - column to sort on Flag 09 - order clear ascending, set descending output: ST X - sorted array rest of stack trashed.... uses: ALPHA - for a message SORTMAT - variable to hold array while sorting.... 00 { 86-Byte Prgm } 01 LBL "SORT" 02 "Sorting\n" ; \n Cism for lf ( newline) 03 ARCL ST X 04 AVIEW 05 STO "SORTMAT" 06 INDEX "SORTMAT" 07 DIM? 08 Rdn ; roll stack down 09 1e3 10 div ; divide key.... 11 0.999 12 + ; index 1 to length of array - 1 13 X<>Y 14 STOIJ ; starting row & column 15 Rdn ; roll stack down X has my index.. 16 LBL 01 ; start of sort loop 17 FC? 09 18 [MIN] 19 FS? 09 20 [MAX] 21 Rdn ; roll down, don't care what value was... 22 X<>Y 23 R<>R ; ok every row gets exchanged...... 24 I+ ; move up one row 25 ISG ST X 26 GTO 01 ; until end of array 27 RCL "SORTMAT" 28 CLD 29 END if you know you always need ascending or descending you can change lines 17-20 to just a [MIN] or a [MAX] NOW what does the XFCN "label" do..... Jay -- Jay B. Harlow <harlow@plains.nodak.edu> uunet!plains!harlow (UUCP) harlow@plains (Bitnet) Of course the above is personal opinion, And has no bearing on reality...