title: x86-64 Bit Assembly Linux Input
body: <p>I'm trying to input into my program...  All it does is run through and print a '0' to the screen. I'm pretty sure that the PRINTDECI function works, I made it a while ago and it works. Do I just have to loop over the input code and only exit when I enter a certain value? I'm not sure how I would do that...  Unless it's by ACSII values which might suck.... Anyways, here's my code (Yasm(nasm clone), Intel Syntax):</p>
  
  <pre><code>GLOBAL _start
  SECTION .text
  
  PRINTDECI:
   LEA R9,[NUMBER + 18]       ; last character of buffer
   MOV R10,R9                 ; copy the last character address
   MOV RBX,10                 ; base10 divisor
  
   DIV_BY_10:
  
   XOR RDX,RDX                ; zero rdx for div
   DIV RBX                    ; rax:rdx = rax / rbx
   ADD RDX,0x30               ; convert binary digit to ascii
   TEST RAX,RAX               ; if rax == 0 exit DIV_BY_10
   JZ CHECK_BUFFER
   MOV byte [R9],DL           ; save remainder
   SUB R9,1                   ; decrement the buffer address
   JMP DIV_BY_10
  
   CHECK_BUFFER:
  
   MOV byte [R9],DL
   SUB R9,1
  
   CMP R9,R10                 ; if the buffer has data print it
   JNE PRINT_BUFFER 
   MOV byte [R9],'0'          ; place the default zero into the empty buffer
   SUB R9,1
  
   PRINT_BUFFER:
  
   ADD R9,1                   ; address of last digit saved to buffer
   SUB R10,R9                 ; end address minus start address
   ADD R10,1                  ; R10 = length of number
   MOV RAX,1                  ; NR_write
   MOV RDI,1                  ; stdout
   MOV RSI,R9                 ; number buffer address
   MOV RDX,R10                ; string length
   SYSCALL
  RET
  
  _start:
   MOV RCX, SCORE     ;Input into Score
   MOV RDX, SCORELEN
   MOV RAX, 3
   MOV RBX, 0
   SYSCALL
  
   MOV RAX, [SCORE]
   PUSH RAX           ;Print Score
    CALL PRINTDECI
   POP RAX
  
   MOV RAX,60         ;Kill the Code
   MOV RDI,0
   SYSCALL
  
  SECTION .bss
   SCORE:         RESQ 1
   SCORELEN EQU $-SCORE
  </code></pre>
  
  <p>Thanks for any help!
   - Kyle</p>
  
  <p>As a side note, the pointer in RCX goes to a insanely large number according to DDD...  So I'm thinking I have to get it to pause and wait for me to type, but I have no idea how to do that...</p>