Is it optimizable: M:=1024*N lazarus / 62-General ---------------------------------------------------------------------- AlexTP · 2021-12-12 11:34 M, N: Int64; CPU x64. I guess that 'M:= N * 1024' is optimizable - it is changed to "N shl 10" in asm. Right? What about 'M:= 1024 * N'? It is optimizable in asm? If not, I will correct my code. ---------------------------------------------------------------------- 440bx · 2021-12-12 12:12 I might be missing something but N * 1024 is the same as 1024 * N, therefore any optimization that applies to one, applies to the other as well. ---------------------------------------------------------------------- Bi0T1N · 2021-12-12 15:58 Quote from: 440bx on December 12, 2021, 01:12:05 pmI might be missing something but N * 1024 is the same as 1024 * N, therefore any optimization that applies to one, applies to the other as well. That might depend on the implementation and I think there were some cases where the one worked but the other was missing. However, the optimization here is implemented in both ways. FPC 3.2.0: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function MultiplyRight(const num: Int64): Int64;begin    MultiplyRight := num * 1024;end; function MultiplyLeft(const num: Int64): Int64;begin    MultiplyLeft := 1024 * num;end; Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i multiplyright(int64):        movq    %rdi,%rax        shlq    $10,%rax        ret multiplyleft(int64):        movq    %rdi,%rax      shlq    $10,%rax        ret ---------------------------------------------------------------------- AlexTP · 2021-12-12 16:25 Here (in the asm) $10 means decimal 10? Okay, thanks. ---------------------------------------------------------------------- Ñuño_Martínez · 2021-12-13 11:11 Quote from: Alextp on December 12, 2021, 05:25:30 pmHere (in the asm) $10 means decimal 10? Okay, thanks. IIRC, in ASM $10 means decimal 16. ---------------------------------------------------------------------- PascalDragon · 2021-12-13 12:44 Quote from: Ñuño_Martínez on December 13, 2021, 12:11:04 pmQuote from: Alextp on December 12, 2021, 05:25:30 pmHere (in the asm) $10 means decimal 10? Okay, thanks. IIRC, in ASM $10 means decimal 16. It depends on the syntax of the assembly. In this case it's AT&T assembly and there $10 is decimal and $0x10 is hexadecimal. ---------------------------------------------------------------------- Ñuño_Martínez · 2021-12-21 20:41 Then maybe that's why some ASM code I wrote for DOS didn't work as expected.