Fixed input bugs.

Input from stdin now works as expected in the emulator.
New program to demo input from the command line.
This commit is contained in:
Anachronaut
2024-11-01 16:41:25 -04:00
committed by GitHub
parent 67eea181b8
commit c512f07305
3 changed files with 63 additions and 12 deletions
+55
View File
@@ -0,0 +1,55 @@
; This program asks the user for input, then prints whatever they input back to the console again.
; It stores the input string in a buffer in the Data Memory.
#Include Libraries/print.asm
#Program
start:
SETD Message0 ; Set the Data Pointer to the explanation message.
CALL printString ; Print it out.
CALL lineFeed
SETD Buffer ; Set the Data Pointer to the start of the buffer.
INIB 0x0A ; Load the value of a linefeed into B.
inputLoop:
INA 0x00 ; Poll the command line.
CCF
SUB
BRQ inputEnd ; If we encountered a linefeed, the string is over, proceed to processing.
STA ; Store A into the buffer.
INCD ; Increment to the next spot in the buffer.
BRI inputLoop ; Loop again to grab more string.
inputEnd:
INIA 0x00 ; Set A to 0.
STA ; Store it in the buffer.
SETD Buffer ; Set the Data Pointer to the start of the buffer again.
CALL printString ; Print it out.
CALL lineFeed
HALT ; End the program.
#Data
; A 256 character buffer for the input string.
; There will need to be some kind of way to define large arrays better than this...
Buffer:
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Message0:
"Input Test: Will echo anything you put in."