Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 exptools 1/6/84; site ihnss.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!whuxl!houxm!ihnp4!ihnss!knudsen From: knudsen@ihnss.UUCP Newsgroups: net.micro.6809 Subject: Speed-optimizing 6809 'C' routines Message-ID: <2287@ihnss.UUCP> Date: Fri, 2-Nov-84 14:28:08 EST Article-I.D.: ihnss.2287 Posted: Fri Nov 2 14:28:08 1984 Date-Received: Mon, 5-Nov-84 10:06:55 EST Organization: AT&T Bell Labs, Naperville, IL Lines: 34I just posted a benchmark timing of the Prime Sieve run on OS-9 C, Level 1, Coco. I think our favorite chip came off pretty well, tho can't judge till I learn what the C64's clock rate is. Some hints I learned last nite about speeded up C functions: (1) Although the 6809 cleary beats other 8-bitters in stack-frame addressing for automatic variables, you can run even faster (and a tad shorter) by re-declaring automatic locals as either DIRECT STATIC in the function body or DIRECT external and DIRECT global outside of any bodies. (2) Too many variables done as in (1) will overflow your direct page, so another hint: Pick the variable that's most critical in a function and declare that one LAST (or FIRST?). The idea is to give it a zero offset from the S-register, so it gets accessed as "0,S" == ",S" which is just as fast (4 cycles for CHAR) as a DIRECT pager. All other items in the stack frame will be "n,S" and will take an extra clock cycle, unless n>7 in which case you pay two extra cycles and another byte. So put other critical automatics' declarations next to the most critical one. (3) I don't know to what extent any C compilers take advantage of keeping pointers in registers (I THINK that Microware C lacks REGISTER declaration), but when writing assembler position-independent code, I would re-write for(i=0; i