Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

User input help

user input

  • Please log in to reply
2 replies to this topic

#1 untitled_1

untitled_1

    CC Addict

  • Validating
  • PipPipPipPipPip
  • 129 posts
  • Location:3rd rock from the sun
  • Programming Language:C, C++, Delphi/Object Pascal, Assembly
  • Learning:Python, Perl, Ada, Fortran, Bash

Posted 31 October 2010 - 04:24 AM

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

  • 0

#2 mebob

mebob

    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 467 posts
  • Programming Language:C, C++, Assembly
  • Learning:PHP

Posted 31 October 2010 - 09:03 AM

How exactly is it not working?
  • 0
Latinamne loqueris?

#3 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 02 November 2010 - 01:30 PM

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

  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'






Also tagged with one or more of these keywords: user input

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download