#// function for title case, from 27 March 2012 class #// Lin Jensen for CSC 116 #void titlecase (char* str) // edx .globl titlecase .text titlecase: mov 4(%esp), %edx # string pointer #{ char c; // ah, al # int isletter, state = 0; // initial state no word found xor %eax, %eax # zero all of ax # while (c = *str) // cl for character while: movb (%edx), %cl cmp $0, %cl jz done cmp $0, %al # state jnz state1 state0: # { d = c|0x20; isletter = d >= 'a' && d <= 'z'; # if (!state && isletter) movb %cl, %ch orb $0x20, %ch cmpb $'a', %ch jl cont cmpb $'z', %ch jg cont # { state = 1; // a word is now started movb $1, %al # *str = c & 0xDF;// make first letter uppercase andb $0xDF, %cl movb %cl, (%edx) # } jmp cont # if (state==1 && c==' ') state1: cmp $0x20, %cl jne cont # state = 0; // done with a word movb $0, %al # else nothing to do # str++ ; // point to next letter cont: inc %edx # } jmp while done: ret