I don't have an emulator handy to test this, but I think the problem is the pop ax
at the end of the function, which overwrites the return value you have put there.
Also check the way you build up the number- you are doing bx = bx + ax *10 instead of bx = bx*10 + ax.