【问题标题】:3d C array to Assembly3d C 阵列组装
【发布时间】:2019-06-23 04:47:06
【问题描述】:

我正在整个视频缓冲区中一起渲染 10x12 像素地图

buffer[20][512] = malloc(10*12)

我在 20 个组中有多达 512 个潜在的 10x12 位图。我只使用一个组号:0 buffer[group][number of 10x12 tiles]

因此,buffer[0][mapindex]

每次调用该函数时,我只需要索引不同的地图。 我将缓冲区传递给 nasm 函数 tile_render(buffer,0,mapindex);

这是我迷路的地方:

    lea esi,[ebp + 12]; Passing the buffer from the stack

    mov eax,[ebp + 36]   ;Location of mapindex on the stack

    I am looping through 10 x 12 trying to render the pixels

    mov dl,[4*esi + eax +8] 

    move byte [edi + ebx],dl  ;moving one byte at a time.

    //code omitted

    add ebx,320  

但是,我没有找到 10x12 像素的正确地址,这意味着我只是在屏幕上出现乱码。

当然还有其他方法可以处理这个问题,我可以做得很好,但我想知道如何在汇编中更好地使用 3 维数组。在这方面,我的经验是新手,所以我希望以前有人处理过这种情况。

【问题讨论】:

  • 找到了这个案例的解决方案:

标签: c++ c arrays


【解决方案1】:

找到了这个案例的解决方案:

mov esi,[ebp + 12] ; buffer[20][512] = malloc(10*12)
mov edx,[esi]    ;Move to first bitmap
lea esi,[edx]    ;first bitmap address
mov eax,[ebx + 36] ;index to each map
mov ecx,120        ;120 = 12x10 size bit map
mul ecx            ;120 x map index.
mov dl. [esi + eax] ;index through to the output buffer
mov [edi + ebx],dl   ; next
.
.
.
add ebx,320

【讨论】:

  • 要放置一个代码块,只需选择它并按工具栏上的{} 按钮,或按Ctrl+K。工具栏右侧还有一个help button,请花几分钟了解如何正确格式化您的代码
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-01-20
  • 1970-01-01
  • 1970-01-01
  • 2018-12-27
  • 2019-06-28
  • 1970-01-01
相关资源
最近更新 更多