1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-05 16:26:17 +00:00
janet/examples/sysdialect_asm.janet

37 lines
700 B
Plaintext
Raw Normal View History

2023-05-12 23:10:52 +00:00
(def ir-asm
@{:instructions
'(
# Types
(type-prim Int s32)
(type-prim Double f64)
(type-struct MyPair 0 1)
(type-pointer PInt 0)
(type-array DoubleArray 1 1024)
# Declarations
(bind 0 Int)
(bind 1 Int)
(bind 2 Int)
(bind 3 Double)
(bind bob Double)
(bind 5 Double)
(bind 6 MyPair)
# Code
2023-08-06 20:50:42 +00:00
(constant 0 10)
(constant 0 21)
2023-08-07 14:10:15 +00:00
:location
(add 2 1 0)
2023-08-06 20:50:42 +00:00
(constant 3 1.77)
(call 3 sin 3)
(cast bob 2)
(call bob test_function)
(add 5 bob 3)
2023-08-07 14:10:15 +00:00
(jump :location)
2023-08-06 20:50:42 +00:00
(return 5))
:parameter-count 0
2023-08-07 14:10:15 +00:00
:link-name "test_function"})
2023-05-12 23:10:52 +00:00
(def as (sysir/asm ir-asm))
(print (sysir/to-c as))