; ---- Keyboard Routines for Ultrabasic
; ---- Gabriel Fernandez
; ---- You are not allowed to use this code without permission

INKEY$:
  PUSH EDI
  PUSH EAX
  MOV edi, eax
  mov ebx, edi
  mov ecx, [eax]
  add ebx, ecx
  add ebx, 4

  Mov AH, 06
  Mov DL, 0FFh
  Int 21h
  Jz empty
  mov [ebx], al
  inc ecx
  mov [edi], ecx
  cmp al, 0
  JE extended
  POP EAX
  POP EDI
    RET
extended:
  Mov AH,06h
  Mov DL,0FFh
  Int 21h
  inc ebx
  mov [ebx], al
  inc ecx
  mov [edi], ecx
empty:   ; Don't fill the string
POP EAX
POP EDI
RET