小编Ale*_*nze的帖子

在中断服务程序中,什么都不能用?

我知道ISR需要非常快,并且应该很快处理中断.但我不明白同样的原因.为什么要满足这个条件?而且,为了做到这一点,对ISR代码的所有内容有什么限制吗?通常情况下,所有不应包含在ISR代码中的内容?

谢谢

operating-system interrupt linux-kernel

0
推荐指数
1
解决办法
2012
查看次数

我们如何在 16 位中使用 `e[]x` 而在 32 位中不使用 `r[]x`

那么在汇编中,如何e[]x在16位实模式下可以使用,而r[]x在32位模式下不能使用呢?例如:

BITS 16
mov bx, 1
mov eax, 2
Run Code Online (Sandbox Code Playgroud)

将在 IDA 中正确组装和反汇编(在 16 位模式下)。它可以工作,因为我之前已经反汇编了 Win2k 引导加载程序并找到了eax.

但是,为什么即使在无法访问的受保护模式下的 64 位处理器上也无法访问r[]x

x86 assembly x86-64

0
推荐指数
1
解决办法
257
查看次数

代码在Windows XP上的malloc()崩溃

我的简化代码如下所示:

 char decrypted[64] = "P@ssw0rd                ";
 int realsize = 8;
  realloc(decrypted, realsize);

  char *dec2 = (char *) malloc(realsize+1); // Exe crashes at this point
Run Code Online (Sandbox Code Playgroud)

我猜它与char*dec2有关 ,但这只是因为某些原因崩溃了Win XP.

c malloc

0
推荐指数
1
解决办法
144
查看次数

如何从字符串中存储和检索char*?

const char *RecBuffer, int *packetLength 指向数据和大小

    string packet(RecBuffer,*packetLength);//store here
     ...do some stuff
    RecBuffer = packet.c_str();//retrieve it later
Run Code Online (Sandbox Code Playgroud)

现在发生的事情是我的Recbuffer包含大量的浮点数,并且我将收到的数据包作为UDP数据包收到.但是当我从字符串中存储和检索它时,它包含垃圾.

我哪里错了?

c++ stl

0
推荐指数
1
解决办法
104
查看次数

简单C程序上的奇怪输出

我在C中有以下内容:

int x = 0;
int *a = &x;

void foo(int *a)
{
    static int x = 0;
    x++;
    *a += x;
    a = &x;
    *a = x + 10;
}

int _tmain(int argc, _TCHAR* argv[])
{
    foo(a);
    foo(a);
    printf("%d\n", *a);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我可以清楚地调试它,并看到该行*a += x没有做任何事情,而且我可以看到x在离开函数之前仅一秒钟的值22并且它打印出来13.

当我在脑海中做到这一点时,我已经34岁了,据我所知,这应该是正确的答案.有人可以解释我可能错在哪里吗?

c

0
推荐指数
1
解决办法
135
查看次数

为什么我在这里得到两个不同的输出?

以下两段代码产生两种不同的输出.

//this one gives incorrect output
cpp_dec_float_50 x=log(2)
std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_50>::digits)<< x << std::endl;
Run Code Online (Sandbox Code Playgroud)

它给出的输出是

0.69314718055994528622676398299518041312694549560547

这是唯一正确的小数点后15位.如果x是双倍的话,即便如此,我们也会得到前15位正确的数字.似乎结果溢出了.我不知道为什么它应该.cpp_dec_float_50应该具有50位精度.

//this one gives correct output
cpp_dec_float_50 x=2
std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_50>::digits)<< log(x) << std::endl;
Run Code Online (Sandbox Code Playgroud)

它给出的输出是

0.69314718055994530941723212145817656807550013436026

根据wolframaplha这是正确的.

c++ floating-point boost

0
推荐指数
1
解决办法
86
查看次数

兼容模式下x64窗口上的本机x32应用程序与x32窗口上的x32应用程序之间的差异

我有一个用C++编写的旧的原生win32应用程序,它可以在Windows x32上正常工作,但它在Windows x64上崩溃了.即使我选择兼容模式.我有一个源代码,但它不容易阅读,因为它是由一个不再在我们公司工作的人编写的,代码非常庞大且异步.不容易调试的任务.

我想知道我应该关注什么.与x32 windows相比,x32兼容模式下的x64窗口有什么不同?我知道注册表可以产生一些问题,但似乎不是这种情况.还有别的吗?

c++ 64-bit winapi native

0
推荐指数
1
解决办法
175
查看次数

打印出具有最长长度的行,具有最高ASCII值总和的行或具有最大字数的行

我需要一些帮助来打印出具有最长长度的行,具有最高ASCII值总和的行,或者来自文本文件的具有最大字数的行.这是我第一次编程,我真的很挣python而且不​​知道如何计算本周需要我的实验室.我试图解决它,但到目前为止没有运气.谁能帮帮我吗?

python

-1
推荐指数
1
解决办法
248
查看次数

make函数返回数据结构的标题

有几种数据类型.

data Book =BName| Author deriving (Eq,Show)
data Video = VName deriving (Eq,Show)
data CD =Cname | Auth | NOC deriving (Eq,Show)
data Product = Product Book Video CD deriving (Eq,Show)
Run Code Online (Sandbox Code Playgroud)

make function getTitle返回结构名称(BName,CName或VName).例如getTitle(Book"name"noname") - >"name"getTitle(Vide"name") - >"name"等.

可能吗?

存在数据类型Book with field title and author,Videocassete with field author,CDdisk with fields title,composition of composition and author.1)创建数据类型可以引入此数据类型的产品2)使函数getTitle返回标题.3)使函数getTitles返回产品列表中的所有标题(使用函数getTtitle)4)使函数bookAuthors返回产品列表中的书籍作者5)使函数lookupTitle :: String - > [Product] - > Maybe返回带有输入名称的产品的产品6)使函数lookupTitles :: [String] - > [Product] - > [Product]输入params是名称列表和产品列表,并且每个名称从列表中获取产品产品.忽略第一个列表中的名称,而不是第二个列表中的产品.使用函数lookipTitle.

这都是一项任务.


data Book = Book String String deriving(Eq,Show)
data …
Run Code Online (Sandbox Code Playgroud)

haskell

-1
推荐指数
1
解决办法
270
查看次数

方程在C++中无法正常工作

//Samuel LaManna
//Program 1 (intrest rate)
/*Variables:
Principal=P
Interest Rate=R
Times Compounded=T
Answer=A */

#include <iostream>                                                                        //Input/output

using namespace std;

int main ()
{
  int P, R, T, A;                                                                          //Declaring Variables
  cout<<endl;
  cout<<"Interest Earned Calculator";                                                      //Prints program title
  cout<<endl;
  cout<<endl;
  cout<<"Please enter the Principal Value: ";
  cin >> P;
  cout<<endl;
  cout<<endl;
  cout<<"Please enter the Interest Rate (in decimal form): ";
  cin >> R;
  cout<<endl;
  cout<<endl;
  cout<<"Please enter the Number of times the interest is compounded in a year: ";
  cin …
Run Code Online (Sandbox Code Playgroud)

c++

-2
推荐指数
1
解决办法
618
查看次数