Skip to content

libsla Feature Request: Include Program Counter Register in .sla XML #5888

Open
@pjsoberoi

Description

@pjsoberoi

I would like to request a change to the .sla XML schema. Currently the .sla XML does not specify which register is the program counter. When using the libsla emulator (see sleighexample.cc) this results in the program counter register never being set. Emulation works, but EIP is never set correctly. IMHO this is rather unexpected. memstate.getValue(register) works for all registers except for the program counter.

To get around this in my code I've implemented something like the following:

memstate.setValue("PC", value);
emulator.setExecuteAddress(Address(trans.getDefaultCodeSpace(), memstate.getValue("PC")));
...
...
emulator.executeInstruction();
...
...
pc = emulator.getExecuteAddress().getOffset();
memstate.setValue("PC", pc);

This way PC and the emulator are always in sync. The drawback is I need to know which register is the program counter. There is nothing in the .sla to tell me that information. The .pspec has the information:

  <programcounter register="PC"/>

but the .pspec is not an input to the libsla emulator.

I see two ways going forward:

  1. update the .sla schema to include a line to specify which is register is the program counter
  2. update the libsla emulator to taken in an optional .pspec file

I prefer the first option. Once implemented in the .sla, the libsla emulator can update the program counter register transparently to the user. This means memstate.getValue(register) works for all registers as expected.

Pinging @mumbel @GhidorahRex

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions