; ; getToken.s ; ; The getting of the next token from the input file ; ; © 1995 Straylight ; ;----- Standard Header ------------------------------------------------------ GET libs:header GET libs:swis GET libs:stream ;----- External dependencies ------------------------------------------------ GET sh.anchor ;----- Main code ------------------------------------------------------------ AREA |TermScript$$Code|,CODE,READONLY ; --- getToken --- ; ; On entry: R9 == previous token, or -1 ; R10 == pointer into the tokenised buffer ; R12 == anchor block pointer ; ; On exit: R7 == token class of token read ; R8 == index of token in token class ; R9 == new lookahead token ; R10 == moved on to the first character after the rvalue ; ; Use: Tries to read an token from the current input line EXPORT getToken getToken ROUT 10getToken CMP R9,#10 ;Is it a newline? BEQ %20getToken ;A newline -- bump line count LDRB R9,[R10],#1 ;Load a byte CMP R9,#31 ;Is it an implicit newline? BEQ %20getToken ;Yes -- bump line counter 15getToken ADR R8,tokClasses ;Point to class table LDR R8,[R8,R9,LSL #1] AND R7,R8,#&FF AND R8,R8,#&FF00 MOV R8,R8,LSR #8 MOVS PC,R14 ;Return to caller 20getToken LDR R7,tsc_line ;Yes -- get current line ADD R7,R7,#1 ;Increment line num STR R7,tsc_line ;And save new line number LDRB R9,[R10],#1 ;Load a byte CMP R9,#31 ;Should we ignore this char? BEQ %20getToken ;Yes -- look for the next B %15getToken GET sh.tokClasses LTORG ;----- That's all, folks ---------------------------------------------------- END