在64位架构上执行内存阵列 [英] Executing memory array on 64-bit architecture

查看:71
本文介绍了在64位架构上执行内存阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段看起来像这样的测试代码:

展开 | 选择 | Wrap | 行号

解决方案

第一个问题是代码是从malloc()返回的指针,并且你正在通过丢失分配的开始来增加它。不好。


我会将代码分配给临时指针以增加它。


其次,取消引用操作符是一个incrment运算符具有相同的优先权并且从右到左相关联。因此* code ++将增加代码然后取消引用它。我想你想取消引用代码,然后增加它,所以你应该有++(*代码)。当然,使用temp变量而不是代码。



第一个问题是代码是从malloc()和你返回的指针失去你的分配开始正在增加它。不好。


我会将代码分配给临时指针以增加它。


其次,取消引用操作符是一个incrment运算符具有相同的优先权并且从右到左相关联。因此* code ++将增加代码然后取消引用它。我想你想取消引用代码,然后增加它,所以你应该有++(*代码)。当然,使用临时变量而不是代码。



不,分配内存的填充没问题;我不会说64位

英特尔喋喋不休所以我不能再说其他任何事了。

展开 | 选择 | Wrap | 行号


是的,我已经使用这个确切的方法很长一段时间没有任何问题,现在我已经切换到64位崩溃了。


我可以执行数组,如果我只用只能在SSE寄存器上工作的指令填充它,例如XMM0 = XMM0 + XMM1。

但问题似乎是我需要从内存中加载值,如给定的例子勒..

I have a piece of test code that looks like this:

Expand|Select|Wrap|Line Numbers

解决方案

The first problem is that code is a pointer returned from malloc() and you are incrementing it therby losing the start of you allocation. Not good.

I would assign code to a temp pointer in increment it.

Secondly, the de-reference operatot an the incrment operator have the same precedence and are associated right to left. So *code++ will increment code and then de-reference it. I think you want to dereference code and then increment it so you should have ++(*code). Of course, using a temp variable instead of code.


The first problem is that code is a pointer returned from malloc() and you are incrementing it therby losing the start of you allocation. Not good.

I would assign code to a temp pointer in increment it.

Secondly, the de-reference operatot an the incrment operator have the same precedence and are associated right to left. So *code++ will increment code and then de-reference it. I think you want to dereference code and then increment it so you should have ++(*code). Of course, using a temp variable instead of code.

Nope, the filling of the allocated memory was done alright; I don''t speak 64 bits
Intel babble so I can''t say anything else about it.

Expand|Select|Wrap|Line Numbers


Yes, I have been using this exact method for a long time without any problems, it is just now that I have switched to 64-bit that it crashes.

I can execute the array if I only fill it with instructions that only work on the SSE-registers, for example XMM0 = XMM0 + XMM1.
But the problem seems to be when I need to load values from memory, as in the given example..


这篇关于在64位架构上执行内存阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆