summaryrefslogtreecommitdiff
path: root/rdoff/test/rdtlib.asm
diff options
context:
space:
mode:
Diffstat (limited to 'rdoff/test/rdtlib.asm')
-rw-r--r--rdoff/test/rdtlib.asm48
1 files changed, 48 insertions, 0 deletions
diff --git a/rdoff/test/rdtlib.asm b/rdoff/test/rdtlib.asm
new file mode 100644
index 0000000..6c2b8ec
--- /dev/null
+++ b/rdoff/test/rdtlib.asm
@@ -0,0 +1,48 @@
+ ;; library functions for rdtmain - test of rdx linking and execution
+
+ ;; library function = _strcmp, defined as in C
+
+[SECTION .text]
+[BITS 32]
+
+[GLOBAL _strcmp]
+_strcmp:
+ push ebp
+ mov ebp,esp
+
+ ;; ebp+8 = first paramater, ebp+12 = second
+
+ mov esi,[ebp+8]
+ mov edi,[ebp+12]
+
+.loop:
+ mov cl,byte [esi]
+ mov dl,byte [edi]
+ cmp cl,dl
+ jb .below
+ ja .above
+ or cl,cl
+ jz .match
+ inc esi
+ inc edi
+ jmp .loop
+
+.below:
+ mov eax,-1
+ pop ebp
+ ret
+
+.above:
+ mov eax,1
+ pop ebp
+ ret
+
+.match:
+ xor eax,eax
+ pop ebp
+ ret
+
+[SECTION .data]
+[GLOBAL _message]
+
+_message: db 'hello',0 \ No newline at end of file