flat assembler
Message board for the users of flat assembler.
Index
> Non-x86 architectures > swap from arm to thumb mode ... |
Author |
|
revolution 18 Jul 2018, 03:13
The lowest bit of PC tells the CPU which mode to use to decode instructions. The actual address fetched from RAM does not use the lowest bit from PC, so no exceptions are raised.
The T bit is only used when the OS is returning from an exception. In general you shouldn't change the T bit manually in code. |
|||
18 Jul 2018, 03:13 |
|
Gyver 18 Jul 2018, 06:09
Thx revolution! i understood, referring to my example:
0x010000: sub pc, pc #1 … entering in thumb mode… 0x010006: … thumb code here … right? |
|||
18 Jul 2018, 06:09 |
|
ProMiNick 18 Jul 2018, 07:28
revolution wrote: The lowest bit of PC tells the CPU which mode to use to decode instructions. sub pc,pc #1 - affect only ARM cpus where T flag is located at lowest pc bit, and flags not exist as separate entity(register). From ARM versions where T moved to flags: instruction version without postfix "s" dosn`t affect flags. Even more from ARMv6: instruction variant "sub pc,reg #imm" - not exist anymore, only "subs pc,reg #imm" stayed. instuction "sub pc, reg #imm" - In linux it is very slow form of switching to thumb mode via handling of exception generated by deprecated instruction. In other OSes it can be not handled at all. Am I right? _________________ I don`t like to refer by "you" to one person. My soul requires acronim "thou" instead. |
|||
18 Jul 2018, 07:28 |
|
Gyver 18 Jul 2018, 07:53
Quote: instruction "sub pc, reg #imm" - In linux it is very slow form of switching to thumb mode via handling of exception generated by deprecated instruction. In other OSes it can be not handled at all. You are right ProMiNick! Actually this is the first instruction of an elf program |
|||
18 Jul 2018, 07:53 |
|
revolution 18 Jul 2018, 09:57
ProMiNick wrote: Dosn`t that apply only for earliest APM cores, where T flag was directly located in lowest pc bit, but not in flags? ProMiNick wrote: Even more from ARMv6: So I'd say that the "slowness" is not important. But as always measure it in the app if you think it is some sort of performance bottleneck. And of course different CPU implementations will have different timings so test it across all versions you intend to support. |
|||
18 Jul 2018, 09:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.