home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19742 < prev    next >
Encoding:
Text File  |  1992-12-13  |  1.6 KB  |  49 lines

  1. Path: sparky!uunet!pmafire!news.dell.com!swrinde!gatech!news.byu.edu!yvax.byu.edu!physc1.byu.edu!seth
  2. Newsgroups: comp.sys.mac.programmer
  3. Subject: Assembly with C question...
  4. Message-ID: <1992Dec12.232559.265@physc1.byu.edu>
  5. From: seth@physc1.byu.edu
  6. Date: 12 Dec 92 23:25:59 -0700
  7. Distribution: world
  8. Organization: Brigham Young University
  9. Lines: 38
  10.  
  11. Hi. I have a question about assembly language and C. Here is a snippet of
  12. C code, followed by the same thing disassembled.
  13.  
  14.  
  15. main()
  16. {
  17.     Init();
  18.     MakeMenus();
  19.     MakeWindow();
  20.     AddrsSet();
  21.     MakeGrid();
  22.  
  23.  
  24. main:
  25. 00000000        JSR       $0000(A5)
  26. 00000004        JSR       $0000(A5)
  27. 00000008        JSR       $0000(A5)
  28. 0000000C        JSR       $0000(A5)
  29. 00000010        JSR       $0000(A5)
  30.  
  31.  
  32. My question is, why are all the function calls done in this way? How can I 
  33. tell what the offset relative to a5 is? I am confused. I have till now only
  34. done assembly in the MDS (sad, sad) assembler. (yes, I was the one whining
  35. about it a few weeks ago. The class is over, and now I can do assembly with 
  36. the inline assembler of THINK C like so many of you suggested...)
  37. In the MDS Assembler we always could tell just what our offsets were, 
  38. becaused we used labels. I don't understand how all these function calls can
  39. be made with an offset of $0000(a5). Isn't a5 the global area? Why are the 
  40. function calls going there anyways? Shouldn't they be going to the code area,
  41. with offsets relative to the PC? I obviously don't see what is supposed to be
  42. going on here, and I would appreciate it if one of you assembly gurus would 
  43. enlighten me...
  44.  
  45. Thanks,
  46. Seth Leigh
  47. BYU Physics Dept.
  48.  
  49.