forked from AbleOS/ableos
examples
This commit is contained in:
parent
42be580425
commit
e7aa306e5d
12
hbasm/assets/add.hbasm
Normal file
12
hbasm/assets/add.hbasm
Normal file
|
@ -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
|
16
hbasm/assets/celsius_converter.hbasm
Normal file
16
hbasm/assets/celsius_converter.hbasm
Normal file
|
@ -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
|
|
@ -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
|
||||
li r255, 1
|
||||
li r254, 1
|
||||
li r253, 100
|
||||
ecall
|
||||
|
||||
li r255, 2
|
||||
li r254, 0
|
||||
li r253, 0
|
||||
ecall
|
||||
|
||||
tx
|
|
@ -1,3 +1,4 @@
|
|||
li r20, 1010
|
||||
st r20, r24, 0, 1
|
||||
addi r24, r0, 10
|
||||
addi r24, r0, 10
|
||||
tx
|
BIN
hbvm/assets/add.hb
Normal file
BIN
hbvm/assets/add.hb
Normal file
Binary file not shown.
BIN
hbvm/assets/celsius_converter.hb
Normal file
BIN
hbvm/assets/celsius_converter.hb
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue