Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PC access in functions does not yield correct results #16

Open
wysiwyng opened this issue Jun 3, 2022 · 4 comments
Open

PC access in functions does not yield correct results #16

wysiwyng opened this issue Jun 3, 2022 · 4 comments
Labels
bug Something isn't working etiss writer Issues concerning the ETISS writer backend module

Comments

@wysiwyng
Copy link
Collaborator

wysiwyng commented Jun 3, 2022

void pctest(int a, int b) {
  X[a] = PC;
  PC = X[b];
}

is translated to:

static inline void pctest(ETISS_CPU * const cpu, ETISS_System * const system, void * const * const plugin_pointers, etiss_int32 a, etiss_int32 b)
{
  ((test_core*)cpu)->X[a] = ic.current_address_;
  cpu->instructionPointer = ((test_core*)cpu)->X[b];
}

where ic.current_address_ can not be accessed in function context.

@wysiwyng wysiwyng added bug Something isn't working etiss writer Issues concerning the ETISS writer backend module labels Jun 3, 2022
@neithernut
Copy link

Could you please elaborate?

@wysiwyng
Copy link
Collaborator Author

wysiwyng commented Jun 3, 2022

the PC can be read as ic.current_address_ during the instruction translation phase of ETISS, as functions are executed during JIT runtime they need to read the PC as cpu->instructionPointer

@wysiwyng
Copy link
Collaborator Author

wysiwyng commented Jun 3, 2022

problematic in "just doing that" is that currently cpu->instructionPointer is incremented at the very beginning of each instruction, but ic.current_address_ always points to the address of the current instruction. to fix this properly, the PC increment would have to be reworked, and by that extent most likely made explicit in the CoreDSL model.

@wysiwyng
Copy link
Collaborator Author

see also: Minres/CoreDSL#54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working etiss writer Issues concerning the ETISS writer backend module
Projects
None yet
Development

No branches or pull requests

2 participants