ASM: cpp-and-asm-a.asm global _allCaps _allCaps: mov rax, rdi ; get the pointer to the buffer from calling function / rax is the return value xor rcx, rcx ; counter=0 top: mov BYTE dl, [rax] ; mov the byte at the address in rax into dl inc rcx ; add one to the length counter xor dh, dh ; Zero out the High Bit of dx cmp dl, 0x00 ; check for end of buffer je go_back ; if we've reached a 0, return from this function and dl, 0x5F ; make the ASCII character capitol mov [rax], dl ; put the modified character back into the buffer inc rax ; point to next character jmp top ; go back to the top of the loop go_back:dec rcx ; subtract 1 from counter (becuase that last one was a 0 signifying the end of the buffer) mov rax, rcx ; since rax is what gets returned, put the counter value (rcx) into rax ret ; return from this function CPP: cpp-and-asm-c.cpp #include extern "C" int allCaps(char*); int main(int argc, char **argv) { char buf[]="hello"; printf( "Buffer: [%s]\n", buf ); allCaps(buf); printf( "Buffer: [%s]\n", buf ); printf( "Size: %d\n", allCaps(buf)); return(0); } MAKEFILE: Makefile cpp-and-asm : cpp-and-asm_a.asm nasm -f macho64 cpp-and-asm_a.asm -o $(LIB_DIR)cpp-and-asm_a.o g++ -c $(OPT) $(CPP_FLAGS) cpp-and-asm-c.cpp -o $(LIB_DIR)cpp-and-asm_c.o g++ $(LIB_DIR)cpp-and-asm-c.o $(LIB_DIR)cpp-and-asm-a.o -o $(BIN_DIR)cpp-and-asm