Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!mintaka!pogo.ai.mit.edu!rjc From: rjc@pogo.ai.mit.edu (Ray Cromwell) Newsgroups: comp.sys.amiga.emulations Subject: Re: Emulator Mechanics (sorry long post) Message-ID: <1991Mar9.033450.9362@mintaka.lcs.mit.edu> Date: 9 Mar 91 03:34:50 GMT References: <1303@macuni.mqcc.mq.oz> <39935@cup.portal.com> <10775@dog.ee.lbl.gov> Sender: daemon@mintaka.lcs.mit.edu (Lucifer Maleficius) Distribution: na Organization: None Lines: 39 Besides inline data, don't forget this old trick lda choice asl tax lda jumptable+1,x pha lda jumptable,x pha php rti Or what about this entrypoint1 lda #data1 .byte 2c entrypoint2 lda #data2 .byte 2c entrypoint3 lda #data3 .byte 2c etc,etc 2c is the 6502 instruction 'bit'. The operand to bit is a SHORT pointing to an address. LDA # is 2 bytes long, so entering at any point causes the following instructions to do nothing. How are compilers supposed to be smart enough to recognize such clever optimizations and translate them to their 68000 equivelent? The 6502 could only address 64k, space savers like this were used all the time. Then of course, there weren't any rules of how to call the OS, so most 6502 programs would JUMP directly into rom at different addresses depending on how much of the function they wanted to use. I think compilers would do a much better job on 16bit micro's where C is used. I don't know a single C compiler that generates self modifying code, or 'do-nothing' instructions between opcodes to save bytes whenentering functions.