home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,115 of 4,675   
   vince@nospicedham.pianoman.cluster. to Richmond   
   Re: sys_read from stdin   
   28 Nov 17 16:02:01   
   
   On 2017-11-28, Richmond  wrote:   
   > I am trying to read a key from the keyboard. I have switched off   
   > canonical mode so it doesn't wait for the return key. But it does not   
   > seem to pick up the key in AX.   
      
   is this on Linux?  x86_64?   
      
   Is there any reason you're not using the "syscall" instruction?   
   int 0x80 is deprecated on x86_64.   
      
   ALso on x86_64 the system call numbers are different, I think sys_read   
   is syscall #0   
      
   A great tool for debugging things like this is the "strace" program which   
   will show all system calls and arguments from your program.   
      
   Vince   
      
   >   
   > GCHAR:  push rax   
   >         push rbx   
   >         push rcx   
   >         push rdx   
   >         mov rsi, charbuffer    ; buffer = address to store the bytes read   
   >         mov rcx,rsi   
   >         mov rdx, 0x4        ; number of bytes to read   
   >                            (setting this to 1 makes no difference)   
   >         mov rax, 0x3        ; number for sys_read   
   >         mov rbx, 0x2        ; From stdin   
   >         int 0x80   
   >         MSPRINT "Byte read is "   
   >         MOV AX,[charbuffer]   
   >         CALL PWORD   
   >         pop rdx   
   >         pop rcx   
   >         pop rbx   
   >         pop rax   
   >         RET   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca