Jump to content

User input help

- - - - -

  • Please log in to reply
2 replies to this topic

#1
untitled_1

untitled_1

    Learning Programmer

  • Members
  • PipPipPip
  • 89 posts
hey all, im trying to get user input in the form of like a stream of bytes from key board, im doing the following and its wrong

jmp main


input: resb 20


get_input:

         mov ah, 0ah ;user input function

         int 21h ;for user input

         ret


main:

         mov dx, input ;move address of input to dx where keyboard input will be returned

         call get_input

         int 20h ;return to dos


This code is not working, im using nasm, i want input to initialized to value input by user in keyboard

Edited by dargueta, 02 November 2010 - 01:28 PM.
Added code tags


#2
mebob

mebob

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 490 posts
How exactly is it not working?
Latinamne loqueris?

#3
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
The buffer can't just be empty; you need a bit more information for the interrupt. The first byte of the buffer should be the length of the buffer not including the two info bytes; the second should be 0, and everything after that is your buffer in which the string will be stored. On a return the second byte of the buffer will contain a number indicating how many bytes were stored into the buffer.

In your case you want something like

input: resb 22

.

.

.


mov     ah, 0ah

mov     BYTE [input], 0x20

mov     BYTE [input + 1], 0x00

mov     dx, input

int     21h


sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users