summaryrefslogtreecommitdiffstats
path: root/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM')
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_1.C10
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_2.C7
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_3.S22
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/HALF_STR.C10
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/INT64.H9
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.H4
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.S26
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.APJbin0 -> 103 bytes
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.C20
-rw-r--r--Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/TWO_CH.C9
10 files changed, 117 insertions, 0 deletions
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_1.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_1.C
new file mode 100644
index 0000000..9a7744f
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_1.C
@@ -0,0 +1,10 @@
+#include "int64.h"
+
+void add_64(int64 *dest, int64 *src1, int64 *src2)
+{ unsigned hibit1=src1->lo >> 31, hibit2=src2->lo >> 31, hibit3;
+ dest->lo=src1->lo + src2->lo;
+ hibit3=dest->lo >> 31;
+ dest->hi=src1->hi + src2->hi +
+ ((hibit1 & hibit2) || (hibit1!= hibit3));
+ return;
+}
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_2.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_2.C
new file mode 100644
index 0000000..96735fb
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_2.C
@@ -0,0 +1,7 @@
+#include "int64.h"
+
+void add_64(int64 *dest, int64 *src1, int64 *src2)
+{ dest->lo=src1->lo + src2->lo;
+ dest->hi=src1->hi + src2->hi;
+ return;
+}
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_3.S b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_3.S
new file mode 100644
index 0000000..17a0f36
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/ADD64_3.S
@@ -0,0 +1,22 @@
+; generated by Norcroft ARM C vsn 4.41 (Advanced RISC Machines) [Aug 26 1992]
+
+ AREA |C$$code|, CODE, READONLY
+|x$codeseg|
+
+ EXPORT add_64
+add_64
+ LDR a4,[a2,#0]
+ LDR ip,[a3,#0]
+ ADDS a4,a4,ip
+ STR a4,[a1,#0]
+ LDR a2,[a2,#4]
+ LDR a3,[a3,#4]
+ ADC a2,a2,a3
+ STR a2,[a1,#4]
+ MOV pc,lr
+
+ AREA |C$$data|,DATA
+
+|x$dataseg|
+
+ END
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/HALF_STR.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/HALF_STR.C
new file mode 100644
index 0000000..0f00e81
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/HALF_STR.C
@@ -0,0 +1,10 @@
+typedef struct half_words_struct
+{ unsigned field1:16;
+ unsigned field2:16;
+} half_words;
+
+half_words max( half_words a, half_words b )
+{ half_words x;
+ x= (a.field1>b.field1) ? a : b;
+ return x;
+}
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/INT64.H b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/INT64.H
new file mode 100644
index 0000000..0b017f4
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/INT64.H
@@ -0,0 +1,9 @@
+#ifndef __int64_h
+#define __int64_h
+
+typedef struct int64_struct {
+ unsigned int lo;
+ unsigned int hi;
+} int64;
+
+#endif
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.H b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.H
new file mode 100644
index 0000000..6d4135e
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.H
@@ -0,0 +1,4 @@
+/* Declaration of mul64, specifying that the int64 */
+#include "int64.h"
+
+__value_in_regs extern int64 mul64(unsigned a, unsigned b);
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.S b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.S
new file mode 100644
index 0000000..1b4beb6
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MUL64.S
@@ -0,0 +1,26 @@
+; 32-bit by 32-bit multiplication routine for use with C
+
+ AREA |mul64$$code|, CODE, READONLY
+
+|x$codeseg|
+
+ EXPORT mul64
+
+; On entry a1 and a2 contain the 32-bit integers to be multiplied (a, b)
+; On exit a1 and a2 contain the result (a1 bits 0-31, a2 bits 32-63)
+mul64
+ MOV ip, a1, LSR #16 ; ip = a_hi
+ MOV a4, a2, LSR #16 ; a4 = b_hi
+ BIC a1, a1, ip, LSL #16 ; a1 = a_lo
+ BIC a2, a2, a4, LSL #16 ; a2 = b_lo
+ MUL a3, a1, a2 ; a3 = a_lo * b_lo (m_lo)
+ MUL a2, ip, a2 ; a2 = a_hi * b_lo (m_mid1)
+ MUL a1, a4, a1 ; a1 = a_lo * b_hi (m_mid2)
+ MUL a4, ip, a4 ; a4 = a_hi * b_hi (m_hi)
+ ADDS ip, a2, a1 ; ip = m_mid1 + m_mid2 (m_mid)
+ ADDCS a4, a4, #&10000 ; a4 = m_hi + carry (m_hi')
+ ADDS a1, a3, ip, LSL #16 ; a1 = m_lo + (m_mid<<16)
+ ADC a2, a4, ip, LSR #16 ; a2 = m_hi' + (m_mid>>16) + carry
+ MOV pc, lr
+
+ END
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.APJ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.APJ
new file mode 100644
index 0000000..ce0107e
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.APJ
Binary files differ
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.C
new file mode 100644
index 0000000..5dc30e6
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/MULTEST.C
@@ -0,0 +1,20 @@
+/* Demonstrate mul64 */
+
+#include <stdio.h>
+#include "int64.h"
+#include "mul64.h"
+
+int main()
+{ int64 res;
+ unsigned a,b;
+
+ printf( "Enter two unsigned 32-bit numbers in hex eg.(100 FF43D)\n" );
+ if( scanf( "%x %x", &a, &b ) != 2 )
+ { puts( "Bad numbers" );
+ } else
+ { res=mul64(a,b);
+ printf( "Least significant word of result is %8X\n", res.lo );
+ printf( "Most significant word of result is %8X\n", res.hi );
+ }
+ return( 0 );
+}
diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/TWO_CH.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/TWO_CH.C
new file mode 100644
index 0000000..9f4c72f
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CANDASM/TWO_CH.C
@@ -0,0 +1,9 @@
+typedef struct two_ch_struct
+{ char ch1;
+ char ch2;
+} two_ch;
+
+two_ch max( two_ch a, two_ch b )
+{
+ return (a.ch1>b.ch1) ? a : b;
+}