+;------------------------------------------------------------------------------
+; ReadByte: Read one byte with error checking into InputByte and A.
+; ReadAndCheckError: Call read with the current C stack and check for errors.
+
+.bss
+ReadSize: .res 2
+
+.code
+ReadByte:
+
+; C->read (C->callerdata, &B, 1)
+
+ jsr PushCallerData
+ lda #<InputByte
+ ldx #>InputByte
+ jsr pushax
+ ldx #0
+ lda #1
+
+; This is a second entry point used by the other calls to Read
+
+ReadAndCheckError:
+ sta ReadSize
+ stx ReadSize+1
+ jsr Read
+
+; Check the return code and bail out in case of problems
+
+ cmp ReadSize
+ bne @L1
+ cpx ReadSize+1
+ beq @L2 ; Jump if ok
+@L1: lda #MLOAD_ERR_READ
+ bne CleanupAndExit
+
+; Done
+
+@L2: lda InputByte ; If called ReadByte, load the byte read
+Done: rts
+