• What is the mov dword ptr [rsp+50h],0 ; instruction doing in this disassembly?

    From Johann \@johann@myrkraverk.invalid to comp.os.ms-windows.programmer.win32,alt.lang.asm,comp.lang.asm on Sun Sep 20 18:39:36 2026
    From Newsgroup: alt.lang.asm

    Dear comp.os.ms-windows.programmer.win32, alt.lang.asm, and comp.lang.
    asm,

    As the topic says, what is the mov dword ptr [rsp+50h],0 ; instruction
    doing? I can see no use for it whatsoever. This is disassembled after
    CL /Ox /O2 /Oi, and I believed the compiler would eliminate all extrane-
    ous instructions. Am I wrong? Please see line 0x77 below.

    The source code can be seen cross posted to comp.lang.python, comp.lang.
    c, and sci.math.


    Command line output follows. Best wishes, and happy assembly
    programming.

    C:\Src\Python\Cryptohack\Myrkraverk>dumpbin /disasm myrkraverk.obj
    Microsoft (R) COFF/PE Dumper Version 14.51.36252.0
    Copyright (C) Microsoft Corporation. All rights reserved.


    Dump of file myrkraverk.obj

    File Type: COFF OBJECT

    count_lsb:
    0000000000000000: 48 83 EC 38 sub rsp,38h
    0000000000000004: 48 8B C2 mov rax,rdx
    0000000000000007: 48 8D 4C 24 58 lea rcx,[rsp+58h]
    000000000000000C: 41 B9 01 00 00 00 mov r9d,1
    0000000000000012: 48 89 4C 24 20 mov qword ptr [rsp+20h],rcx
    0000000000000017: 48 8B C8 mov rcx,rax
    000000000000001A: 48 8D 15 00 00 00 lea
    rdx,[??_C@_01EFFIKLCJ@n@]
    00
    0000000000000021: 45 8B C1 mov r8d,r9d
    0000000000000024: FF 15 00 00 00 00 call qword ptr [__imp_PyArg_UnpackTuple]
    000000000000002A: 85 C0 test eax,eax
    000000000000002C: 74 5E je 000000000000008C
    000000000000002E: 48 8B 54 24 58 mov rdx,qword ptr [rsp+58h]
    0000000000000033: 48 8B 42 08 mov rax,qword ptr [rdx+8]
    0000000000000037: F7 80 A8 00 00 00 test dword ptr [rax+0A8h],1000000h
    00 00 00 01
    0000000000000041: 74 49 je 000000000000008C
    0000000000000043: 4C 8B 42 10 mov r8,qword ptr [rdx+10h]
    0000000000000047: 33 C9 xor ecx,ecx
    0000000000000049: 49 83 F8 08 cmp r8,8
    000000000000004D: 72 32 jb 0000000000000081
    000000000000004F: 48 8D 42 18 lea rax,[rdx+18h]
    0000000000000053: 49 C1 E8 03 shr r8,3
    0000000000000057: 33 D2 xor edx,edx
    0000000000000059: 4D 85 C0 test r8,r8
    000000000000005C: 74 16 je 0000000000000074
    000000000000005E: 66 90 nop
    0000000000000060: 83 38 00 cmp dword ptr [rax],0
    0000000000000063: 75 0F jne 0000000000000074
    0000000000000065: 83 C1 1E add ecx,1Eh
    0000000000000068: 48 FF C2 inc rdx
    000000000000006B: 48 83 C0 04 add rax,4
    000000000000006F: 49 3B D0 cmp rdx,r8
    0000000000000072: 72 EC jb 0000000000000060
    0000000000000074: 0F BC 00 bsf eax,dword ptr [rax]
    0000000000000077: C7 44 24 50 00 00 mov dword ptr [rsp+50h],0
    00 00
    000000000000007F: 03 C8 add ecx,eax
    0000000000000081: FF 15 00 00 00 00 call qword ptr [__imp_PyLong_FromLong]
    0000000000000087: 48 83 C4 38 add rsp,38h
    000000000000008B: C3 ret
    000000000000008C: 48 8B 0D 00 00 00 mov rcx,qword ptr [__imp_PyExc_TypeError]
    00
    0000000000000093: 48 8D 15 00 00 00 lea rdx,[??_C@_0BO@OMAMMBDI@Expected?5exactly?5one?5integer?4@]
    00
    000000000000009A: 48 8B 09 mov rcx,qword ptr [rcx]
    000000000000009D: FF 15 00 00 00 00 call qword ptr [__imp_PyErr_SetString]
    00000000000000A3: 33 C0 xor eax,eax
    00000000000000A5: 48 83 C4 38 add rsp,38h
    00000000000000A9: C3 ret

    PyInit_myrkraverk:
    0000000000000000: 48 8D 0D 00 00 00 lea rcx,[myrkraverk_module]
    00
    0000000000000007: 48 FF 25 00 00 00 jmp qword ptr [__imp_PyModuleDef_Init]
    00

    PyType_HasFeature:
    0000000000000000: 85 91 A8 00 00 00 test dword ptr [rcx+00000000000000A8h],edx
    0000000000000006: B8 00 00 00 00 mov eax,0
    000000000000000B: 0F 95 C0 setne al
    000000000000000E: C3 ret

    Py_TYPE:
    0000000000000000: 48 8B 41 08 mov rax,qword ptr [rcx+8]
    0000000000000004: C3 ret

    Summary

    4 .bss
    80 .chks64
    A8 .data
    84 .debug$S
    9F .drectve
    C .pdata
    74 .rdata
    CC .text$mn
    8 .xdata
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From JJ@jj4public@gmail.com to comp.os.ms-windows.programmer.win32,alt.lang.asm,comp.lang.asm on Mon Sep 21 18:10:13 2026
    From Newsgroup: alt.lang.asm

    On Sun, 20 Sep 2026 18:39:36 +0800, Johann "Myrkraverk" Oskarsson wrote:
    Dear comp.os.ms-windows.programmer.win32, alt.lang.asm, and comp.lang.
    asm,

    As the topic says, what is the mov dword ptr [rsp+50h],0 ; instruction
    doing? I can see no use for it whatsoever. This is disassembled after
    CL /Ox /O2 /Oi, and I believed the compiler would eliminate all extrane-
    ous instructions. Am I wrong? Please see line 0x77 below.

    The source code can be seen cross posted to comp.lang.python, comp.lang.
    c, and sci.math.

    Command line output follows. Best wishes, and happy assembly
    programming.
    [snip]

    If that `count_lsb` is a library function, the instruction is accessing
    stack area outside of `count_lsb` function's local stack area (allocated by `sub rsp,38h`).

    So it's either accessing the local stack area of `count_lsb` function's
    caller (i.e. local variables); or one of the function arguments or local
    stack area, of one of the parent callers within the function call hierarchy.

    Depending on the context, the instruction may or may not be needed.
    --- Synchronet 3.22a-Linux NewsLink 1.2