flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
pro3carp3
I'm adding some exception handling using the example here: https://board.flatassembler.net/topic.php?t=11266.
The example transfers control back to the procedure by setting context.Rip to the point immediately past the errant code: Code: buggy_instruction: div ebx sizeof_buggy_instruction = $ - buggy_instruction ... add [context.Rip],sizeof_buggy_instruction Rather than jump to the code following the error, however, I want to jump to a particular label to handle the exception, similar to a finally block. I'm getting a value out of range error when attempting this: Code: mov [context.Rip], finally_label How do I adjust the context.Rip to jump to the finally label upon exiting the exception handler? Thanks. |
|||
![]() |
|
ProMiNick
finally_label - is 64 bit immediate value.
only instruction that accept 64 IMM is "mov REG, IMM64" so mov RAX, finally_label mov [context.Rip], RAX will work. |
|||
![]() |
|
sinsi
Isn't it better for 64-bit code to use LEA rather than MOV? I thought MOV would give a 64-bit address but LEA would use RIP-relative (and no relocation).
|
|||
![]() |
|
Furs
Code: add [context.Rip], finally_label - buggy_instruction |
|||
![]() |
|
pro3carp3
I should have realized that. Thank you.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.