1
votes

Hallo everybody, Can someone help me out of my situation, im searching for a instrucior that implements the JMP (Jump) instructior like in Assembler. I've found out that it could be withe the goto function of Flex/Bison but i have no really idea how to do. Have got anyone idea. Im very grateful of yours help. Thanks.

Here is an example how it looks like. with the JMP instructor, he goes to the label L1.

:L1
IF FLAG AND X"0001"
EVT 23;
ELSE
WAIT 500 ms;
JMP L1;
END IF;
1
Not too sure what you are talking about, but the while loop will nicely replace that bit of code you have there.slugster
Hallo slugster, what i ment was, its allround a syntactical analysis and i want that the interpreter i build should recognise the JMP Instructor, when i give an Input like at the top, and gives me back, that JMP was used und it jumped to the label L1. I've build a syntax tree where he can recognise the and while statement the operators and the bigger lower equal operators now i need the same for JMP, if you go to the question how do i implement a ifstatement in flex/bison there you find the code. look it out and if you have an idea i will be very grateful.Imran

1 Answers

1
votes

To implement a jump instruction you need to add gramma support for the label

label: ':' NAME { /* code to store the label */ };

and some grammer to parse the jump command

jmp: JMP NAME { /* code to look-up label and go there */ };

Keep in mind, defer the checking of all jump targets till the end of the parsing, otherwise you not be able to jump ahead.