diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S')
| -rw-r--r-- | Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/BASICASM/JUMP.S | 40 |
1 files changed, 40 insertions, 0 deletions
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
|
