1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 21:10:27 +02:00
guile/check/fib.tst
pcpa 712877a5a4 Correct implementation problems on ix86.
* check/all.tst, check/lightning.c: Only declare or use 64 bit
	interfaces on 64 bit builds.

	* check/fib.tst: Use simpler logic to not need preprocessor
	conditionals for 32 or 64 bit.

	* include/lightning.h: Only declare 64 bit macros on a 64 bit
	build. Code using lightning must know about wordsize and the
	jit generation limitations, also, this way it generates a
	compile time failure, not a runtime assertion.

	* include/lightning/jit_x86.h: Correct typo in macro name.

	* lib/jit_arm.c, lib/jit_arm-cpu.c, lib/jit_mips.c,
	lib/jit_mips-cpu.c, lib/jit_ppc.c, lib/jit_ppc-cpu.c,
	lib/jit_x86.c, lib/jit_x86-cpu.c: Correct wrong code to get
	current jit function pointer.

	* lib/lightning.c: Move call to the simplify() optimization
	to after register liveness is known. Previous code did work
	by accident but now with proper test cases the problem was
	noticed.

	* lib/jit_disasm.c: Always cast bfd_vma to long long when
	passing it as printf argument.
2012-12-03 09:40:08 -02:00

58 lines
776 B
Scilab

.data 32
format:
.c "nfibs(%d) = %d\n"
.code
jmpi main
nfibs:
prolog
arg $in
getarg %r2 $in // R2 = n
movi %r1 1
blti_u ref %r2 2
subi %r2 %r2 1
movi %r0 1
loop:
subi %r2 %r2 1 // decr. counter
addr %v0 %r0 %r1 // V0 = R0 + R1
movr %r0 %r1 // R0 = R1
addi %r1 %v0 1 // R1 = V0 + 1
bnei loop %r2 0 // if (R2) goto loop
ref:
movr %ret %r1 // RET = R1
ret
epilog
main:
prolog
arg $argc
arg $argv
getarg_i %r0 $argc
blei default %r0 1
getarg %r0 $argv
addi %r0 %r0 $(__WORDSIZE >> 3)
ldr %r0 %r0
prepare 0
pushargr %r0
finishi @atoi
retval %r0
jmpi call
default:
movi %r0 32
call:
movr %v0 %r0
prepare 0
pushargr %r0
finishi nfibs
retval %r0
prepare 1
pushargi format
pushargr %v0
pushargr %r0
finishi @printf
ret
epilog