Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pur-ee.UUCP Path: utzoo!linus!decvax!harpo!ihnp4!inuxc!pur-ee!iuvax!apratt From: apratt@iuvax.UUCP Newsgroups: net.lang Subject: Re: Self-modifying code - (nf) Message-ID: <1322@pur-ee.UUCP> Date: Sun, 8-Jan-84 02:39:04 EST Article-I.D.: pur-ee.1322 Posted: Sun Jan 8 02:39:04 1984 Date-Received: Sun, 8-Jan-84 21:30:11 EST Sender: notes@pur-ee.UUCP Organization: Electrical Engineering Department , Purdue University Lines: 19 #R:fortune:-215700:iuvax:11800008:000:684 iuvax!apratt Jan 8 00:38:00 1984 I found another use for self-modifying code: speed. I wrote a graphics package (a pretty simple-minded one) for the IBM PC, and found that my line-drawing routine had two spots where one of three things needed doing: increment x (or y), decrement x (or y), do nothing to x (or y). I could have loaded the proper add-on value (-1, 0, or 1) into a memory location or register and used an add instruction, but it was MUCH faster to have the program "poke" an increment, decrement, or NOP instruction into the appropriate spot. One (inprecise) comparison (timed with a watch) showed a 20% speed increase (approx. 4 seconds in 20). -- Allan Pratt ...ihnp4!iuvax!apratt