I was unable to compile the example so if anyone is able to help?
These were the steps I took to try and compile the function.Re: FreeBASIC and the Raspberry Pi ?
Postby D.J.Peters » Mar 20, 2018 8:56
For our new ARM Linux user :-)
Tip: using GNU ARM assembler with FreeBASIC
Special ARM GNU as directives
file: "function.s"
Code: Select all
.arm @ 32 bit mode
.global fb_add @ make 'fb_add' visible for FreeBASIC
.type fb_add, %function @ it's a function
.text @ begin of the code segment
.align 2 @ word boundary
fb_add: @ function fb_add(r0, r1) as integer
add r0, r0, r1 @ r0 = r0 + r1
bx lr @ return from function with result in r0
.end @ end of assembler listing
file: "test.bas"
Code: Select all
declare function fb_add cdecl alias "fb_add" (byval r0 as integer,byval r1 as integer) as integer
print " 3 + 7 = " & fb_add(3,7)
sleep
#> fbc test.bas -Wa function.s
Joshy
pi@raspberrypi:~ $ cd fbPrograms
pi@raspberrypi:~/fbPrograms $ cat > function.s
.arm @ 32 bit mode
.global fb_add @ make 'fb_add' visible for FreeBASIC
.type fb_add, %function @ it's a function
.text @ begin of the code segment
.align 2 @ word boundary
fb_add: @ function fb_add(r0, r1) as integer
add r0, r0, r1 @ r0 = r0 + r1
bx lr @ return from function with result in r0
.end @ end of assembler listing
pi@raspberrypi:~/fbPrograms $
pi@raspberrypi:~/fbPrograms $ cat function.s
.arm @ 32 bit mode
.global fb_add @ make 'fb_add' visible for FreeBASIC
.type fb_add, %function @ it's a function
.text @ begin of the code segment
.align 2 @ word boundary
fb_add: @ function fb_add(r0, r1) as integer
add r0, r0, r1 @ r0 = r0 + r1
bx lr @ return from function with result in r0
.end @ end of assembler listing
pi@raspberrypi:~/fbPrograms $ as -o function.o function.s
pi@raspberrypi:~/fbPrograms $ gcc -o function function.o
/usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/crt1.o: In function `_start':
(.text+0x34): undefined reference to `main'
collect2: error: ld returned 1 exit status
pi@raspberrypi:~/fbPrograms $