[comp.sys.mac.programmer] Getting started in Assembly on the Mac

DFJOHN01@ULKYVX.BITNET (GMAIL_FLAG_PERSONAL_NAME) (02/15/89)

Greeting from the University of Louisville (U of L)!!! (My 1st Posting)

I am an Engineering Math and Computer Science major at U of L's Speed
Scientific School. While the only Macintosh available on the whole campus for
student use is a 512K RAM, 400k single-sided floppy machine, I managed to
familiarize myself with most of the toolbox through my endeavors with Turbo and
Lightspeed Pascals this past summer and fall.

To redefine the word "extreme", I recently obtained a full-time position with
the University's Typesetting department and am the proud "owner" of a Mac II w/
4mb RAM, 40mb hard disk with a Radius Two-Page Display monitor. (I also mess
around with our graphic designer's IIx 4/80 with a rasterOps 24-bit color
monitor, and a Sharp 24-bit color scanner).

So now I think that I am ready for the big league and would like to learn
Assembly language on the Mac. I have NO previous experience with assembly.

My three main reasons for wanting to learn it are:
  1) To understand disassembled code.
  2) To understand "debugger's" language.
  3) To make my code run faster.

I have purchased all of MPW, including the Pascal & C compilers, the Assembler,
MacApp, SADE and TML, and the TML source code library (which is AWESOME). Can
you advise a soul such as mine as to how to get started with Assembly?

Thanks in advance...

David F. Johnson         | Bitnet   : DFJOHN01@ULKYVX
Typesetter II / Student  | INTERNET : dfjohn01%ulkyvx.bitnet@cunyvm.cuny.edu
University of Louisville | UUCP     : ...psuvax1!ulkyvx.bitnet!dfjohn01

*******************************************************************************
*****     The words herein are mine, all mine, and are probably           *****
*****     *NOT* those of the University of Louisville.                    *****
*******************************************************************************

wiechman@athos.rutgers.edu (NightMeower) (02/15/89)

In article <8902150414.AA06752@jade.berkeley.edu> DFJOHN01@ULKYVX.BITNET (GMAIL_FLAG_PERSONAL_NAME) writes:

> 
> My three main reasons for wanting to learn it are:
>   1) To understand disassembled code.
>   2) To understand "debugger's" language.
>   3) To make my code run faster.
> 
> I have purchased all of MPW, including the Pascal & C compilers, the Assembler,
> MacApp, SADE and TML, and the TML source code library (which is AWESOME). Can
> you advise a soul such as mine as to how to get started with Assembly?
> 



With MPW Pascal (I believe our version is 2.0) the source code is
fairly tight.  You may be able to do some bit shifts instead of a
division by powers of two in some cases.  So, reason number three may
be partially done for you.  I am certain there is a way to compile
into assembly code if you'd like to try to optimize it, however just
wait until you have thoroughly debugged things.

The MPW C compiler is a completely different story.  The same
algorithm is much slower written in C.

If you must start in assembly, there are a number of macros to make
your life easier.  Many if not all of the flow constructs of Pascal
exist, allowing easier coding and in the long run easier maintainence
(sp?).  


Kevin
-- 
===========================================================================
Kevin S. Wiechmann			arpa:  wiechman@rutgers.rutgers.edu

	 This is only a test... for the next sixty seconds...

han@Apple.COM (Byron Han, Architect) (02/16/89)

Some good books are:

MPW and Assembly Language Programming.  by Scott Kronick.  Good introduction to
     programming Toolbox stuff with Assembler.
Encyclopedia Mac ROM by Keith Mathew and Jay Friedland.  This gives examples on
     how to call Mac Toolbox routines from C, Pascal, and Assembly.  
     Indispensible.
How to Write Macintosh Software.  by Scott Knaster.

With MPW you can use the dumpcode and dumpobj routines to "disassemble" code.
This is a good way to learn techniques.  Of course, the 68000 reference
from Motorola is good to have also.



+-----------------------------------------------------------------------------+
| Disclaimer: Apple has no connection with my postings.                       |
+-----------------------------------------------------------------------------+ 
Byron Han, Communications Architect      Cereal, anyone?  :-)
Apple Computer, Inc.                     -------------------------------------
20525 Mariani Ave, MS27Y                 Internet: han@apple.COM
Cupertino, CA 95014                      UUCP:{sun,voder,nsc,decwrl}!apple!han
--------------------------------------   GENIE: BYRONHAN
ATTnet: 408-974-6450   Applelink: HAN1   CompuServe: 72167,1664
------------------------------------------------------------------------------

thecloud@dhw68k.cts.com (Ken McLeod) (02/16/89)

In article <25887@apple.Apple.COM> han@Apple.COM (Byron Han, Architect) writes:
>Some good books are:
>
>MPW and Assembly Language Programming.  by Scott Kronick.  Good introduction to
>     programming Toolbox stuff with Assembler.
>Encyclopedia Mac ROM by Keith Mathew and Jay Friedland.  This gives examples on
>     how to call Mac Toolbox routines from C, Pascal, and Assembly.  
>     Indispensible.
>How to Write Macintosh Software.  by Scott Knaster.

  And, of course:

  "The Complete Book of Macintosh Assembly Language Programming"
  by Dan Weston.

  Excellent hands-on primer, with tons of examples demonstrating all the
  commonly-used Toolbox routines. The original edition used the MDS
  Assembler for its examples, but I believe there's a new edition that
  deals with the MPW assembler.

-ken

-- 
==========     .......     =============================================
Ken McLeod    :.     .:    felix!dhw68k!thecloud@ics.uci.edu
==========   :::.. ..:::   InterNet: thecloud@dhw68k.cts.com
                ////       =============================================

malczews@castor.usc.edu (Frank Malczewski) (02/19/89)

In article <25887@apple.Apple.COM> han@Apple.COM (Byron Han, Architect) writes:
>Some good books are:
>
>MPW and Assembly Language Programming.  by Scott Kronick.  Good introduction to
>     programming Toolbox stuff with Assembler.



Actually, the Kronick book, though somewhat interesting as a general mood
piece, is not all the in-depth in terms of assembler.  I would recommend
looking elsewhere (I believe there are others assembler texts that provide
a lot more detail [I've not looked, however].

  -- Frank Malczewski     [malczews@castor.usc.edu]

P.S. If you'd like a slightly used copy, let me know...

jkjl@munnari.oz (John Lim) (02/20/89)

>In article <8902150414.AA06752@jade.berkeley.edu> DFJOHN01@ULKYVX.BITNET (GMAIL_FLAG_PERSONAL_NAME) writes:
>
>> My three main reasons for wanting to learn it are:
>>   1) To understand disassembled code.
>>   2) To understand "debugger's" language.
>>   3) To make my code run faster.
>> 
>> I have purchased all of MPW, including the Pascal & C compilers, the Assembler,
>> MacApp, SADE and TML, and the TML source code library (which is AWESOME). Can
>> you advise a soul such as mine as to how to get started with Assembly?

I suggest you compile your MPW and TML code with the output assembler
option on. This will give you a great idea of how *bad* assembler code
is written. 

But all jokes aside, it probably is a good idea to compare your HLL code
and see how the assembly lang. is generated as it will teach you
(1) and (2). Optimizing code will then come with experience.


	Good Luck !

	john