R&R 0 Newbie Poster

Can you tell me what needs to be changed in the program in order to run? Thank you.

.model small
.386
.stack 100h
.data
.code


decimal                  proc            near

;print out number given in AX in decimal

                  xor            eax,eax
                  xor            ebx,ebx
                  mov            cx,2            ;this is to accept the base and the decimal value
                  
newchar:            
                  cmp            cx,0
                  jle            startConvert
                  dec            cx
                  mov            ah,1            ;This sets up to accept another input from keyboard
                  int            21h            ;this asks for an input and stores it in al
                  
                  ;mov            al,0h            ;This sets up to accept another input from keyboard
                  ;int            21h            ;this asks for an input and stores it in al
                  ;push            ax            ;stores the second input from keyboard
                  
                  
                  
                  sub            al,30h
                  jl            stloop            ;jumps if negative
                  cmp            al,9h
                  jg            stloop            ;jumps if greater than
                  
                  xor            ah,ah            ;to get only the digit they type
                  push            ax            ;this stores the first input from the keyboard
                  
                  cbw                        ;convert byte to word
                  ;jmp            newchar            ;to accept multiple digits

stloop:                  
                  mov            ah,2
                  mov            dl,0ah
                  int            21h            ;This section inserts a carrige return
                  mov            dl,0dh
                  int            21h
                  
                  
startConvert:            pop            bx
                  push            ax            ;given to routine to print out
                  ;push            bx
                  push            cx
                  push            dx
                  
                  mov            cx,0            ;starts a counter for the number of digits
                  ;mov            bx,10            ;base 10 conversion THIS IS THE LINE TO CHANGE FOR DIFFERENT BASES!!!!
                  
nonzero:            
                  xor            dx,dx            ;same as mov dx,0
                  div            bx
                  push            dx            ;this is the remainder of the divider
                  inc            cx            ;this will help determine the number of digits produced
                  or            ax,ax            ;sets flags to check is ax = 0
                  jne            nonzero            ;jump not equal to

write:                  
                  pop            dx            ;gets deciaml digit from stack
                  add            dl,'0'      ;ascii value of 30h (what are the values for octal and binary)
                  mov            ah,2
                  int            21h
                  loop            write            ;loops number of times in cx, which is the number of digits
                  pop            dx
                  pop            cx
                  pop            bx
                  pop            ax
                  ret
decimal                  endp
                  end decimal
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.