From 4a6784862771854644bf9de5080d05de311043e2 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 10 Nov 2019 11:22:16 +0000 Subject: [PATCH] Add CALL/RET example --- examples/call_ret.mima | Bin 0 -> 36 bytes examples/call_ret.mimasm | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 examples/call_ret.mima create mode 100644 examples/call_ret.mimasm diff --git a/examples/call_ret.mima b/examples/call_ret.mima new file mode 100644 index 0000000000000000000000000000000000000000..b18cb357af75163f2cd951cfef438dbc5d55e5e0 GIT binary patch literal 36 ccmZR;0KXU*4=}L)Vqp2e!0?N~=raQY06P{1&Hw-a literal 0 HcmV?d00001 diff --git a/examples/call_ret.mimasm b/examples/call_ret.mimasm new file mode 100644 index 0000000..1e68770 --- /dev/null +++ b/examples/call_ret.mimasm @@ -0,0 +1,18 @@ +IAR = main +ACC = 0 +RA = 0 + +; This CALL/RET example does not use any sort of stack, and thus can +; only go 1 call deep. Nevertheless, it demonstrates how the CALL and +; RET instructions behave. + +main: + LDC 0 + ADC 1 + CALL sub ; Sets the RA to the next address (in this case, ADC 4) + ADC 4 + HALT + +sub: + ADC 50 + RET ; Jumps to the ADC 4