identify some tokens
This commit is contained in:
@@ -912,6 +912,71 @@ evaluate_constant:
|
||||
mov rdx, 0xFF ; unrecognised type
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; identify_register
|
||||
;
|
||||
; description:
|
||||
; takes a register in ascii-encoded text and returns its token ID or
|
||||
; UNRECOGNISED_TOKEN_ID if not recognised
|
||||
;
|
||||
; parameters:
|
||||
; edi = register to be searched
|
||||
;
|
||||
; returned:
|
||||
; ax = register's token ID or UNRECOGNISED_TOKEN_ID
|
||||
; ------------------------------------------------------------------------------
|
||||
|
||||
identify_register:
|
||||
xor eax, eax ; tokens.registers + eax -> entry in tokens.registers
|
||||
.loop:
|
||||
cmp eax, (tokens.registers_end - tokens.registers)
|
||||
jge .not_found
|
||||
|
||||
cmp edi, [tokens.registers + eax]
|
||||
je .found
|
||||
|
||||
add eax, 6
|
||||
jmp .loop
|
||||
.found:
|
||||
mov ax, [tokens.registers + eax + 4]
|
||||
ret
|
||||
.not_found:
|
||||
mov ax, UNRECOGNISED_TOKEN_ID
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; identify_operator
|
||||
; TODO combine with identify_register
|
||||
;
|
||||
; description:
|
||||
; takes an operator in ascii-encoded text and returns its token ID or
|
||||
; UNRECOGNISED_TOKEN_ID if not recognised
|
||||
;
|
||||
; parameters:
|
||||
; edi = operator to be searched
|
||||
;
|
||||
; returned:
|
||||
; ax = operator's token ID or UNRECOGNISED_TOKEN_ID
|
||||
; ------------------------------------------------------------------------------
|
||||
|
||||
identify_operator:
|
||||
xor eax, eax ; tokens.operators + eax -> entry in tokens.operators
|
||||
.loop:
|
||||
cmp eax, (tokens.operators_end - tokens.operators)
|
||||
jge .not_found
|
||||
|
||||
cmp edi, [tokens.operators + eax]
|
||||
je .found
|
||||
|
||||
add eax, 6
|
||||
jmp .loop
|
||||
.found:
|
||||
mov ax, [tokens.operators + eax + 4]
|
||||
ret
|
||||
.not_found:
|
||||
mov ax, UNRECOGNISED_TOKEN_ID
|
||||
ret
|
||||
|
||||
; ------------------------------------------------------------------------------
|
||||
; utilities
|
||||
; ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user