1 Star 0 Fork 0

pifan_dev / FUZIX

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.binfmt 4.38 KB
一键复制 编辑 原始数据 按行查看 历史
32bit
Uses binfmt_flat with tiny tweaks to avoid loading Linux binaries for now.
8bit
16 byte header for current style binary. We try to reflect the general
pattern of naming in classic Unixlike systems
The 16 byte header is replaced by stubs. The syscall interface for most
8bit processors is to jump to the start of the stubs. Relocations are
done by the application itself if required, except the 6502 where because
of the ZP relocations this is not practicable.
struct exec {
uint16_t a_magic;
#define EXEC_MAGIC 0x80A8 /* Just need something to id with */
uint8_t a_cpu;
#define A_8080 1 /* 8080 series processors (and Z80) */
#define A_6800 2 /* 6800 series */
#define A_6502 3 /* 6502 */
#define A_6809 4 /* 6809 */
#define A_RABBIT 5 /* Rabbit is unZ80 enough to be its own */
#define A_MSP340 6 /* MSP340 series */
#define A_PDP11 7 /* PDP-11 */
#define A_8086 8 /* x86 16bit */
#define A_68000 9 /* 68000 32bit */
#define A_NS32K 10 /* NS32K 32bit */
uint8_t a_cpufeat;
#define AF_8080_8085 1 /* Uses 8085 instructions */
#define AF_8080_Z80 2 /* Uses legal Z80 instructions */
#define AF_8080_Z180 4 /* Uses Z180 instructions */
#define AF_8080_Z280 8 /* Uses Z280 instructions */
#define AF_8080_EZ80 16 /* Uses EZ80 extensions */
#define AF_6800_6803 1 /* PSHX etc */
#define AF_6800_6303 2 /* XGDX and similar */
#define AF_6800_68HC11 4 /* Y register and other extensions */
#define AF_6C502 1 /* CMOS 6502 extra instructions */
#define AF_65C816 2 /* Uses 65C816 instructions */
#define AF_65C816_B0 4 /* 65C816 assuming bank 0 (so can use
stack relative addressing) */
#define AF_65C02_BITOP 8 /* SMB/RMB/TSB/TRB/BBR */
#define AF_6809_6309 1 /* 6309 extensions */
#define AF_RABBIT_R3K 1 /* Uses Rabbit 3000 additions */
uint8_t a_base; /* Load address page */
uint8_t a_hints;
#define HINT_GRAPHICS 1 /* Hint that this binary uses graphics */
#define HINT_DEBUG 2 /* Debug data follows binary image */
uint16_t a_text;
uint16_t a_data;
uint16_t a_bss;
uint8_t a_entry; /* Entry point - 0-255 bytes in only */
/* These are kept in pages */
uint8_t a_size; /* Binary memory request 0 = all */
uint8_t a_stack; /* Stack size hint */
uint8_t a_zp; /* Zero/Direct page space required */
/* This isn't really part of the header but a location fixed after
it */
/* uint16_t a_sigvec; */
};
Entry Conditions & System Calls
6502/65C816:
C stack pointer configured in zero page (ZP:0/1 before relocations)
C stack will be placed at the top of memory as normal (C and
CPU stack are separate)
6502 stack set to end of 6502 stack space (may not be $1FF)
X holds high byte of load address
A holds first zero page value allocated
Y undefined
Signal vector helper code must be present at offset 16
System calls via
Arguments on C stack (ZP:0 + base)
X holds the syscall number
Y holds the number of arguments
Behaves like a cc65 non fast call, so the syscall unstacks the
passed arguments
Returns in YX with error code in A and Z clear if no error
68000:
A7 is set to the C stack
Code is always relocated
Other registers are undefined
System calls:
32bit pointer / 32bit int unlike smaller ports
trap 15 causes a SIGTRAP
trap14 (currently - may relocate this)
d0 = syscall
d1 = arg1
a0 = arg2
a1 = arg3
a2 = arg4
The only register we guarantee to save is A5, thus anything using
base relative addressing needs to use A5 as the base because signal
handling at the wrong moment may mean all other registers are
undefined. This might seem a pain but it saves us a load of clocks!
return value is in d0.l and a0.l (for convenience)
error code is in d1.w
6809:
S is set to the C stack
X holds the load address
other registers undefined
Execution begins at first byte of loaded binary
No signal vector helper required
System calls are via swi
Arguments on the caller stack, call number in D when swi
Caller unstacks
Returns error code in D, return in X
8080/8085/Z80:
SP is set to the C stack
DE holds the load address
System calls:
On Z80 IX, IY and alternate registers are saved except AF' which
may be destroyed
On entry userspace stack holds the syscall arguments
On return HL holds the return value and carry is clear
On error return HL holds the error and carry is set
Signal vector helper will be present at offset 16. This is needed
for ACK 8080 binaries but for current SDCC Z80 binaries it's just
ex de,hl
jp (hl)
1
https://gitee.com/pifan_dev/FUZIX.git
git@gitee.com:pifan_dev/FUZIX.git
pifan_dev
FUZIX
FUZIX
master

搜索帮助