Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!uwm.edu!bionet!ucselx!crash!pro-mansion.cts.com!psonnek From: psonnek@pro-mansion.cts.com (Patrick Sonnek) Newsgroups: comp.sys.apple2 Subject: Re: ML subroutines (passing parameters in ML) Message-ID: <8834@crash.cts.com> Date: 26 Apr 91 08:36:11 GMT Sender: root@crash.cts.com Lines: 43 In-Reply-To: message from acmfiu@serss0.fiu.edu >i'm curious as to how some of you pass parameters to ML routines in your >ML code. for instance, let's say you had a routine that took two numbers >and returned the answer. how would you pass the two routines. i've basically >passed values two ways: 1) put them in some dummy variable, 2) if the >subroutine required many parameters, then i'd just pass the address of >where to find the data. >i'm just looking for efficiency and readability. #1 above is definitely >not readable. but #2 is. does anyone pass parameters via the stack? The stack works well, as you can pass the entire address to your routine. the registers only hold one byte, so you would have to use two registers to pass the address. Another thing that will work, is the following line of code CallSub JSR SubRotne DW Parmlist . . . with this bit of code, you could then check the stack for the return address, which would point at the address containing the address of your parameter list. Your subroutine would have to add 2 to the address contained in the stack before issuing the RTS command, or you would return to the DW and your program would do strange things, or it would die horribly. I now this is quick and dirty, but I've got to run, If you've got more questions, you can e-mail me. ---- ProLine: psonnek@pro-mansion Sysop Pro-mansion: 507/726-6181 Internet: psonnek@pro-mansion.cts.com MCImail: psonnek UUCP: crash!pro-mansion!psonnek ARPA: crash!pro-mansion!psonnek@nosc.mil BITNET: psonnek%pro-mansion.cts.com@nosc.mil <> <>