Home | History | Annotate | Download | only in tests
      1 	;; rdtmain - main part of test program for RDX execution.
      2 	;; returns true (0) if its parameter equals the phrase "hello"
      3 	;; "hello" is stored in the library part, to complicate the
      4 	;; linkage.
      5 
      6 	;; assemble and link with the following commands:
      7 	;; nasm -f rdf rdtmain.asm
      8 	;; nasm -f rdf rdtlib.asm
      9 	;; ldrdf rdtmain.rdf rdtlib.rdf -o rdxtest.rdx
     10 
     11 	;; run with 'rdx rdxtest.rdx [parameters]' on a Linux (or possibly
     12 	;; other 32 bit OS) systems (x86 architectures only!)
     13 	;; try using '&& echo Yes' afterwards to find out when it returns 0.
     14 	
     15 [EXTERN _strcmp]		; strcmp is an imported function
     16 [EXTERN _message]		; imported data
     17 [SECTION .text]
     18 [BITS 32]
     19 
     20 	;; main(int argc,char **argv)
     21 [GLOBAL _main]
     22 _main:
     23 	push ebp
     24 	mov ebp,esp
     25 
     26 	;; ebp+8 = argc, ebp+12 = argv
     27 
     28 	cmp dword [ebp+8],2
     29 	jb error		; cause error if < 1 parameters
     30 
     31 	mov eax, [ebp+12]	; eax = argv
     32 
     33 	mov ebx, [eax+4]	; ebx = argv[1]
     34 	mov ecx, _message	; ecx = "hello"
     35 
     36 	push ecx
     37 	push ebx
     38 	call _strcmp		; compare strings
     39 	add esp,8		; caller clears stack
     40 	
     41 	pop ebp
     42 	ret			; return return value of _strcmp
     43 	
     44 error:
     45 	mov eax,2		; return 2 on error
     46 	pop ebp
     47 	ret
     48