🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #5514

Re: Modula-2 and Assembly

#5514
From: John Schultz
Date: Fri, 28 Sep 1990 21:51
65 lines
3752 bytes
In article <1990Sep28.013538.3231@zorch.SF-Bay.ORG> xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) writes:
>lkoop@pnet01.cts.com (Lamonte Koop) writes:
>>
>>    I'm about to go out of my mind here.  I have a rather large program
>>written in Modula-2, in which I suddenly find a need to have the ability to
>>Get/Set a 68030 or 68020's cache control register (CACR).  In assembly, no
>>problem...in Modula-2..big problem.  Using Benchmark Modula-2 there is a
>>utility for converting asm load files to M2 OBM files (for use as the
>>Implementation portion of a library module)..BUT, I am beginning to think that
>>this particular path isn't going to work for me (nothing's going my way with
>>this...).  You can also use INLINE or CODE procedures, which are basically
>>inline lists of machine code (hex op-codes, the whole works...what fun; NO
>>mnemonics, labels, etc...just the pure machine code...), but these so far have
>>produced nothing but rather spectacular GURUs (one managed to blank vd0:...and
>>other bells and whistles).  If ANYONE has ides post them or E-Mail me...
>
>Well, I cannot _guarantee_ that this will work, because I've never found
>the need for it, but ...
>
>Modula-2 itself supports memory mapped i/o, through the low level ability
>to address a particular physical word of memory by its (constant) address.
>
>See, for example, "Modula-2, A Seafarer's Manual and Shipyard Guide",
>Edward J. Joyce section 6.1 "Absolute Memory Locations" (page 168, in my
>edition), or "Programming in Modula-2", Niklaus Wirth, Fourth Edition,
>Section 29 of the manual or sections 12 and especially 13.2 of the Report.
>
>The trick, better illustrated in Joyce's book, is to declare the variable
>with the decimal or hex absolute address in brackets right after the
>variable name.  From Joyce:
>
>	VAR
>		EndMemory[65535] : CARDINAL;
>		ResetPntr[0FFFEH] : INTEGER;
>		NMIPntr[0FFFCH] : INTEGER;
>
>Try it!  This might let you finess the assembly problem altogether.
>
>Kent, the man from xanth.
><xanthian@Zorch.SF-Bay.ORG> <xanthian@well.sf.ca.us>

  First, Lamonte wants to change the CACR, which is a register, like
"D0" or "A5" etc, and thus doesn't have an "address". Second the above
"trick" won't work with Benchmark anyway (at least not with my version).
A pointer must be declared and initialized explicitly (no biggie).

  Playing with the CACR or any of the control registers must be done in
assembly, and *must* be done in supervisor mode, as MOVEC is a privileged
instruction. Once you get your code working in assembly (you'll need a
68020/030 assembler) it's easy to write a conversion utility to convert
the binary to INLINE statements. For something like CACR routines this
won't be too much of a pain, but for larger HLL to assembly interfacing,
you're better off with C. All of my high performance work is done in C and
assembly, and lower performance code in M2 (it's one fast compiler). The
Benchmark facility for assembly interfacing only works with a quirky version
of the Metacomco assembler (although PD fixes are around).

  Dave Haynie's SetCPU plays with the CACR. If the source is available,
you're all set, else ask Dave or other CBM'rs about the restrictions of
putting the Amiga into supervisor mode and banging the CACR.

  Good luck,


  John
Technical Details
Message-ID: <4702@crash.cts.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!nosc!crash!jcs
References: <4676@crash.cts.com> <1990Sep28.013538.3231@zorch.SF-Bay.ORG>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!nosc!crash!jcs
From: jcs@crash.cts.com (John Schultz)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Modula-2 and Assembly
Message-ID: <4702@crash.cts.com>
Date: 28 Sep 90 21:51:14 GMT
References: <4676@crash.cts.com> <1990Sep28.013538.3231@zorch.SF-Bay.ORG>
Organization: Crash TimeSharing, El Cajon, CA
Lines: 65