[net.micro.mac] more comments

keith@ssc-vax.UUCP (Keith Nemitz) (08/09/85)

So far my mail recieved in responce to my earlier message have been
somewhat in favor of suggesting that I should make good my promises.
In that vein I summit the following code for scrutiny.


MODULE SoundDriver;

FROM SYSTEM IMPORT CODE;

PROCEDURE SysBeep(duration:INTEGER);
BEGIN CODE(43464) END SysBeep;

VAR i:INTEGER;
BEGIN
  FOR i := 5 TO 100 BY 5 DO SysBeep(i); END;
END SoundDriver.

It worked on my Mac (512k,1drive);
There was a suggestion that the return address is placed on top the stack
after the call is made, but one will notice that the duation of the tone
increases as the code implies.  (code never lies. comments, well...)

My next feat of magic will be to see if one can use the 'no entry or exit
code generated for procs' compiler option, and still get the same results.

                                              keith


(* This is to notify you that your left hemisphere is at war with your right
hemisphere.  please do not be unduly alarmed.  you were not using either of
them anyway. *)

jamie@uw-june (James Painter) (08/10/85)

When I ran the SoundDriver example posted by keith@ssc-vax I found that
the duration of the tone was NOT increasing.  I believe that the

jamie@uw-june (James Painter) (08/10/85)

Whoops!  I got interrupted.  Let's try again.

I've found that interfacing to the ROM from the PD Modula-2 compiler is
not quite as simple as Keith suggested.  His example fails to correctly
pass the duration parameter to the ROM SysBeep procedure.

It IS possible if you are willing to do a little hand assembly.


For example, here is the SoundDriver code fixed up.  At the last
iteration the duration is ~ 2 seconds as it should be.


MODULE SoundDriver;

FROM SYSTEM IMPORT CODE;

PROCEDURE SysBeep(duration:INTEGER); (*$P-*)
BEGIN
  CODE ( 4E56H ); CODE( 0000H );   (* LINK A6,#0     *)
  CODE ( 3F2EH ); CODE( 0008H );   (* MOVE.W 8(A6),-(SP)  ; Push duration *)
  CODE (0A9C8H );                  (* Trap to ROM SysBeep *)
  CODE ( 4E5EH );                  (* UNLINK A6 *)
  CODE ( 4E75H );                  (* RETURN *)
END SysBeep;  (*$P+*)

VAR i:INTEGER;
BEGIN
  FOR i := 5 TO 100 BY 5 DO SysBeep(i); END;
END SoundDriver.



If there is an easier way I'd like to know about it.



--Jamie Painter

ARPA:     jamie@uw-june.ARPA
UUCP:     {ihnp4,decvax,tektronix}!uw-beaver!uw-june!jamie