Picproje Elektronik Sitesi

MİKRODENETLEYİCİLER => ARM => ARM7 Mikrodenetleyici => Konuyu başlatan: z - 09 Nisan 2007, 23:59:08

Başlık: Keil C icinde asm
Gönderen: z - 09 Nisan 2007, 23:59:08

while (a>b){
                  for (i=0;i<10;i++)
                       {
                          ..........
                          ..........
                          __asm{
                                       Hangi Regler bosta, hangileri bosta değil?
                                    }
                          ..........
                          ..........
                       }
                   ..........
                   ..........
                }


Yukaridaki gibi curcuna kod icine inline asm yazabilmek icin hangi regleri ezmemem gerektigi bilgisi elinizde varmi?
Başlık: Ynt: Keil C icinde asm
Gönderen: z - 04 Ocak 2011, 05:14:29
ARM Cortex M3 icin cevabi asagida. Islemcinin ARM modunda olmasi durumu degistirmemesi lazim faka emin degilim.

"In these cases, it is important to understand how parameters and return results are passed between the
calling program and the function being called. The mechanisms of these interactions are specified in
the ARM Architecture Procedure Call Standard [AAPCS, [Ref. 5]].
For simple cases, when a calling program needs to pass parameters to a subroutine or function, it
will use registers R0–R3, where R0 is the first parameter, R1 is the second, and so on. Similarly, R0
is used for returning a value at the end of a function. R0–R3 and R12 can be changed by a function or
subroutine whereas the contents of R4–R11 should be restored to the previous state before entering the
function, usually handled by stack PUSH and stack POP.
To make them easier to understand, the examples in this book do not strictly follow AAPCS practices.
If a C function is called by an assembly code, the effect of a possible register change to R0–R3
and R12 will need to be taken into account. If the contents of these registers are needed at a later stage,
these registers might need to be saved on the stack and restored after the C function completes. Since
the example codes mostly only call assembly functions or subroutines that affect a few registers or
restore the register contents at the end, it's not necessary to save registers R0–R3 and R12."
Başlık: Ynt: Keil C icinde asm
Gönderen: Burak B - 04 Ocak 2011, 08:49:15
Hocam ARM' de PUSHAD, POPAD olmaması ne kötü değilmi. Hani olsaydı tüm regleri saklayıp işimiz bitince iade ederdik mesela ;)

Başlık: Ynt: Keil C icinde asm
Gönderen: z - 04 Ocak 2011, 14:43:37
Neden olmasin?

CortexM3 de multiple register kullanmak suretiyle yapabilirsin.

Ornegin push {R0-R12}

Bu R0 ve R12 dahil ne var ne yok hepsini push eder. Ayni sekilde pop edebilirsin.
Başlık: Ynt: Keil C icinde asm
Gönderen: Burak B - 04 Ocak 2011, 16:24:31
Hocam örnek için sağolun ben bunu biliyorum zaten fikir versin diye örnek göstermiştim. Daha açık anlatmalıydım benim hatam tabi. Vediğiniz alıntıda da bunu belirtiyor zaten.