ForwardCom / code-examples

Code examples for ForwardCom
18 stars 2 forks source link

./make_example.sh hello #1

Open ego opened 4 months ago

ego commented 4 months ago

Hi, Great project!

I have some errors while running code examples

❯ uname
Darwin MacBook-Pro Darwin Kernel Version 23.5.0; ARM64_T6031 arm64
❯ ./make_example.sh hello

Assembling hello.as to hello.ob

Linking file hello.ex
Adding object files: hello.ob
Using library members: libc.li:puts.ob libc.li:raise_event.ob libc.li:startup.ob
Running hello.ex:
Error: Cannot control floating point exceptions and rounding mode on this platform
Hello ForwardCom world!
❯ cat out.txt
Debug listing of hello.ex
Sat Jun 29 02:30:59 2024

0024 __entry_point: int64 r16 = move(r0)
                  0x0
0025              int64   r17 = move(r1)
                  0x0
0026              int64   r18 = move(r2)
                  0x0
0027              int64   r0 = move(0x1 << 32)
                  0x100000000
0028                      call _raise_event
000A _raise_event: int64  push(sp, r16, 0x16)
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x1001C8
000B              int64   r16 = address([_main+0xFFFFFFD0])
                  0x100
000D              int32   r17 = move(0x0)
                  0x0
000F              int64   r18 = address([_main])
                  0x130
0011              int64   r19 = move(r0)
                  0x100000000
0012              int64   r20 = move(r1)
                  0x0
0013              int64   r21 = move(r2)
                  0x0
0014              int64   r22 = move(r3)
                  0x0
0015              int32   compare(r17, 0), jump_sbeloweq @_003
                  jump
0021 @_003:       int64   pop(sp, r16, 0x16)
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x100200
0022                      return
                  0x0
0029              int64   r0 = move(r16)
                  0x0
002A              int64   r1 = move(r17)
                  0x0
002B              int64   r2 = move(r18)
                  0x0
002C                      call _main
0000 _main:       int64   r0 = address([_main+0xFFFFFFD0])
                  0x100
0002                      call _puts
0006 _puts:               sys_call(sp, sp, 0x1, 0x101)
                  system call: puts
0008                      return
                  0x0
0003              int32   r0 = move(0)
                  0x0
0004                      return
                  0x0
002D              int64   r16 = move(r0)
                  0x0
002E              int64   r0 = move(0x1 << 33)
                  0x200000000
002F                      call _raise_event
000A _raise_event: int64  push(sp, r16, 0x16)
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x1001C8
000B              int64   r16 = address([_main+0xFFFFFFD0])
                  0x100
000D              int32   r17 = move(0x0)
                  0x0
000F              int64   r18 = address([_main])
                  0x130
0011              int64   r19 = move(r0)
                  0x200000000
0012              int64   r20 = move(r1)
                  0x0
0013              int64   r21 = move(r2)
                  0x0
0014              int64   r22 = move(r3)
                  0x0
0015              int32   compare(r17, 0), jump_sbeloweq @_003
                  jump
0021 @_003:       int64   pop(sp, r16, 0x16)
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x0
                  0x100200
0022                      return
                  0x0
0030              int64   r0 = move(r16)
                  0x0
0031                      sys_call(0x1, 0x10)
                  system call: exit
❯ ./make_example.sh calculator

Assembling calculator.as to calculator.ob

Linking file calculator.ex

Error 320: Unresolved external symbol _print_string in module calculator.obAdding object files: calculator.ob
AgnerF commented 4 months ago

I have never tried to compile this on an ARM platform. I am happy that it actually works.

Error: Cannot control floating point exceptions and rounding mode on this platform

This means that it doesn't know how to control floating point exceptions on the ARM platform. You can ignore this as long as you are not working with floating point exceptions.

Error 320: Unresolved external symbol _print_string in module calculator.ob

You are missing the library libc_light.li or libc.li

ego commented 4 months ago
FILE=calculator
./forw -ass $FILE.as
./forw -link $FILE.ex $FILE.ob libc.li libc_light.li math.li
./forw -emu $FILE.ex -list=out.txt
Screenshot 2024-06-29 at 09 51 44

🤩

AgnerF commented 4 months ago

So it works