CensoredUsername / dynasm-rs

A dynasm-like tool for rust.
https://censoredusername.github.io/dynasm-rs/language/index.html
Mozilla Public License 2.0
720 stars 54 forks source link

RIP relative addressing. #2

Closed CensoredUsername closed 8 years ago

CensoredUsername commented 8 years ago

Currently no way exists to use labels as immediates/memory locations in generated code. label arguments are only supported on instructions taking code arguments. This can probably be solved by just generalizing labels as immediates, although significant modifications to the parser will be necessary to use them as memory locations (especially when used as part of an immediate expression).

CensoredUsername commented 8 years ago

Probably this parser rework will not be necessary due to the limitations of RIP relative addressing. The parser would just have to recognize the following symbols before going into parsing the whole argument as an expression: [ ->, [ >, [ <. [ =>.

The runtime support has to be slightly extended to allow rip-relative offsets to be encoded when they are not directly at the end of an instruction (currently this is assumed, and it will not be the case if the operand also has an immediate).

CensoredUsername commented 8 years ago

Implemented as from 0b2143b. In the end labels weren't generalized as immediates because the use for this seems to be rather limited.