flat assembler
Message board for the users of flat assembler.

Index > DOS > Help with input

Author
Thread Post new topic Reply to topic
Jakevfr



Joined: 03 Feb 2007
Posts: 26
Jakevfr
Here's my routine for getting user input:
Code:
clearget:
  mov bx, 0
  .loop:
    mov [get+bx], ' '
    inc bl
    cmp bl, 32
    jbe .loop
ret

getsint:
  call clearget
  mov bx, 0
  .input:
    mov ah, 8
    int 21h

    cmp al, 13
    je .complete

  .continue:
    mov ah, 2
    mov dl, al
    int 21h

    mov [get+bx], al
    inc bl
    jmp .input

  .complete:
    mov ax, get
    mov bx, 0
ret 

get db ' ' dup 32              
    

Now whenever I use it all it returns is 259. Why is this and how can I fix it?
Post 11 Feb 2007, 16:41
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Code:
--- jake.asm    2007-02-11 14:50:18 +0000
+++ temp.asm    2007-02-11 14:47:08 +0000
@@ -1,8 +1,16 @@
+org 100h
+
+Komenco:        call getsint
+                mov ah,9
+                mov dx,get
+                int 21h
+Fino:           ret
+
 
 clearget:
   mov bx, 0
   .loop:
-    mov [get+bx], ' '
+    mov [get+bx], '$'
     inc bl
     cmp bl, 32
     jbe .loop
@@ -32,5 +40,5 @@
     mov bx, 0
 ret 
 
-get db ' ' dup 32              
+get db '$' dup 32
    


Quote:

[ WinXP ] Sun 02/11/2007>temp.com
Whatever, man!Whatever, man!
[ WinXP ] Sun 02/11/2007>scrndump


Does this not work like you want? (I don't exactly understand what "returns 259" means.)

P.S. moderator, please move this to DOS, por favor! Wink
Post 11 Feb 2007, 20:53
View user's profile Send private message Visit poster's website Reply with quote
Jakevfr



Joined: 03 Feb 2007
Posts: 26
Jakevfr
I gues I should explain what I'm wanting a little better. It works fine for strings, but I'm wanting to get numbers. I want the user to be able to input the number '65' and 65 be stored in the AX register for later use.
Post 11 Feb 2007, 21:14
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
The number 65 is 41h (base 16), but the string '65' in AX would be 3635h. In other words, it's a bit more complicated.

Please read DOS FAQ or use FASMLIB (Win32, Linux) or read String to number and vice versa ??
Post 11 Feb 2007, 21:34
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.