diff --git a/Sensor-API.md b/Sensor-API.md index 0fa16473..69608ad2 100644 --- a/Sensor-API.md +++ b/Sensor-API.md @@ -479,29 +479,29 @@ float Examplef(float a, float b) { Assembly: ```asm - .literal .LC1012, 0x3ecccccd <- 0.4f - .literal .LC1013, 0x40600000 <- 3.5f + .literal .LC1012, 0x3ecccccd <- 0.4f + .literal .LC1013, 0x40600000 <- 3.5f _Z8Examplefff: - addi sp, sp, -16 #,, <- reserve 16 bytes on stack - s32i.n a0, sp, 12 #, <- save a0 (return address) on stack - s32i.n a12, sp, 8 #, <- save a12 on stack, to free for local var - s32i.n a13, sp, 4 #, <- save a13 on stack, to free for local var - mov.n a13, a3 # b, b <- a3 holds 'b', save to a13 - call0 sinf # <- calc sin of a2 (a) - l32r a3, .LC1012 #, <- load 0.4f in a3 - mov.n a12, a2 # D.171139, <- save result 'sin(a)' to a12 - mov.n a2, a13 #, b <- move a13 (second arg: b) to a2 - call0 __addsf3 # <- add floats a2 and a3, result to a2 - mov.n a3, a2 # D.171139, <- copy result to a3 - mov.n a2, a12 #, D.171139 <- load a2 with a12: sin(a) - call0 __mulsf3 # <- multiply 'sin(a)*(b+0.4f)' - l32r a3, .LC1013 #, <- load a3 with 3.5f - call0 __subsf3 # <- substract - l32i.n a0, sp, 12 #, <- restore a0 (return address) - l32i.n a12, sp, 8 #, <- resotre a12 - l32i.n a13, sp, 4 #, <- resotre a13 - addi sp, sp, 16 #,, <- free stack - ret.n <- return + addi sp, sp, -16 #,, <- reserve 16 bytes on stack + s32i.n a0, sp, 12 #, <- save a0 (return address) on stack + s32i.n a12, sp, 8 #, <- save a12 on stack, to free for local var + s32i.n a13, sp, 4 #, <- save a13 on stack, to free for local var + mov.n a13, a3 # b, b <- a3 holds 'b', save to a13 + call0 sinf # <- calc sin of a2 (a) + l32r a3, .LC1012 #, <- load 0.4f in a3 + mov.n a12, a2 # D.171139, <- save result 'sin(a)' to a12 + mov.n a2, a13 #, b <- move a13 (second arg: b) to a2 + call0 __addsf3 # <- add floats a2 and a3, result to a2 + mov.n a3, a2 # D.171139, <- copy result to a3 + mov.n a2, a12 #, D.171139 <- load a2 with a12: sin(a) + call0 __mulsf3 # <- multiply 'sin(a)*(b+0.4f)' + l32r a3, .LC1013 #, <- load a3 with 3.5f + call0 __subsf3 # <- substract + l32i.n a0, sp, 12 #, <- restore a0 (return address) + l32i.n a12, sp, 8 #, <- resotre a12 + l32i.n a13, sp, 4 #, <- resotre a13 + addi sp, sp, 16 #,, <- free stack + ret.n <- return ``` Now with `double`: @@ -515,8 +515,8 @@ double Exampled(double a, double b) { Assembly: ```asm - .literal .LC1014, 0x9999999a, 0x3fd99999 <- 0.4 - .literal .LC1015, 0x00000000, 0x400c0000 <- 3.5 + .literal .LC1014, 0x9999999a, 0x3fd99999 <- 0.4 + .literal .LC1015, 0x00000000, 0x400c0000 <- 3.5 _Z8Exampleddd: addi sp, sp, -32 #,, s32i.n a0, sp, 28 #, @@ -578,23 +578,23 @@ _Z9Examplef2ff: s32i.n a14, sp, 0 #, mov.n a14, a3 # b, b call0 sinf # - call0 __extendsfdf2 # <- extend float to double + call0 __extendsfdf2 # <- extend float to double mov.n a12, a2 #, mov.n a2, a14 #, b mov.n a13, a3 #, - call0 __extendsfdf2 # <- extend float to double + call0 __extendsfdf2 # <- extend float to double l32r a4, .LC1014 #, l32r a5, .LC1014+4 #, - call0 __adddf3 # <- add double + call0 __adddf3 # <- add double mov.n a4, a2 #, mov.n a5, a3 #, mov.n a2, a12 #, mov.n a3, a13 #, - call0 __muldf3 # <- multiply double + call0 __muldf3 # <- multiply double l32r a4, .LC1015 #, l32r a5, .LC1015+4 #, - call0 __subdf3 # <- substract double - call0 __truncdfsf2 # <- truncate double to float + call0 __subdf3 # <- substract double + call0 __truncdfsf2 # <- truncate double to float l32i.n a0, sp, 12 #, l32i.n a12, sp, 8 #, l32i.n a13, sp, 4 #, @@ -662,11 +662,11 @@ _Z20ExampleStringConcat2R6Stringhh: s32i.n a0, sp, 60 #, s32i.n a14, sp, 48 #, extui a14, a4, 0, 8 # b, b - call0 _ZN6StringC2EPKc # <- allocate String + call0 _ZN6StringC2EPKc # . <- allocate String movi.n a4, 0xa #, addi a2, sp, 24 #,, mov.n a3, a13 #, a - call0 _ZN6StringC1Ehh # <- allocate String + call0 _ZN6StringC1Ehh # <- allocate String addi a3, sp, 24 #,, addi.n a2, sp, 12 #,, call0 _ZplRK15StringSumHelperRK6String # @@ -676,7 +676,7 @@ _Z20ExampleStringConcat2R6Stringhh: mov.n a13, a2 # D.171315, mov.n a3, a14 #, b mov.n a2, sp #, - call0 _ZN6StringC1Ehh # <- allocate String + call0 _ZN6StringC1Ehh # <- allocate String mov.n a3, sp #, mov.n a2, a13 #, D.171315 call0 _ZplRK15StringSumHelperRK6String # @@ -686,11 +686,11 @@ _Z20ExampleStringConcat2R6Stringhh: mov.n a2, a12 #, s call0 _ZN6String6concatERKS_ # mov.n a2, sp #, - call0 _ZN6StringD1Ev # <- destructor + call0 _ZN6StringD1Ev # <- destructor addi a2, sp, 24 #,, - call0 _ZN6StringD1Ev # <- destructor + call0 _ZN6StringD1Ev # <- destructor addi.n a2, sp, 12 #,, - call0 _ZN6StringD2Ev # <- destructor + call0 _ZN6StringD2Ev # <- destructor l32i.n a0, sp, 60 #, l32i.n a12, sp, 56 #, l32i.n a13, sp, 52 #, @@ -733,19 +733,19 @@ _Z20ExampleStringConcat3R6Stringhh: s32i.n a14, sp, 0 #, mov.n a12, a2 # s, s extui a14, a4, 0, 8 # b, b - call0 _ZN6String6concatEPKc # <- native char* add + call0 _ZN6String6concatEPKc # <- native char* add mov.n a3, a13 #, a mov.n a2, a12 #, s - call0 _ZN6String6concatEh # <- native int add + call0 _ZN6String6concatEh # <- native int add l32r a3, .LC1032 #, mov.n a2, a12 #, s - call0 _ZN6String6concatEPKc # <- native char* add + call0 _ZN6String6concatEPKc # <- native char* add mov.n a3, a14 #, b mov.n a2, a12 #, s - call0 _ZN6String6concatEh # <- native int add + call0 _ZN6String6concatEh # <- native int add l32r a3, .LC1033 #, mov.n a2, a12 #, s - call0 _ZN6String6concatEPKc # <- native char* add + call0 _ZN6String6concatEPKc # <- native char* add l32i.n a0, sp, 12 #, l32i.n a12, sp, 8 #, l32i.n a13, sp, 4 #,