[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[f-cpu] fctools 0.3 uploaded to seul.org
Hi F-gang!
I uploaded fctools-0.3.tar.gz to http://f-cpu.seul.org/~f-cpu/new/.
Highlights of this release:
* I finished the linker. It supports only static binaries and
relocatable objects (that is, no shared libraries), but that
should be sufficient for the moment.
* There also is a second emulator, called `elfemu'. It emulates
a basic Unix/Linux operating system running on an F-CPU,
including virtual memory and a reasonable set of system calls.
Currently, it runs only static binaries, but that's all you can
build with the most recent tools anyway. See the README file
for a description how to build ELF binaries, and how to run them.
* (fcpu-)as accepts a new option `-T <hexval>' which sets the load
address of a binary created with `-O bin'. The machine emulator
`emu' still loads a binary at address 0, though.
* (fcpu-)emu now uses a table-based instruction decoder that
should be faster than the compare-and-jump tree gcc generated
for the `switch' statement I used before. Gcc compiles `emu.c'
a little faster now, and needs less memory.
* The `bitrev' instruction now right-shifts by the number of bits
indicated by the third operand (as the manual states it).
I also changed EU_SHL to match the emulator (not released yet).
* I changed the system calling conventions. In release 0.2, you had
to execute
move first_arg, r1
move second_arg, r2
...
syscall $syscall_number, r0
move r1, result
but that's suboptimal. In 0.3, the sequence has changed to
move first_arg, r2
move second_arg, r3
...
loadconsx $syscall_number, r1
syscall $0, r0
move r1, result
which allows us to define a single assembler function that accepts
the syscall number as an argument (which was impossible before):
.text
.p2align 5
.globl _syscall
_syscall:
syscall $0, r0
// handle return values (-4096...-1 means there was an error)
loadconsx.0 $-4097, r2
cmple.64 r2, r1, r3
loadcons $errno, r2
jmpl r3, r63 // not an error, return result
store.32 r2, r1 // store code in `errno' and return -1
loadconsx.0 $-1, r1
jmp r63
.comm errno,4,4
Now we can write something like
#include <unistd.h>
/* this should go into a header file */
#define SYS_read 1
#define SYS_write 2
extern long _syscall(unsigned long, ...);
ssize_t
read(int fd, void *buf, size_t len) {
return _syscall(SYS_read, fd, buf, len);
}
ssize_t
write(int fd, const void *buf, size_t len) {
return _syscall(SYS_write, fd, buf, len);
}
to create system call wrappers in C. I also added a lot of system
calls, but only to `elfemu' (see emu/syscalls.def for a list
of supported functions). `emu' still accepts only `exit' (0),
`read' (1) and `write' (2) - and I guess it will stay that way.
* A number of bugs has been fixed.
Have fun,
--
Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
"All I wanna do is have a little fun before I die"
*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu in the body. http://f-cpu.seul.org/