F.A.M.E.
Fast and Accurate Morolora 68000 Emulation Library
Custom Code Generation
Copyright (c) 2002-2005 Oscar Orallo Peláez / Daniel Lancha García. All rights reserved.
March 14th, 2006
0. Introduction |
This document is intented for advanced users in order to get advantage of some expert features defined at design time. If you are not very familiar with 68000 emulation/architecture, you are probably looking for the standard FAME distribution. For a complete function reference, take a look at the standard FAME distribution too.
Customized code generation allows you to get the best from FAME, fiting it to your needs. Frequently, some emulation features are not really interesting/needed when you emulate a given system, so you can switch them off to speed things up. This is specially useful when you are running out of CPU power.
This library was designed with customization in mind. Every emulation environment has its own requirements and frequently using a standard built is kinda pointless. We experimented great speed improvements using a customized built for every emulator. NEO4all and UAE4all emulators were coded in this fashion.
Unfortunately, we did not think in the first place about anyone generating a custom built so you will find generator messages/comments in spanish. Refer to this documentation if you do not understand spanish.
If you find any bug in FAME, it would be nice that you inform me about that via email. Any feedback, comments and suggestions will also be appreciated.
How to contact Oscar Orallo:
E-mail: oscar@m68k.com
Web site: http://www.m68k.com/fame
FAME Distribution: http://www.m68k.com/fame/fame.zip (latest)
FAME Development Package: http://www.m68k.com/fame/famedev.zip (latest)
1. Terms of use |
FAME is a development package that contains the following files:
File | Description |
---|---|
famex86.c | X86 source code generator |
famesh4.c | SH4 source code generator |
generation.html | Library generation document |
fame.html | Documentation file |
fame.h | C/C++ header file |
FAME may be distributed freely in unmodified form, as long as this document file is included.
Nothing may be charged for this library. If you want to use it in a shareware or commercial application, contact me.
The author will not be held liable for damages. FAME comes with absolutely NO WARRANTY. Anyway i will try to help you with any problem you have using FAME.
If you do not agree with all of these terms, please remove FAME from your computer.
You are encouraged to contact the author if you wish to use FAME in a commercial product (to negotiate licensing).
Any program which uses FAME must include in its documentation or in the program itself the following credit text:
FAME Motorola 68000 Emulation Library by Oscar Orallo (oscar@m68k.com)
2. What you will need |
3. Getting started |
In order to generate your customized FAME, you will have to follow these steps:
4. Code generation options |
I describe here the generation options found in FAME.
I have coloured option headers to warm about size/speed issues:
- Grey: Does not affect in speed and/or size at all.
- Green: Little impact in speed and/or size.
- Yellow: Medium impact in speed and/or size. Sometimes depends upon execution environment.
- Red: Big impact in speed and/or size.
Code generation format |
Option: -f <format> | Set by default: win32 |
Plaforms: X86 |
Select the code format to use the library with the different compilers around for the X86 platform. Currently, the following output formats are supported:
|
Calling convention |
Option: -r | Set by default: stack |
Plaforms: X86 |
This option is related with the way the compilers manage the function parameters. There are two options: by the stack or by registers. Generally, the compilers pass the parameters by the stack. Visual C++ and GNU C/C++ compilers do this by stack. Consult the documentation of your compiler if you do not know how it does. |
Inline code |
Option: -i | Set by default: disabled |
Plaforms: X86 |
The fetch-decode loop is inlined with the opcode implementation in order to speed up this process. This option has a great impact in terms of speed, so do not turn it off unless you want to get as a reduced code size as possible. In the SH4 version, the code is always inlined. |
Bits address bus |
Option: -ab32 | Set by default: 24 |
Plaforms: All |
You can select between 24 and 32 bits address bus. 32 bits addresses are faster because there is no need to isolate the lower address bits but requires to have clean addresses. There is no rule to know if a system requires address masking. Some systems take in advantage of the fact that the 68000 only uses the lower 24 bits for addressing to not worry about the higher bits. |
Dummy reads emulation |
Option: -nlt | Set by default: enabled |
Plaforms: All |
Some instructions perform a memory read that does not modify the result of the instruction nor the timing in any way. This is, a dummy read. However, a 68000 microprocessor really does the read. |
Not documented features emulation |
Option: -ncnd | Set by default: enabled |
Plaforms: All |
Enables the emulation of some 68000 undocumented behaviour. Usually, this is not needed to get a fairly good level of accuracy. If you want to know more about this, you can find more information here. |
User and supervisor memory address spaces |
Option: -eum | Set by default: enabled |
Plaforms: All |
Generally, the emulated systems use the supervisor memory address space. Generating FAME to use a single memory address space speeds up emulation and decrease object code significantly. Try to use a single memory address space whenever possible. |
Group 0 exceptions emulation |
Option: -ne0 | Set by default: enabled |
Plaforms: All |
The address and bus error exceptions (reset exception is not emulated) could be emulated enabling this option. However, this will slow things down significantly due to the aditional checkings on addresses. |
Function names prefix |
Option: -n <pref> | Set by default: m68k |
Plaforms: All |
You can change the prefix used in function naming in FAME. By default, they are named with the m68k prefix. This is useful when you are about emulating a multi-CPU system and do not want to switch the CPU context generating as many instances as |
Exact timing |
Option: -net | Set by default: enabled |
Plaforms: All |
Some instructions requires a good deal of CPU power to calculate the exact number of clock cycles spent in its execution. With this option you can enable/disable the accurate timing. Swith this off if you prefer speed over accuracy. |
Memory map descriptors caching |
Option: -dm | Set by default: disabled |
Plaforms: SH |
A large memory region list could generate a bottleneck in memory access easily. To avoid this problem, you can enable this option, fixing the time spent in address decoding despiting the memory region list. However, this will increase notably the object code generated. |
Internal clock cycles counting |
Option: -ncc | Set by default: enabled |
Plaforms: All |
FAME has an internal cycles counter with the total number of clock cycles executed since the last reset. Disabling this option, FAME will not update this counter after each execution freeing a bit of CPU power for other tasks. |
Bit 0 execinfo |
Option: -nb0 | Set by default: enabled |
Plaforms: All |
This bit holds the running state of the emulated CPU. This bit is used by the core to modify correctly some register values from the outside (memory handler, interrupt handler, ...). |
Trace mode emulation |
Option: -nt | Set by default: enabled |
Plaforms: All |
This option enables trace exceptions. The emulation of this feature could be expensive in terms of speed depending upon size of timeslices. In addition, the vast majority of the systems do not use it at all, allowing you to turn it off for good. |
Take in account clock cycles spent in IRQ attention |
Option: -nic | Set by default: enabled |
Plaforms: All |
When the 68000 CPU gets interrupted by an IRQ, it spends some clock cycles in its attention. This option allows you to take in account those clock cycles. They will stop the emulation under normal circumstances, this is, if the internal cycles counter reaches zero or bellow. |
Memory accesses to two memory regions simultaneously |
Option: -nmb | Set by default: enabled |
Plaforms: SH |
Since a long word memory access requires two word accesses, it may happen a single long word access implies two different memory regions in one shot. In some systems, this could not be take place, so you can turn off this option to speed up memory wobblies by a bit. |
Check address errors in short jumps |
Option: -cb | Set by default: enabled |
Plaforms: SH |
This option is a partially implemented address error exception. It was specially designed to fix the Commodore Amiga 500 game "Shadow of the Beast" with the lowest CPU power cost possible. |
5. Generation tips |
If you have any suggestions, comments or contributions do not hesitate to get in contact with me.
Have a nice day!