home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / m68k / 1397 < prev    next >
Encoding:
Internet Message Format  |  1992-11-24  |  2.2 KB

  1. Path: sparky!uunet!munnari.oz.au!uniwa!john
  2. From: john@gu.uwa.edu.au (John West)
  3. Newsgroups: comp.sys.m68k
  4. Subject: Re: 68000 code question and optimalisation
  5. Date: 24 Nov 1992 04:20:08 GMT
  6. Organization: The University of Western Australia
  7. Lines: 38
  8. Message-ID: <1esahoINNlv4@uniwa.uwa.edu.au>
  9. References: <1992Nov23.104011.9355@philce.ce.philips.nl>
  10. NNTP-Posting-Host: mackerel.gu.uwa.edu.au
  11.  
  12. meulenbr@ce.philips.nl (Frans Meulenbroeks) writes:
  13.  
  14. >I discovered that I can do pc relative subroutine calls in two ways.
  15. >1) using bsr 
  16. >2) using jsr with d16(pc) addressing.
  17.  
  18. >Assuming that the jump offset is greater than 128 bytes, is there any
  19. >difference (except the opcode) in these two instructions?
  20. >Or are there just two ways to do the same thing (like 
  21. >move.l    #123456,-(sp) is the same as pea 123456)?
  22.  
  23. On a 68000, JSR d16(pc) takes 18 cycles. BSR word takes 18 cycles. Both require
  24. 2 reads and 2 writes. So no - there is no difference apart from the opcodes.
  25. (MOVE.L #123456,-(sp) is 20 cycles. So is PEA 123456)
  26.  
  27. >Also does anyone have suggestions on how to optimize 68000 code.
  28. >(eg. instructions or instruction patterns that can be replace by other
  29. >more efficient ones)? A pointer to a good book/article on this topic is
  30. >also welcome. I want to optimize for space without losing too much
  31. >speed.
  32.  
  33. Sadly, optimization is an art. It can really only be learnt through experience.
  34. Get yourself a table of instruction timings, determine the timing for the
  35. desired piece of code, and then see if you can find a faster way. After a 
  36. while, you'll get to know that table well.
  37. In general, there is almost no gain from replacing single instructions. The
  38. best improvements will be on longer sections of code - unrolling loops is good,
  39. re-arranging code to avoid unnecessary branches, lookup tables instead of
  40. lengthy calculations. This is of course assuming that you've already found
  41. yourself a better overall algorithm. It is usually a waste of time doubling
  42. the speed of a bubble-sort.
  43. You want space? That is trickier. You need a whole different set of tricks,
  44. and since it is usually speed that is desired, not many people have discovered
  45. them.
  46.  
  47. John West
  48. --
  49. For the humour impaired: Insert a :-) after every third word
  50.