From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../ARM202U/EXAMPLES/BASICASM/JUMP.S | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S (limited to 'Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S') diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S new file mode 100644 index 0000000..fbcb4eb --- /dev/null +++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S @@ -0,0 +1,40 @@ + AREA ArithGate, CODE ; name this block of code + ENTRY ; mark the first instruction to call +main + MOV r0, #2 ; set up three parameters + MOV r1, #5 + MOV r2, #15 + BL arithfunc ; call the function + SWI 0x11 ; terminate + +arithfunc ; label the function + CMP r0, #4 ; Treat code as unsigned integer + BHI ReturnA1 ; If code > 4 then return first + ; argument + ADR r3, JumpTable ; Load address of the jump table + LDR pc,[r3,r0,LSL #2] ; Jump to appropriate routine + +JumpTable + DCD ReturnA1 + DCD ReturnA2 + DCD DoAdd + DCD DoSub + DCD DoRsb + +ReturnA1 + MOV r0, r1 ; Operation 0, >4 + MOV pc,lr +ReturnA2 + MOV r0, r2 ; Operation 1 + MOV pc,lr +DoAdd + ADD r0, r1, r2 ; Operation 2 + MOV pc,lr +DoSub + SUB r0, r1, r2 ; Operation 3 + MOV pc,lr +DoRsb + RSB r0, r1, r2 ; Operation 4 + MOV pc,lr + + END ; mark the end of this file -- cgit v1.2.3