.text

.global _start
_start:
	/* Implement the for loop in the Java code */
	movl $0, %ecx        /* Initialize ecx to zero */
	
forLoop:	
	cmpb $0, str(%ecx)     /* is str[ecx] == 0?  */
	jz   endFor            /* If it is zero goto end of for loop */
	xor  $32, str(%ecx)    /* str[ecx] ^= 32 */
	inc  %ecx              /* ecx++ */
	jmp  forLoop
	
endFor:
        movl %ecx, strLen     /* Set string length */

        /* Display str i.e., System.out.print(str) */
        mov $4, %eax         /* System call to write to a file handle */
        mov $1, %ebx         /* File handle=1 implies standard output */
        mov $str, %ecx       /* Address of message to be displayed    */
        mov strLen, %edx     /* Number of characters to be  displayed */
        int $0x80            /* Call OS to display the characters.    */

	/* Display new line .ie. System.out.print("\n") */
        mov $4, %eax         /* System call to write to a file handle */
        mov $1, %ebx         /* File handle=1 implies standard output */
        mov $newLine, %ecx   /* Address of message to be displayed    */
        mov $1, %edx         /* Number of characters to be  displayed */
        int $0x80            /* Call OS to display the characters.    */

        /* System.exit(0) */
        mov $1,%eax          /* The system call for exit (sys_exit)   */
        mov $0,%ebx          /* Exit with return code of 0 (no error) */
        int  $0x80

.data
/* The string to be manipulated and displayed */
str:	 .string "HelloWorld"  /* Trailing '\0' is atuomatically added */
newLine: .string "\n" /* New line character */
strLen: .int 0

