datasg segment para'code' msg1 db 'enter a number:',"$" msg2 db 'the log of this number is:',"$" count db 0 sign dw ? string db 6 dup( ' '),"$" sign1 db ? number dw ? strlist label byte max db 20 len db ? buffer db 20 dup(' ') dolar db '$' datasg ends codesg segment para 'code' main proc far assume ds:datasg,cs:codesg mov ax,datasg mov ds,ax mov ah,6h mov al,25 mov ch,0 mov cl,0 mov dh,24 mov dl,79 mov bh,7 int 10h mov ah,2h mov dh,10 mov dl,30 mov bh,0 int 10h lea dx,msg1 mov ah,9h int 21h mov ah,0ah lea dx,strlist int 21h lea bx,buffer while_blank:cmp byte ptr[bx],' ' jne end_while_blank inc bx jmp while_blank end_while_blank: mov sign,1 cmp byte ptr[bx],'+' je skip_sign cmp byte ptr[bx],'_' jne save_sign mov sign,-1 skip_sign: inc bx save_sign: mov ax,0 mov count,0 while_digit: cmp byte ptr [bx],'0' jl end_while_digit cmp byte ptr [bx],'9' jg end_while_digit mov cx,10 mul cx mov cl,[bx] and cx,000fh add ax,cx inc count inc bx jmp while_digit end_while_digit: imul sign ;;;;;;;;;;;compute log;;;;;;;;;;; mov number,ax mov cx,0 mov ax,1 lopwhile: cmp ax,number jnle end_while add ax,ax inc cx jmp lopwhile end_while: dec cx mov ax,cx ;;;;;;;;;;;convert number in ax to string;;;;;;; lea bx,string add bx,5 mov sign,' ' cmp ax,0 jge setup mov sign1,'-' neg ax setup: mov cx,10 divloop: mov dx,0 div cx add dl,30h mov [bx],dl dec bx cmp ax,0 jne divloop mov cl,sign1 mov [bx],cl ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov ah,2h mov dh,12 mov dl,30 mov bh,0 int 10h ;print result lea dx,msg2 mov ah,9h int 21h lea dx,string mov ah,9h int 21h ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov ax,4c00h int 21h main endp codesg ends end main