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