[net.micro.apple] Apple Pascal & Assembly - Expert Help Needed

dan@uwmacc.UUCP (dan jatnieks) (05/29/86)

*** This line reserved for a future use as yet unrevealed to me ***

   For the past several months I have been using Apple's UCSD Pascal system to 
write a program that has several routines written in Assembler.  The assembler
part is basically an interface to the Apple's graphics routines in the 
Applesoft ROM.  Currently there are about 10 assembly ".PROC"'s some of which 
are for high res. and the others for low res.  I haven't found the Apple manuals
to be very useful in the area of calling assembly routines, and have the 
following questions about it:

   1.  I haven't found a good way to share data (labels) between two or more
       ".PROC"'s.  Supposedly, using ".DEF" and ".REF" will make a label 
       globally available, but I had problems with this.  If the routine in
       which the label is defined is *not* the first routine (sequentially) that
       uses it it seemed to assemble and link o.k., but it wouldn't run 
       correctly.  The only way it will run correctly is if the label is defined
       in the first routine that uses it.  i.e. (NOT a literal example)
      
       This works:       .PROC R1     This doesn't:      .PROC R1
                         .DEF labl                       .REF labl
                         LDA labl                        LDA labl
                         RTS                             RTS
                  labl:  .BYTE 1

                         .PROC R2                        .PROC R2
                         .REF labl                       .DEF labl
                         LDA labl                        LDA labl
                         RTS                             RTS
                                                   labl: .BYTE 1

       There is no mention of this in the manual, and besides causing me 
       headaches, doesn't seem reasonable.  I can work around it, but when
       a variable (label) inherantly belongs in a routine I would rather not 
       move it just because that routine is not first.  Has anyone else run 
       into this problem?  What is the cause?  Is there a better solution?

   2.  I tried to write a Pascal program that would test all of the assembly
       routines that I wrote.  In this program all the assembly routines were
       declared as "EXTERNAL".  Compiling this program kept giving me a very
       cryptic "Stack Overflow" message followed by a reboot.  Eventually I
       removed some of the "EXTERNAL" declarations, and presto! it worked.  It
       apparently wasn't just because there were too many "EXTERNAL"
       declarations, because there is a different error message for that.  Why
       would just declarations cause a stack overflow?  There were maybe ten
       "EXTERNAL"s and two other Procedures (both small), and I can't imagine
       that much stack space would be needed during such a small compilation.

   3.  Does anyone know of a GOOD technical manual about Apple Pascal and using
       assembler from it?

   [ If anyone is interested enough, I can mail the actual code.  It's small and
     might help to understand the problem.  I would send a version that works 
     and a version that doesn't to compare.  I'm not crazy about doing it, and 
     it might be hard to explain (via written word) what each part does, but 
     I'll try. ]

   What I am trying to do is not that difficult or complicated.  The Pascal
assembler seems to be overly restrictive about many things.  If I could use
my MERLIN assembler, I could finish it in an hour or two.  Does anyone know
if there exists an assembler that can produce relocatable code compatable
with Apple Pascal?  The whole process is agonizingly slow under Pascal, and
I would love to do it some other way.
   Does anyone have any experience with the new PRODOS version of Apple Pascal
that I hear about every now and then?  Is it compatable with code from the 
UCSD version?  More importantly, is the assembler better?

   Thanks in advance for any help or suggestions.
                                                 --danj.


-- 

----------
"How often have I said to you that when you have eliminated the impossible,
 whatever remains, however improbable, must be the truth"
               -- Sir Arthur Conan Doyle

dan jatnieks     

Univ. of Wisconsin - Madison C.S. Dept.
Univ. of Wisconsin - Madison Academic Computing Center (MACC) Micro Consultant

UUCP :   ...{allegra,ihnp4,seismo}!uwvax!uwmacc!dan
ARPA :   dan@easter

USMAIL:    Work - c/o MACC-MIC         Home - 1301 Spring St.
                  1210 W. Dayton              Apt.#601
                  Madison, WI  53706          Madison, WI  53715
                  (608) 263-7744              (608) 251-6302
----------

ags@pucc-h (Dave Seaman) (06/09/86)

In article <2236@uwmacc.UUCP> dan@uwmacc.UUCP (dan jatnieks) writes:
>   1.  I haven't found a good way to share data (labels) between two or more
>       ".PROC"'s.  Supposedly, using ".DEF" and ".REF" will make a label 
>       globally available, but I had problems with this.  If the routine in
>       which the label is defined is *not* the first routine (sequentially) that
>       uses it it seemed to assemble and link o.k., but it wouldn't run 
>       correctly.  

I have not run into this, even though I have used quite a few .DEFs and
.REFs.  Are you using version 1.2?  I seem to recall there was a bug
in the version 1.1 linker that might explain this.

>   2.  I tried to write a Pascal program that would test all of the assembly
>       routines that I wrote.  In this program all the assembly routines were
>       declared as "EXTERNAL".  Compiling this program kept giving me a very
>       cryptic "Stack Overflow" message followed by a reboot.  

There are two solutions to this:  use the compiler swapping {$S+} option, or
(under version 1.2) use the system configured for 128K.  Note the amount
of free space reported by the compiler at the beginning of each procedure.
If that number gets too small, a stack overflow is likely.

>   3.  Does anyone know of a GOOD technical manual about Apple Pascal and using
>       assembler from it?

I am not aware of any better source than the Apple documentation.  Sorry.
-- 
Dave Seaman	  					pur-ee!pucc-h!ags

	"I wish I had time to explain Dimensional Transcendentalism!"