Results 1 to 2 of 2

Thread: Printing a number

  1. #1
    ChimpFace9000
    Guest

    Post

    I have a number contained in the variable FileSize, and its a word. How do i print out the decimal equivelent?

  2. #2
    Junior Member
    Join Date
    Jun 2000
    Posts
    28
    just keep dividing by 10 and saving dx
    then add 48 to turn it into a decimal

    eg
    printnum:
    mov ax,filesize
    xor cx,cx ;zero counter
    mov bx,10 ;decimal

    l1:
    xor dx,dx ;prepare for division
    div bx
    inc cx ;+1 digits
    add dl,48 ;convert to ascii digit
    or ax,ax ;anything left?
    push dx ;save digit
    jnz l1 ;get next digit

    mov di,seg string ;or: push ds pop es etc
    mov es,di
    mov di,offset string ;es:di = string
    cld

    l2:
    pop ax ;get digit
    stosb ;store it in string
    loop l2 ;get next one

    xor ax,ax OR mov ax,"$" ;terminate string
    stosb
    ret

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width