TAlpha::Negative 部分汇编

本文探讨了在图像处理与内存操作中优化算法的实现,通过使用汇编语言进行底层操作,实现了对图像数据的高效处理与内存优化。具体包括宽度调整、内存地址计算、循环遍历及逐像素的异或操作,显著提高了处理速度和内存使用效率。
      Width *= 3;
      register const int ld = iLineAdd + Width;
      Width >>= 1;
      Width--;
      for (register int i = Height - 1; i >= 0; i--)
       {
        register unsigned short int *ptr = (unsigned short int *)ptrBuffer;
        for (register int j = Width; j >= 0; j--)
         {
          *ptr = ~*ptr;
          ptr++;
         }
        ptrBuffer += ld;
       }
汇编代码
:00425E95 8D1C52         lea ebx, dword ptr [edx+2*edx] ; edx = Width
:00425E98 89DA           mov edx, ebx
;:00425E9A 81EA23010000  sub edx, 00000123
:00425EA0 8B5D0C         mov ebx, dword ptr [ebp+0C]
:00425EA3 03DA           add ebx, edx
:00425EA5 D1FA           sar edx, 1
:00425EA7 895DFC         mov dword ptr [ebp-04], ebx ; [ebp-04] = ld
:00425EAA 4A             dec edx
:00425EAB 49             dec ecx
:00425EAC 894DF8         mov dword ptr [ebp-08], ecx ; [ebp-08] = i
:00425EAF 837DF800       cmp dword ptr [ebp-08], 00000000
:00425EB3 7C50           jl 00425F05
:00425EB5 8BC8           mov ecx, eax ; eax = ptrBuffer
:00425EB7 8BDA           mov ebx, edx ; ebx = j
:00425EB9 85DB           test ebx, ebx
:00425EBB 7C0B           jl 00425EC8
:00425EBD 66F711         not word ptr [ecx] ; *ptr = ~*ptr
:00425EC0 83C102         add ecx, 00000002  ; ptr++ 
:00425EC3 4B             dec ebx            ; j-- 
:00425EC4 85DB           test ebx, ebx
:00425EC6 7DF5           jge 00425EBD
:00425EC8 0345FC         add eax, dword ptr [ebp-04]
:00425ECB FF4DF8         dec [ebp-08]
:00425ECE 837DF800       cmp dword ptr [ebp-08], 00000000
:00425ED2 7DE1           jge 00425EB5

 Width--;
 #ifdef _using_color_rgb_struct_
    register color_rgb *pDest;
    register const int ld = iPixelAdd + 3;
    for (register int i = Height - 1; i >= 0; i--)
     {
      for (register int j = Width; j >= 0; j--)
       {
        pDest = (color_rgb *)ptrDest;
        *((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest);
        pDest->r = ~pDest->r;

        ptrDest += ld;
       }

      ptrDest += iLineAdd;
     }
 #else
汇编代码
:00425ED6 4A        dec edx ; Width--
:00425ED7 8D7B03    lea edi, dword ptr [ebx+03] ; edi = ld
:00425EDA 49        dec ecx
:00425EDB 894DF4    mov dword ptr [ebp-0C], ecx ; [ebp-0C] = i
:00425EDE 837DF400  cmp dword ptr [ebp-0C], 00000000
:00425EE2 7C21      jl 00425F05
:00425EE4 8BF2      mov esi, edx ; j = Width
:00425EE6 85F6      test esi, esi ; esi = j
:00425EE8 7C0F      jl 00425EF9
:00425EEA 8BC8      mov ecx, eax ; ecx = pDest 多浪费一步
:00425EEC 66F710    not word ptr [eax]
:00425EEF F65102    not [ecx+02]
:00425EF2 03C7      add eax, edi ; ptrDest += ld
:00425EF4 4E        dec esi
:00425EF5 85F6      test esi, esi
:00425EF7 7DF1      jge 00425EEA
:00425EF9 03450C    add eax, dword ptr [ebp+0C] ; ptrDest += iLineAdd
:00425EFC FF4DF4    dec [ebp-0C] ; i--
:00425EFF 837DF400  cmp dword ptr [ebp-0C], 00000000
:00425F03 7DDF      jge 00425EE4

 Width--;
 #ifdef _using_short_int_
    register const int ld = iPixelAdd + 2;
    for (register int i = Height - 1; i >= 0; i--)
     {
      for (register int j = Width; j >= 0; j--)
       {
        *ptrDest = ~*ptrDest;
        ptrDest++;
        *((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest);

        ptrDest += ld;
       }

      ptrDest += iLineAdd;
     }
汇编代码
:00425EC8 4A            dec edx ; Width--
:00425EC9 8D7302        lea esi, dword ptr [ebx+02] ; ld = iPixelAdd + 2
:00425ECC 81C223010000  add edx, 00000123
:00425ED2 8D79FF        lea edi, dword ptr [ecx-01] ; i = Height - 1
:00425ED5 85FF          test edi, edi
:00425ED7 7C1B          jl 00425EF4
:00425ED9 8BCA          mov ecx, edx
:00425EDB 85C9          test ecx, ecx
:00425EDD 7C0D          jl 00425EEC
:00425EDF F610          not byte ptr [eax] ; *ptrDest = ~*ptrDest
:00425EE1 40            inc eax ; ptrDest++
:00425EE2 66F710        not word ptr [eax] ; *((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest)
:00425EE5 03C6          add eax, esi ; ptrDest += ld
:00425EE7 49            dec ecx      ; j--
:00425EE8 85C9          test ecx, ecx
:00425EEA 7DF3          jge 00425EDF
:00425EEC 03450C        add eax, dword ptr [ebp+0C] ; ptrDest += iLineAdd
:00425EEF 4F            dec edi ; i--
:00425EF0 85FF          test edi, edi
:00425EF2 7DE5          jge 00425ED9

内循环do...while

 Width--;
 #ifdef _using_short_int_
    register const int ld = iPixelAdd + 2;
    for (register int i = Height - 1; i >= 0; i--)
     {
      register int j = Width;
      do
       {
        *ptrDest = ~*ptrDest;
        ptrDest++;
        *((unsigned short int *)ptrDest) = ~*((unsigned short int *)ptrDest);

        ptrDest += ld;
        j--;
       }while(j >= 0);

      ptrDest += iLineAdd;
     }

汇编代码

:00425E98 4A            dec edx  ; Width--
:00425E99 8D7B02        lea edi, dword ptr [ebx+02]
:00425E9C 81C223010000  add edx, 00000123
:00425EA2 8D71FF        lea esi, dword ptr [ecx-01]
:00425EA5 85F6          test esi, esi  ; esi = i
:00425EA7 7C17          jl 00425EC0
:00425EA9 8BCA          mov ecx, edx   ; j = Width
:00425EAB F610          not byte ptr [eax]  ; *ptrDest = ~*ptrDest
:00425EAD 40            inc eax             ; ptrDest++
:00425EAE 66F710        not word ptr [eax]  
:00425EB1 03C7          add eax, edi        ; ptrDest += ld
:00425EB3 49            dec ecx             ; j--
:00425EB4 85C9          test ecx, ecx
:00425EB6 7DF3          jge 00425EAB
:00425EB8 03450C        add eax, dword ptr [ebp+0C]  ; ptrDest += iLineAdd
:00425EBB 4E            dec esi        ;  i--  
:00425EBC 85F6          test esi, esi
:00425EBE 7DE9          jge 00425EA9

                                    
                                          

                       
### 支持处理包含 `(:requirements :typing :fluents :negative-preconditions)` 的 PDDL 规划器 在 PDDL 中,`:requirements` 字段用于声明领域文件中使用了哪些扩展特性。具体到 `:typing`、`:fluents` 和 `:negative-preconditions` 这些关键字: - `:typing` 表示使用了类型系统(对象分类); - `:fluents` 表示存在连续数值型状态变量(通常与Numeric Fluents相关); - `:negative-preconditions` 表示动作的前提条件中允许否定形式的谓词。 能够支持上述要求的规划器需要具备对 ADL(Action Description Language)或其增强版本的良好兼容性。以下是一些主流支持这些特性的规划器及其特点: #### Fast Downward Fast Downward 是目前最广泛使用的通用经典规划器之一,它支持大部分 ADL 特性,包括 `:typing`、`:fluents` 以及 `:negative-preconditions`。该规划器通过中间表示语言“SAS+”来处理复杂的 PDDL 文件,并且具有良好的性能和可扩展性。 ```bash # 示例:使用 Fast Downward 求解带复杂 requirements 的 PDDL 文件 ./fast-downward.py domain.pddl problem.pddl --search "astar(lmcut())" ``` Fast Downward 的一大优势是可以通过插件机制扩展对新特性的支持[^1]。 #### LAMA (Learning Based Planner) LAMA 是基于 Fast Downward 构建的启发式规划器,支持完整的 ADL 功能,包括所有提到的 requirements。它结合了机器学习技术优化启发式函数,适合处理大规模复杂问题。 #### Metric-FF Metric-FF 是 FF(Fast Forward)的一个扩展版本,专门用于处理带有数值变量的问题,因此支持 `:fluents`。它也支持 `:typing` 和 `:negative-preconditions` 等基础 ADL 特性。 #### Temporal Fast Downward (TFD) TFD 是 Fast Downward 的时间扩展版本,适用于处理时间约束下的规划任务。它同样支持完整的 ADL 特性集合,包括 `:typing`、`:fluents` 和 `:negative-preconditions`。 #### 基于 SAT 的规划器(如 SATPLAN) SATPLAN 将规划问题转化为布尔可满足性问题进行求解,支持大多数 ADL 特性。虽然其性能可能不如启发式搜索类规划器,但在某些特定场景下表现良好。 --- ### 选择建议 如果目标是处理包含 `:typing`、`:fluents` 和 `:negative-preconditions` 的 PDDL 文件,推荐优先考虑 **Fast Downward** 或 **LAMA**。这两个工具不仅功能全面,而且社区活跃、文档完善,便于调试和集成。 对于需要实时响应或复杂数值计算的应用,可以考虑 **Metric-FF**;而如果涉及时间约束,则应选择 **Temporal Fast Downward**。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值