Jaken_1 0 Newbie Poster

Like the title says. I have a user-inputted string that I need to do math calculations with, therefore, I need to convert the string to an integer. This is my current code. What can I do to manipulate the number the user inputs?

org 0x100

section .data
   prompt   db   "Enter a Base 10 Number",13,10,'$'
   len   equ $ -prompt
   inbinary db   "In binary it is ",13,10,'$'
   inoctal  db   "In octal it is ",13,10,'$'
   inhex    db   "In hexadecimal it is ",13,10,'$'


section .text
start:
   push   cs
   pop    ax
   mov    ds, ax
   mov    es, ax      ; make sure ds = es = cs

   mov    di, string  ; es:di points to string
   cld                ; clear direction flag (so stosb incremements rather than decrements)


   mov    ah, 9
   mov    dx, prompt
   int    21h

read_loop:
   mov    ah, 0x01    ; Function 01h Read character from stdin with echo
   int    0x21
   cmp    al, 0x0D    ; character is carriage return?
   je     read_done   ; yes? exit the loop
   stosb              ; store the character at es:di and increment di
   jmp    read_loop   ; loop again
read_done:
   mov    al, '$'
   stosb              ; 'Make sure the string is '$' terminated


   mov    bx, string  ; store string in base register

   mov    dx, bx      ; ds:dx points to bx
   mov    ah, 9       ; Function 09h Print character string
   int    0x21

   ; Exit
   mov    ax, 0x4c00
   int    0x21

   string:
   times    255 db 0  ; reserve room for 255 characters
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.