i am using the E.asm(...). it's a great tool to get things done (even when some thumb instructions are missing;).
compilation is fine, but does not bring that boost as E.asm does - even when just using peek and poke. I implemented the same operation in 3 different ways, and called each 1000 times:
// takes 538ms ... 222% of the fastest
function rclr1(addr,mask){
poke32( addr, peek32(addr) & ~mask);
}
// takes 334ms ... 138% of the fastest
function rclr2(addr,mask){
"compiled";
poke32( addr, peek32(addr) & !mask); // ~ not supported by compiler
}
// takes 242ms
var rclr3=E.asm("void(int,int)",
"ldr r2,[r0]",
"bic r2,r1",
"str r2,[r0]",
"bx lr"
);
i took a look on the compiler output - the differnces in code between rclr2 and rclr3 speak for themselves:
var rclr2=E.nativeCall(1, "JsVar(JsVar,JsVar)", atob("LenwT4ewBq1F+AgNB0Y0SCpLeESJRphHKU6CRrBHASMAkwAjGkYZRgGVJkyDRqBHgEYlTFhGoEdQRqBHQEawRyJLgkZIRphHgPABACBLwLKYRyBLAUaDRiYiUEaYRx5KA5CQRx1KkEeBRgObGEagR1hGoEdQRqBHQEagRxlIBJcOS834FJB4RJhHB0awRwIjAJMAIxpGGUYBlQpNBkaoRwVGMEagRzhGoEdIRqBHKEagRwAgB7C96PCPAL+1hgMA0aYCAPFQAgDldAUAIawCAHV2BQCLKwIAiZgCAIV2BQDSAAAAZQAAAHBlZWszMgBwb2tlMzIAAAA="));
var rclr3=E.nativeCall(1, "void(int,int)", atob("AmiKQwJgcEc="))
ps: seems that the unary '~' operator has been forgotten in the compiler
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
i am using the E.asm(...). it's a great tool to get things done (even when some thumb instructions are missing;).
compilation is fine, but does not bring that boost as E.asm does - even when just using peek and poke. I implemented the same operation in 3 different ways, and called each 1000 times:
i took a look on the compiler output - the differnces in code between rclr2 and rclr3 speak for themselves:
ps: seems that the unary '~' operator has been forgotten in the compiler