chris@mimsy.UUCP (Chris Torek) (12/16/87)
In article <10861@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes: >The VAX has (is?) an `sob' as well. Actually, it has two flavours of sob, namely `sobgtr' (subtract one and branch if greater than [zero]) and `sobgeq' (subtract one and branch if greater than or equal to [zero]). Note that this handles only tests of the form `--n > 0' and `--n >= 0' (possibly inverted). >So does the 680[012]0 as well, altho it's called `dbra', a special >case of the `DBcc', where `cc' is one of any sixteen branch conditions. DBcc decrements the LOW ORDER WORD of a register, so: >Oddly, the SUN compilers don't seem to make use of it.... They do, but only if you declare variables `register short'. >Thus, if we could coax the compiler into using dbra, the best way to >copy register int n bytes from register char *p to register char *q >would be `do *q++ = *p++; while (--n);'. Not quite. If, however, you write register short n; register char *p, *q; do *q++ = *p++; while (--n != -1); you get a dbra loop. DBcc stops when the low word of a register goes to -1, rather than when it goes to 0. >... The 68020 may handle bigger loops in loop mode as it has a >bigger instruction prefetch queue. The 020 has an instruction *cache*; loops of rather respectable size will run entirely without access to main memory. The loop mode on an 010, however, avoids instruction decode as well as fetch, and hence runs much faster than the obvious guess would lead one to believe. I think the 020 loop mode (bypassing instruction decode) still only handles one instruction. On the 68000, with no loop mode, the fastest way to implement a memory-to-memory copy is by using the moveml instruction. On the 010 and 020, the moveml loop is considerably slower than a careful longword-at-a-time dbra loop. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris