From dcd692405e2c1a389aa1f38d6627d9f3d17a2810 Mon Sep 17 00:00:00 2001 From: able Date: Tue, 12 Sep 2023 01:38:32 -0500 Subject: [PATCH] examples --- hbasm/assets/add.hbasm | 12 ++++++++++++ hbasm/assets/celsius_converter.hbasm | 16 ++++++++++++++++ hbasm/assets/ecall.hbasm | 23 +++++++++++++---------- hbasm/assets/memory.hbasm | 3 ++- hbvm/assets/add.hb | Bin 0 -> 48 bytes hbvm/assets/celsius_converter.hb | Bin 0 -> 70 bytes hbvm/assets/ecall.hb | Bin 112 -> 90 bytes 7 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 hbasm/assets/add.hbasm create mode 100644 hbasm/assets/celsius_converter.hbasm create mode 100644 hbvm/assets/add.hb create mode 100644 hbvm/assets/celsius_converter.hb diff --git a/hbasm/assets/add.hbasm b/hbasm/assets/add.hbasm new file mode 100644 index 0000000..b21dc5a --- /dev/null +++ b/hbasm/assets/add.hbasm @@ -0,0 +1,12 @@ +-- Add two numbers +-- A + B = C + +-- r1 A +li r1, 2 +-- r2 Result +li r2, 0 +-- B = 4 +addi r2, r1, 4 + +-- terminate execution +tx \ No newline at end of file diff --git a/hbasm/assets/celsius_converter.hbasm b/hbasm/assets/celsius_converter.hbasm new file mode 100644 index 0000000..46c6c48 --- /dev/null +++ b/hbasm/assets/celsius_converter.hbasm @@ -0,0 +1,16 @@ +-- r1 will be the temp in fahrenheit +-- r2 temp in celsius +-- r3/r4/r5 will be used by constants + +-- (f - 32) * 5 / 9 + +li r1, 100 + +li r3, 32 +li r4, 5 +li r5, 9 + +sub r2, r1, r3 +mul r2, r2, r4 +dir r2, r0, r2, r5 +tx \ No newline at end of file diff --git a/hbasm/assets/ecall.hbasm b/hbasm/assets/ecall.hbasm index 7743b53..565655d 100644 --- a/hbasm/assets/ecall.hbasm +++ b/hbasm/assets/ecall.hbasm @@ -1,11 +1,14 @@ -addi r1, r0, 1024 -addi r2, r1, 1024 -addi r3, r2, 1024 -addi r4, r3, 1024 -addi r5, r4, 1024 -addi r6, r5, 1024 -addi r7, r6, 1024 -addi r8, r7, 1024 -addi r9, r8, 1024 +li r255, 0 +ecall -ecall \ No newline at end of file +li r255, 1 +li r254, 1 +li r253, 100 +ecall + +li r255, 2 +li r254, 0 +li r253, 0 +ecall + +tx \ No newline at end of file diff --git a/hbasm/assets/memory.hbasm b/hbasm/assets/memory.hbasm index 133def5..0a31145 100644 --- a/hbasm/assets/memory.hbasm +++ b/hbasm/assets/memory.hbasm @@ -1,3 +1,4 @@ li r20, 1010 st r20, r24, 0, 1 -addi r24, r0, 10 \ No newline at end of file +addi r24, r0, 10 +tx \ No newline at end of file diff --git a/hbvm/assets/add.hb b/hbvm/assets/add.hb new file mode 100644 index 0000000000000000000000000000000000000000..321efa58b58e844add54029067e38ef2658721b7 GIT binary patch literal 48 fcmd;@j{+9} literal 0 HcmV?d00001 diff --git a/hbvm/assets/ecall.hb b/hbvm/assets/ecall.hb index 3ecd89a82ad402cc2f2d05840c3c5ee47f3b3b2e..918327121a7e679f599e215b98623f0187efefaa 100644 GIT binary patch literal 90 scmd;=jtiLG;X(qTdl))hT7sk?r=>Q7=02R0icK`qY literal 112 ycmWe&WME)n00RLgMmUq13C?6;hBH}N;7m4FIFp?X&g5W+GdVe6Obv+f5E1}Ep8+la