• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
        • Program-execution
        • Sdm-instruction-set-summary
        • Tlb
        • Running-linux
        • Introduction
        • Asmtest
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
        • Implemented-opcodes
        • To-do
        • Proof-utilities
        • Peripherals
          • Tty
            • Read-tty
              • Write-tty
              • Tty-bufferp
            • Timer
            • X86-exec-peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Tty

    Read-tty

    Read a byte from the TTY.

    Signature
    (read-tty x86) → (mv byt x86)
    Returns
    x86 — Type (x86p x86), given (x86p x86).

    This function reads a byte from the tty-in field of the x86 stobj by extracting and returning its car and writing the cdr to the tty-in field. If the tty-in field is empty (i.e. it is nil), this function returns nil and the x86 stobj is unmodified. Including tty-raw.lsp in raw lisp smashes this function to read from a TCP port instead.

    Definitions and Theorems

    Function: read-tty

    (defun read-tty (x86)
      (declare (xargs :stobjs (x86)))
      (declare (xargs :guard t))
      (let ((__function__ 'read-tty))
        (declare (ignorable __function__))
        (b* ((buf (tty-in x86))
             ((when (null buf)) (mv nil x86))
             (byt (car buf))
             (x86 (!tty-in (cdr buf) x86)))
          (mv byt x86))))

    Theorem: x86p-of-read-tty.x86

    (defthm x86p-of-read-tty.x86
      (implies (x86p x86)
               (b* (((mv ?byt ?x86) (read-tty x86)))
                 (x86p x86)))
      :rule-classes :rewrite)

    Theorem: unsigned-byte-p-8-non-nil-read-tty

    (defthm unsigned-byte-p-8-non-nil-read-tty
      (implies (and (x86p x86)
                    (mv-nth 0 (read-tty x86)))
               (unsigned-byte-p 8 (mv-nth 0 (read-tty x86)))))