When calling the OSRDCH routine from machine code you will need to use the absolute address &40E0. However, when CALLing this routine from BBC BASIC it is recommended that you use the BBC Micro-compatible address &FFE0.
The following example code demonstrates an assembly routine GetKey that returns the ASCII code of the pressed key or -1 if Escape was pressed.
10 OSRDCH=&40E0 20 OSBYTE=&40F4 30 DIM GetKey 24 40 FOR pass%=0 TO 2 50 P%=GetKey 60 [ 70 OPT 0 80 CALL OSRDCH 90 JR C,Escape 100 ; Escape wasn't pressed, return A in HLH'L' 110 LD L,A : LD H,0 120 EXX 130 LD HL,0 140 RET 150 .Escape 160 ; Return -1 170 SBC HL,HL 180 EXX 190 SBC HL,HL 200 ; Clear Escape condition 210 LD A,&7C : CALL OSBYTE 220 RET 230 ] 240 NEXT pass%
The above GetKey routine provides an implementation of GET that is immune to Escape being pressed, returning -1 instead.