summaryrefslogtreecommitdiff
path: root/other/wrez/lime-interface-test.c
diff options
context:
space:
mode:
authorRoot THC2026-02-24 12:42:47 +0000
committerRoot THC2026-02-24 12:42:47 +0000
commitc9cbeced5b3f2bdd7407e29c0811e65954132540 (patch)
treeaefc355416b561111819de159ccbd86c3004cf88 /other/wrez/lime-interface-test.c
parent073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff)
initial
Diffstat (limited to 'other/wrez/lime-interface-test.c')
-rw-r--r--other/wrez/lime-interface-test.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/other/wrez/lime-interface-test.c b/other/wrez/lime-interface-test.c
new file mode 100644
index 0000000..e9ad669
--- /dev/null
+++ b/other/wrez/lime-interface-test.c
@@ -0,0 +1,69 @@
1/* small test program for the lime c interface
2 */
3
4#include "int80.h"
5#include "lime-interface.h"
6
7
8static unsigned long helloworld (void);
9
10
11int
12main (int argc, char *argv[])
13{
14 void (* code_f)(void);
15 unsigned int code_len;
16 unsigned char code[4096 + 128];
17 unsigned long addr;
18 int n;
19
20
21 for (n = 0 ; n < sizeof (code) ; ++n)
22 code[n] = 0x00;
23
24 write (2, "plain: ", 6);
25 addr = helloworld ();
26
27 code_len = lime_generate ((void *) addr,
28 50,
29 &code[0], (unsigned long int) &code[0]);
30
31 write (2, "limed\n", 6);
32 code_f = (void (*)(void)) &code[0];
33 code_f ();
34
35 return (0);
36}
37
38
39static unsigned long
40helloworld (void)
41{
42 unsigned long address;
43
44 __asm__ __volatile__ ("
45 .global tlab0
46 .global tlab3
47 call tlab4
48 tlab4: popl %%eax
49 addl $(tlab0 - tlab4), %%eax
50 jmp tlab3
51
52 tlab0: pushf
53 pusha
54 movl $0x4, %%eax
55 movl $0x2, %%ebx
56 movl $12, %%edx
57 call tlab1
58 .asciz \"hello world\\n\"
59 tlab1: popl %%ecx
60 int $0x80
61 tlab2: popa
62 popf
63 ret
64 tlab3: nop"
65 : "=a" (address) : : "%ebx", "%ecx", "%edx");
66
67 return (address);
68}
69