I am writing a build macro in a C program, and being completely new, I am stuck on something. I am trying to write a macro to move data from a general purpose to a special purpose register.
My problem is that the syntax that I found to move data from GPR to SPR takes on the value of the constant SPR, while I want to use a variable stored in a different register.
# SPR is constant, rA is the value to be written mtspr SPR, rA
I'm for something like this:
# rA contains the number of the SPR, and rB the value to be moved. AWESOMEmtspr rA, rB
Is there a reason this macro is not available, and how would I do it myself?
Thank you very much in advance.
---- Edit: ---- As it now looks, I have a giant switch case in my C code that jumps to the correct mtspr section. I have twenty separate read and write sections that contain SPR: s, each of which looks the same but has a constant value.
, , , - register. , , , , . , , ( , , , OR ), . ( ).
, ? , SPR (, ), , , ,
MTPSR PSRx, val RET MTPSR PSRx+1, val RET
, "", , . , NOP, , PowerPC, , .
, :
#define stringify (s) tostring (s)#define tostring (s) #s#define mfspr (rn) ({unsigned int rval; \ asm volatile ( "mfspr% 0", stringify (rn) \ : "= r" (rval)); RVAL;})#define mtspr (rn, v) asm volatile ( "mtspr" stringify (rn) ",% 0":: "r" (v))
#define stringify (s) tostring (s)
#define tostring (s) #s
#define mfspr (rn) ({unsigned int rval; \ asm volatile ( "mfspr% 0", stringify (rn) \ : "= r" (rval)); RVAL;})
#define mtspr (rn, v) asm volatile ( "mtspr" stringify (rn) ",% 0":: "r" (v))
U-Boot PowerPC.
, , - , , rA - mtspr. , SPR.
mtspr
Source: https://habr.com/ru/post/1754395/More articles:read data from the Internet - rCreating getters / setters in Java (again) - javaPHP static code analysis - finding class dependencies - phpDetermining if an application is running in the background - androidauto_ptr and containers - C ++ - c ++Сканер в Java не работает - javaProcessing an external screen on an iPad - iphonecustom 404 page with asp.net C # 3.5 on IIS6 - c #используя элемент из javascript - javascriptUnknown method key? Error in Rails 2.3.8 Unit Testing - ruby-on-railsAll Articles