; ; Test basic instruction set. ; ; To run tests: ; ; $ ./build/ano tests/t_basic_set.ano > engine/dsl_ano.h ; $ make ; $ ./tests/01_run_tests.sh whatever_binary_make_produces basic ; ; @ANO_SCRIPT_NAME test_basic_inst ; @ANO_SCRIPT_VERSION 0.0.1 ; @ANO_SCRIPT_DESCRIPTION Test basic instruction set ; ; @ANO_FLAGS_VAR_NAME_SUBS [ ] ; @ANO_FLAGS_VAR_WARN_UNUSED [ ] ; ; Copyright (c) 2016-2024, Jani Salonen ; All rights reserved. ; mov t_color (# 0x11, 0x22, 0x33, 0x44) mov t_point (& 1.1, 2.2, 3.3) ; var ; call "t_var" ("var") ; abs ; mov a (-1.0) call "t_abs" ("abs", a) ; add ; mov a (1.0) mov b (2.0) call "t_add" ("add", a, b) mov a (t_color) call "t_add_color" ("add_color", a, b) mov a (t_point) call "t_add_point" ("add_point", a, b); ; call ; mov a ("t_call") call a ("call") call "t_call" ("call") ; cmp ; mov a (1.0) mov b (1.0) call "t_cmp" ("cmp", a, b) call "t_cmp" ("cmp", 2.0, b) call "t_cmp" ("cmp", a, 2.0) ; dec ; mov a (1.0) call "t_dec" ("dec", a) mov a (t_color) call "t_dec_color" ("dec_color", a) mov a (t_point) call "t_dec_point" ("dec_point", a); ; div ; mov a (4.0) mov b (2.0) call "t_div" ("div", a, b) mov a (t_color) call "t_div_color" ("div_color", a, b) mov a (t_point) call "t_div_point" ("div_point", a, b); ; end ; ;mov a ([int] 1) ;end a ;end 1 ; inc ; mov a (1.0) call "t_inc" ("inc", a) mov a (t_color) call "t_inc_color" ("inc_color", a) mov a (t_point) call "t_inc_point" ("inc_point", a); ; label or : ; mod ; mov a (2.0) mov b (4.0) call "t_mod" ("mod", a, b) mov a (t_color) call "t_mod_color" ("mod_color", a, b) mov a (t_point) call "t_mod_point" ("mod_point", a, b); ; mov ; mul ; mov a (2.0) mov b (4.0) call "t_mul" ("mul", a, b) mov a (t_color) call "t_mul_color" ("mul_color", a, b) mov a (t_point) call "t_mul_point" ("mul_point", a, b); ; neg ; mov a (1.0) call "t_neg" ("neg", a) mov a (t_color) call "t_neg_color" ("neg_color", a) mov a (t_point) call "t_neg_point" ("neg_point", a); ; not ; mov a ([uint64] 1) call "t_not" ("not", a) mov a (t_color) call "t_not_color" ("not_color", a) mov a (t_point) call "t_not_point" ("not_point", a); ; pow ; mov a (2.0) mov b (4.0) call "t_pow" ("pow", a, b) mov a (t_color) call "t_pow_color" ("pow_color", a, b) mov a (t_point) call "t_pow_point" ("pow_point", a, b); ; rand ; ; mov a (0) ; mov b (100.0) ; call "t_rand" ("rand", a, b) ; mov a (t_color) ; call "t_rand_color" ("rand_color", a, b) ; mov a (t_point) ; call "t_rand_point" ("rand_point", a, b); ; ret ; mov a (1.0) call "r_ret" ("ret", a) dump rc ; sub ; mov a (2.0) mov b (1.0) call "t_sub" ("sub", a, b) mov a (t_color) call "t_sub_color" ("sub_color", a, b) mov a (t_point) call "t_sub_point" ("sub_point", a, b); ; and ; mov a ([uint64] 1) mov b ([uint64] 255) call "t_and" ("and", a, b) mov a (t_color) call "t_and_color" ("and_color", a, b) mov a (t_point) call "t_and_point" ("and_point", a, b); ; or ; mov a ([uint64] 1) mov b ([uint64] 2) call "t_or" ("or", a, b) mov a (t_color) call "t_or_color" ("or_color", a, b) mov a (t_point) call "t_or_point" ("or_point", a, b); ; xor ; mov a ([uint64] 1) mov b ([uint64] 255) call "t_xor" ("xor", a, b) mov a (t_color) call "t_xor_color" ("xor_color", a, b) mov a (t_point) call "t_xor_point" ("xor_point", a, b); ; test ; mov a ([uint64] 1.0) mov b ([uint64] 2.0) call "t_test" ("test", a, b) mov a (t_color) call "t_test_color" ("test_color", a, b) mov a (t_point) call "t_test_point" ("test_point", a, b); ; crc mov a ([uint64] 0) mov b (1.0) call "t_crc" ("crc", a, b) mov b (t_color) call "t_crc_color" ("crc_color", a, b) mov b (t_point) call "t_crc_point" ("crc_point", a, b); ; func ; exit function t_var (_msg) { dump _msg var [number] _va dump _va var [string] _vb dump _vb var [blob] _vc dump _vc var [pointer] _vd dump _vd var [handle] _ve dump _ve var [color] _vf dump _vf var [image] _vg dump _vg var [point] _vh dump _vh } function t_abs (_msg, _a) { dump _msg abs _a dump _a } function t_add (_msg, _a, _b) { dump _msg add _a (_b) dump _a } function t_add_color (_msg, _a, _b) { dump _msg add _a.red (_b) dump _a.red add _a.green (_b) dump _a.green add _a.blue (_b) dump _a.blue add _a.alpha (_b) dump _a.alpha dump _a.brightness add _a (_b) dump _a } function t_add_point (_msg, _a, _b) { dump _msg add _a.x (_b) dump _a.x add _a.y (_b) dump _a.y add _a.z (_b) dump _a.z add _a.angle_xy (_b) dump _a.angle_xy add _a.mag_xy (_b) dump _a.mag_xy add _a.mag_xyz (_b) dump _a.mag_xyz add _a (_b) dump _a } function t_call (_msg) { dump _msg } function t_cmp (_msg, _a, _b) { dump _msg cmp _a (_b) je "t_cmp_a" mov _msg ("_a != _b") jmp "t_cmp_b" : "t_cmp_a" mov _msg ("_a == _b") : "t_cmp_b" dump _msg } function t_dec (_msg, _a) { dump _msg dec _a dump _a } function t_dec_color (_msg, _a) { dump _msg dec _a.red dump _a.red dec _a.green dump _a.green dec _a.blue dump _a.blue dec _a.alpha dump _a.alpha dump _a.brightness dec _a dump _a } function t_dec_point (_msg, _a) { dump _msg dec _a.x dump _a.x dec _a.y dump _a.y dec _a.z dump _a.z dec _a.angle_xy dump _a.angle_xy dec _a.mag_xy dump _a.mag_xy dec _a.mag_xyz dump _a.mag_xyz dec _a dump _a } function t_div (_msg, _a, _b) { dump _msg div _a (_b) dump _a } function t_div_color (_msg, _a, _b) { dump _msg div _a.red (_b) dump _a.red div _a.green (_b) dump _a.green div _a.blue (_b) dump _a.blue div _a.alpha (_b) dump _a.alpha dump _a.brightness div _a (_b) dump _a } function t_div_point (_msg, _a, _b) { dump _msg div _a.x (_b) dump _a.x div _a.y (_b) dump _a.y div _a.z (_b) dump _a.z div _a.angle_xy (_b) dump _a.angle_xy div _a.mag_xy (_b) dump _a.mag_xy div _a.mag_xyz (_b) dump _a.mag_xyz div _a (_b) dump _a } function t_inc (_msg, _a) { dump _msg inc _a dump _a } function t_inc_color (_msg, _a) { dump _msg inc _a.red dump _a.red inc _a.green dump _a.green inc _a.blue dump _a.blue inc _a.alpha dump _a.alpha dump _a.brightness inc _a dump _a } function t_inc_point (_msg, _a) { dump _msg inc _a.x dump _a.x inc _a.y dump _a.y inc _a.z dump _a.z inc _a.angle_xy dump _a.angle_xy inc _a.mag_xy dump _a.mag_xy inc _a.mag_xyz dump _a.mag_xyz inc _a dump _a } function t_mod (_msg, _a, _b) { dump _msg mod _a (_b) dump _a } function t_mod_color (_msg, _a, _b) { dump _msg mod _a.red (_b) dump _a.red mod _a.green (_b) dump _a.green mod _a.blue (_b) dump _a.blue mod _a.alpha (_b) dump _a.alpha dump _a.brightness mod _a (_b) dump _a } function t_mod_point (_msg, _a, _b) { dump _msg mod _a.x (_b) dump _a.x mod _a.y (_b) dump _a.y mod _a.z (_b) dump _a.z mod _a.angle_xy (_b) dump _a.angle_xy mod _a.mag_xy (_b) dump _a.mag_xy mod _a.mag_xyz (_b) dump _a.mag_xyz mod _a (_b) dump _a } function t_mul (_msg, _a, _b) { dump _msg mul _a (_b) dump _a } function t_mul_color (_msg, _a, _b) { dump _msg mul _a.red (_b) dump _a.red mul _a.green (_b) dump _a.green mul _a.blue (_b) dump _a.blue mul _a.alpha (_b) dump _a.alpha dump _a.brightness mul _a (_b) dump _a } function t_mul_point (_msg, _a, _b) { dump _msg mul _a.x (_b) dump _a.x mul _a.y (_b) dump _a.y mul _a.z (_b) dump _a.z mul _a.angle_xy (_b) dump _a.angle_xy mul _a.mag_xy (_b) dump _a.mag_xy mul _a.mag_xyz (_b) dump _a.mag_xyz mul _a (_b) dump _a } function t_neg (_msg, _a) { dump _msg neg _a dump _a } function t_neg_color (_msg, _a) { dump _msg neg _a.red dump _a.red neg _a.green dump _a.green neg _a.blue dump _a.blue neg _a.alpha dump _a.alpha dump _a.brightness neg _a dump _a } function t_neg_point (_msg, _a) { dump _msg neg _a.x dump _a.x neg _a.y dump _a.y neg _a.z dump _a.z neg _a.angle_xy dump _a.angle_xy neg _a.mag_xy dump _a.mag_xy neg _a.mag_xyz dump _a.mag_xyz neg _a dump _a } function t_not (_msg, _a) { dump _msg not _a dump _a } function t_not_color (_msg, _a) { dump _msg not _a.red dump _a.red not _a.green dump _a.green not _a.blue dump _a.blue not _a.alpha dump _a.alpha dump _a.brightness not _a dump _a } function t_not_point (_msg, _a) { dump _msg not _a.x dump _a.x not _a.y dump _a.y not _a.z dump _a.z not _a.angle_xy dump _a.angle_xy not _a.mag_xy dump _a.mag_xy not _a.mag_xyz dump _a.mag_xyz not _a dump _a } function t_pow (_msg, _a, _b) { dump _msg pow _a (_b) dump _a } function t_pow_color (_msg, _a, _b) { dump _msg pow _a.red (_b) dump _a.red pow _a.green (_b) dump _a.green pow _a.blue (_b) dump _a.blue pow _a.alpha (_b) dump _a.alpha dump _a.brightness pow _a (_b) dump _a } function t_pow_point (_msg, _a, _b) { dump _msg pow _a.x (_b) dump _a.x pow _a.y (_b) dump _a.y pow _a.z (_b) dump _a.z pow _a.angle_xy (_b) dump _a.angle_xy pow _a.mag_xy (_b) dump _a.mag_xy pow _a.mag_xyz (_b) dump _a.mag_xyz pow _a (_b) dump _a } function t_rand (_msg, _a, _b) { dump _msg rand _a (_b) dump _a } function t_rand_color (_msg, _a, _b) { dump _msg rand _a.red (_b) dump _a.red rand _a.green (_b) dump _a.green rand _a.blue (_b) dump _a.blue rand _a.alpha (_b) dump _a.alpha dump _a.brightness rand _a (_b) dump _a } function t_rand_point (_msg, _a, _b) { dump _msg rand _a.x (_b) dump _a.x rand _a.y (_b) dump _a.y rand _a.z (_b) dump _a.z rand _a.angle_xy (_b) dump _a.angle_xy rand _a.mag_xy (_b) dump _a.mag_xy rand _a.mag_xyz (_b) dump _a.mag_xyz rand _a (_b) dump _a } function r_ret (_msg, _a) { dump _msg ret _a } function t_sub (_msg, _a, _b) { dump _msg sub _a (_b) dump _a } function t_sub_color (_msg, _a, _b) { dump _msg sub _a.red (_b) dump _a.red sub _a.green (_b) dump _a.green sub _a.blue (_b) dump _a.blue sub _a.alpha (_b) dump _a.alpha dump _a.brightness sub _a (_b) dump _a } function t_sub_point (_msg, _a, _b) { dump _msg sub _a.x (_b) dump _a.x sub _a.y (_b) dump _a.y sub _a.z (_b) dump _a.z sub _a.angle_xy (_b) dump _a.angle_xy sub _a.mag_xy (_b) dump _a.mag_xy sub _a.mag_xyz (_b) dump _a.mag_xyz sub _a (_b) dump _a } function t_and (_msg, _a, _b) { dump _msg and _a (_b) dump _a } function t_and_color (_msg, _a, _b) { dump _msg and _a.red (_b) dump _a.red and _a.green (_b) dump _a.green and _a.blue (_b) dump _a.blue and _a.alpha (_b) dump _a.alpha dump _a.brightness and _a (_b) dump _a } function t_and_point (_msg, _a, _b) { dump _msg and _a.x (_b) dump _a.x and _a.y (_b) dump _a.y and _a.z (_b) dump _a.z and _a.angle_xy (_b) dump _a.angle_xy and _a.mag_xy (_b) dump _a.mag_xy and _a.mag_xyz (_b) dump _a.mag_xyz and _a (_b) dump _a } function t_or (_msg, _a, _b) { dump _msg or _a (_b) dump _a } function t_or_color (_msg, _a, _b) { dump _msg or _a.red (_b) dump _a.red or _a.green (_b) dump _a.green or _a.blue (_b) dump _a.blue or _a.alpha (_b) dump _a.alpha dump _a.brightness or _a (_b) dump _a } function t_or_point (_msg, _a, _b) { dump _msg or _a.x (_b) dump _a.x or _a.y (_b) dump _a.y or _a.z (_b) dump _a.z or _a.angle_xy (_b) dump _a.angle_xy or _a.mag_xy (_b) dump _a.mag_xy or _a.mag_xyz (_b) dump _a.mag_xyz or _a (_b) dump _a } function t_xor (_msg, _a, _b) { dump _msg xor _a (_b) dump _a } function t_xor_color (_msg, _a, _b) { dump _msg xor _a.red (_b) dump _a.red xor _a.green (_b) dump _a.green xor _a.blue (_b) dump _a.blue xor _a.alpha (_b) dump _a.alpha dump _a.brightness xor _a (_b) dump _a } function t_xor_point (_msg, _a, _b) { dump _msg xor _a.x (_b) dump _a.x xor _a.y (_b) dump _a.y xor _a.z (_b) dump _a.z xor _a.angle_xy (_b) dump _a.angle_xy xor _a.mag_xy (_b) dump _a.mag_xy xor _a.mag_xyz (_b) dump _a.mag_xyz xor _a (_b) dump _a } function t_test (_msg, _a, _b) { dump _msg test _a (_b) dump _a } function t_test_color (_msg, _a, _b) { dump _msg test _a.red (_b) dump _a.red test _a.green (_b) dump _a.green test _a.blue (_b) dump _a.blue test _a.alpha (_b) dump _a.alpha dump _a.brightness test _a (_b) dump _a } function t_test_point (_msg, _a, _b) { dump _msg test _a.x (_b) dump _a.x test _a.y (_b) dump _a.y test _a.z (_b) dump _a.z test _a.angle_xy (_b) dump _a.angle_xy test _a.mag_xy (_b) dump _a.mag_xy test _a.mag_xyz (_b) dump _a.mag_xyz test _a (_b) dump _a } function t_crc (_msg, _a, _b) { dump _msg crc32 _a (_b) dump _a crc64 _a (_b) dump _a } function t_crc_color (_msg, _a, _b) { dump _msg crc32 _a (_b) dump _a crc64 _a (_b) dump _a } function t_crc_point (_msg, _a, _b) { dump _msg crc32 _a (_b) dump _a crc64 _a (_b) dump _a }