zoukankan      html  css  js  c++  java
  • nasm astrlwr_s函数 x86

    xxx.asm

    %define p1 ebp+8
    %define p2 ebp+12
    %define p3 ebp+16
    
    section .text
      global dllmain
      export astrlwr_s
    
    dllmain:
      mov eax,1
      ret 12
    
    ;-----------------------------------------;
    ;  将字符串转换为小写
    ;-----------------------------------------;
    astrlwr_s:
      push ebp
      mov ebp,esp
      
      mov eax,[p1]	; str ptr
      mov ecx,[p2]	; numberOfElements
      
      .for:
      
      test ecx,ecx
      jz .return
      
      mov dl,[eax]
      test dl,dl
      jz .return
      
      ;----------------------------------------;
      ; 如果 < 0x41 next
      ;----------------------------------------;
      cmp dl,41h
      jb .next
    
      ;----------------------------------------;
      ; 如果 > 0x5A next
      ;----------------------------------------;
      cmp dl,5Ah
      ja .next
      
      add dl,20h
      mov [eax],dl
      
      .next:
      dec ecx
      inc eax
      jmp .for
      
      .return:
      xor eax,eax
      mov esp,ebp
      pop ebp
      ret 8
    

    c++:

    #include <iostream>
    #include <Windows.h>
    
    typedef int (CALLBACK* astrlwr_s_t)(char* str, size_t numberOfElements);
    
    astrlwr_s_t astrlwr_s;
    
    int main()
    {
      HMODULE myDLL = LoadLibraryA("xxx.dll");
      astrlwr_s = (astrlwr_s_t)GetProcAddress(myDLL, "astrlwr_s");
    
      char a[10] = "aBcD";
      printf("%d, %s
    ", _strlwr_s(a, 10), a); // abcd
    
    
      char b[10] = "aBcD";
      printf("%d, %s
    ", astrlwr_s(b, 10), b); // abcd
      return 0;
    }
    
  • 相关阅读:
    LR 两种录制:html与url
    性能测试心得之一
    杂记
    基于 python 的接口测试框架
    POJ3579 Median
    洛谷P4035 [JSOI2008]球形空间产生器
    洛谷P2455 [SDOI2006]线性方程组
    POJ2393 Yogurt factory
    洛谷P3763 [TJOI2017]DNA
    洛谷P2234 [HNOI2002]营业额统计
  • 原文地址:https://www.cnblogs.com/ajanuw/p/13736532.html
Copyright © 2011-2022 走看看