简体   繁体   English

从高级语言到IA-32的翻译

[英]Translate from high-level language to IA-32

Can someone please translate this high-level code into IA-32 assembly without using any global variables? 有人可以在不使用任何全局变量的情况下,将此高级代码转换为IA-32程序集吗? I just need it as an example for other work I have to do. 我只需要它作为我要做的其他工作的示例。 Thanks. 谢谢。 Integers are 32-bit and chars are 8-bit. 整数是32位,而char是8位。

class MyString{
   char buff[100];
   int len;

   void deleteChar(char ch){
      int to = 0;
      for (int from = 0; from < this.length; from++){
          char nextch = this.buff[from];
          if (nextch != ch){
             this.buff[to] = nextch;
             to++;
          }
      }
   }
}

Here is what gcc generates when given: 给定gcc会生成以下内容:

void delete_char(char ch, char buf[], int len) {
        int from, to;
        for (from=0,to=0; from<len; ++from)
                if (buf[from] != ch)
                        buf[to++] = buf[from];
}


_delete_char:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $40, %esp
        movl    8(%ebp), %eax
        movb    %al, -28(%ebp)
        movl    $0, -12(%ebp)
        movl    $0, -16(%ebp)
        jmp     L2
L3:
        movl    -12(%ebp), %eax
        addl    12(%ebp), %eax
        movb    (%eax), %al
        cmpb    -28(%ebp), %al
        je      L4
        movl    -16(%ebp), %eax
        movl    %eax, %edx
        addl    12(%ebp), %edx
        movl    -12(%ebp), %eax
        addl    12(%ebp), %eax
        movb    (%eax), %al
        movb    %al, (%edx)
        incl    -16(%ebp)
L4:
        incl    -12(%ebp)
L2:
        movl    -12(%ebp), %eax
        cmpl    16(%ebp), %eax
        jl      L3
        leave
        ret

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不带高级正则表达式 - high-level regular expression with not 从Kafka高级消费者那里获取补偿 - Fetching offset from kafka high-level consumer 文本编辑器的数据结构在哪里以高级语言存在? - Where does the data structure for a text editor live in a high-level language? 高级语言 (Java) 开发人员能否避免 CPU 流水线泡沫? - Can a high-level language (Java) developer avoid CPU pipeline bubbles? Android游戏循环中的高级并发 - High-Level Concurrency in an Android Game Loop 如何在来自 Elasticsearch Java 高级客户端 6.8 的响应中仅获取失败的文档 - How to get only failed documents in the response from Elasticsearch Java High-Level Client 6.8 Elasticsearch 高层 REST 客户端连接失败 https - Elasticsearch high-level REST client fails to connect over https 结合使用不同高级语言编程的两个Webassembly组件 - Combining two webassembly components programmed in different high-level languages 执行单元测试完成的一些高级操作? - Perform some high-level operation of Unit test finish? 寻求用于套接字编程的高级库(Java或Python) - Seeking a High-Level Library for Socket Programming (Java or Python)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM