小编F. *_* P.的帖子

关于低级软件的课程需要C和汇编项目建议

我有一个关于低级编程的课程,需要最后的项目(最后的教学大纲).它基本上是一个软件,可以使用你学到的所有东西.

我有一些想法,比如设计我自己的Roguelike(应该有点像Nethack,只有单人游戏),但我想对替代方案提出一些建议.它不一定是游戏,可以是任何东西.时间表是一个半月,我还有其他项目等,所以实施它不应该太费时间.

要求:

  • 使用时,至少,4个I/O装置,其中之一应该是鼠标或串行端口
  • 其中一些设备应使用中断,其他设备应使用轮询
  • 语言:C和大会(强制性,否则有惩罚)
  • 实现状态机

我们讲授的外围设备是:

  • 显卡 - 图形模式
  • 图形卡 - 文本模式
  • 老鼠
  • 键盘
  • 实时计数器
  • 板载扬声器(通过定时器0和2)
  • 串行端口

这是简略的教学大纲:

输入/输出外设及其操作过程地址空间中的直接映射以轮询模式和中断访问外设IA-32架构和中断控制器中的处理器中断.在汇编和C中编写中断服务程序研究一些典型的个人计算机外围设备,如键盘,鼠标,图形卡,实时时钟,定时器,扬声器和串口.

用C编程语言编程:与C++语言的主要区别; C中的结构化编程.进程的内存布局.函数调用:机制,参数传递,局部变量的存储和返回值.C和IA-32处理器系列组合中的组合编程.创建和使用图书馆.目标代码的静态链接.

使用软件开发工具:gcc,make,gdb,ar,prof,diff,patch和SVN

感谢您的时间!

c assembly projects

5
推荐指数
1
解决办法
2013
查看次数

CUDA初学者 - 在继续之前强制等待线程完成

我正在学习CUDA,目前我有类似的东西.

__device__ void iterate_temperatures(int fieldSize, Atom *atoms) {

  int temperature = threadIdx.x + blockDim.x * blockIdx.x;

  nAtoms = pow(fieldSize, DIMENSION);


  iterate_atoms<<< nAtoms >>>(atoms, nAtoms, temperature);
}
Run Code Online (Sandbox Code Playgroud)

事实上,每个温度都需要最后一个温度.

如何强制每个块等待最后一个块.

谢谢!

c++ cuda

5
推荐指数
1
解决办法
1185
查看次数

实现可以在C++中迭代的优先级队列

我需要为项目实现优先级队列,但是priority_queue没有指示STL,因为我们需要迭代所有元素并随机删除它们.

我们正在考虑将STL set用于此,将其包装在一个类中以使其成为ADT.

有更聪明的解决方案吗?

我们如何能够set公开使用某些公共成员职能呢?我们对迭代器等感兴趣

由于缺少虚拟析构函数,显然导出STL是不明智的:/


新代码:

#ifndef PRIORITYQUEUE_H_
#define PRIORITYQUEUE_H_

#include <set>

template<typename T, template<typename X> class impl_type = std::set>
class PriorityQueue {
    typedef impl_type<T> set_type;
    typedef typename set_type::iterator iterator;
public:
    void push(const T& x) {
        insert(x);

    }

    void pop() {
        erase(begin());
    }

    const T& top() const {
        return *begin();
    }
};

#endif /* PRIORITYQUEUE_H_ */
Run Code Online (Sandbox Code Playgroud)

所以,我们目前有这个.编译器不会抱怨插入,但它确实抱怨erase(begin())和return *begin():

there are no arguments to 'begin' that depend on a template parameter, …

c++ priority-queue

5
推荐指数
1
解决办法
5202
查看次数

C编译器错误 - 初始化程序不是常量

我有一个用于创建新功能的功能 GQueue

GQueue* newGQueue(int n_ele, int ele_size)
{
    GQueue* q = (GQueue*) malloc(sizeof(GQueue));
    if(!q) return NULL;

    q->ptr = malloc(n_ele * ele_size);
    if(!(q->ptr))
    {
        free(q);
        return NULL;
    }

    q->in = q->out = q->count = 0;
    q->size = n_ele; q->ele_size = ele_size;

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

我这样使用它:

volatile GQueue * kbdQueue = newGQueue(10, 1);

但是,此行发生以下编译错误:

Error: initializer element not constant

为什么会这样?10和1显然是常规C代码中不应该打扰的常量malloc等c99.

只有旗帜-Wall.

谢谢

c compiler-errors

4
推荐指数
1
解决办法
3431
查看次数

初学者C++ - 打开一个文本文件进行读取(如果不存在),如果不存在,则将其创建为空

我正在为基于文本的游戏编写一个高分子例程.这是我到目前为止所拥有的.

void Game::loadHiScores(string filename)
{
    fstream hiscores(filename.c_str()); // what flags are needed?
    int score;
    string name;
    Score temp;

    if (hiscores.is_open())
    {
        for (size_t i = 0; i < TOTAL_HISCORES && !(hiscores.eof()); ++i)
        {
            cin >> score >> name;
            temp.addPoints(score);
            temp.scoreSetName(name);
            hiScores.push_back(temp);
        }
    }
    else
    {
        //what should go here?
    }   

    hiscores.close();

}
Run Code Online (Sandbox Code Playgroud)

我怎样才能这样做:

如果文件存在,它应该是开放的阅读

ELSE文件应该被创建

谢谢你的时间

c++ text fstream text-files

3
推荐指数
1
解决办法
365
查看次数

在初学者C++代码上隐藏编译器错误

g ++ undefined reference to '__gxx_personality_sj0'在我的项目的两行中发出了一个模糊的错误.在这种情况下,这意味着什么?我google了很多,发现这通常与在C++中包含C代码或类似的东西有关,这不是我想要的.(我知道代码质量不高,但应该编译,我相信).

Projecto.cpp

#include "Projecto.h"
#include <iostream>
#include <iomanip>
#include <string>



Projecto::~Projecto() {} //THIS LINE GETS THAT ERROR

void Projecto::adicionaVerba(float quantia){

 verba+=quantia;

 if(verba > verbamaxima)
  verba -= quantia;
}

std::string Projecto::Tipo()
{ //THIS LINE GETS THAT ERROR

 return "Projecto";
}

void Projecto::Imprime()
{
 Identificador::Imprime();
 cout << verbamaxima << endl;
}


bool Projecto::operator> (const Projecto &proj2) const
{
 return proj2.verba > this->verba;
}
Run Code Online (Sandbox Code Playgroud)

Projecto.h

#ifndef PROJECTO_H_
#define PROJECTO_H_

#include <iostream>
#include <iomanip>
#include "Identificador.h"
#include <string> …
Run Code Online (Sandbox Code Playgroud)

c++ eclipse inheritance compiler-errors class

3
推荐指数
1
解决办法
5215
查看次数

PL/SQL DB触发器 - 如果不满足给定条件,则插入失败

我有一个小的测试数据库,我用它来学习SQL.
有一个Duel表,其中包含两个Pilot外键(决斗者).我想在插入之前检查决斗者是否还没有"遇到".

伪代码:

before insertion on Duel
for each row already in the table
  if ((new_row.numpilot1 = old_row.numpilot1 and new_row.numpilot2 = old_row.numpilot2) OR
      (new_row.numpilot1 = old_row.numpilot2 and new_row.numpilot2 = old_row.numpilot1)
     )
    insertion fails
Run Code Online (Sandbox Code Playgroud)

另一种选择是

tempnum integer;
select numpilot1 into tempnum from duel 
where (:NEW.numpilot1 = numpilot1 and :NEW.numpilot2 = numpilot2) OR
      (:NEW.numpilot1 = numpilot2 and :NEW.numpilot2 = numpilot1);

if tempnum == null
    fail insertion
Run Code Online (Sandbox Code Playgroud)

什么是PL/SQL(Oracle DBMS)版本?

sql oracle triggers plsql

3
推荐指数
2
解决办法
1987
查看次数

将十六进制字符作为参数传递的正确方法 - system()

我正在搞乱缓冲区溢出,我正在尝试执行返回libc漏洞.为了帮助我,我设计了以下perl脚本:

#!/usr/bin/perl

for ($i = 1; $i < 200; $i++) {
    print "count: $i\n";
    system("echo 1 | ./vuln " . "A"x$i . "\x20\x83\x04\x08AAAA\x5c\xf9\xff\xbf");
}
Run Code Online (Sandbox Code Playgroud)

以下是我定位的代码(./vuln):

#include<stdio.h>
#include<string.h>

main( int argc, char **argv)
{
    char buffer[80];
    printf("%d\n%s\n", strlen(argv[1]), argv[1]);
    getchar();
    strcpy(buffer, argv[1]);
    return 1;
}
Run Code Online (Sandbox Code Playgroud)

这是脚本的输出:

count: 1
1
A
count: 2
2
AA
count: 3
3
AAA
count: 4
4
AAAA
count: 5
5
AAAAA
Run Code Online (Sandbox Code Playgroud)

这表示最后一个字符串连接的部分(具有大量十六进制字符的部分)没有被成功传递为参数.

我在这做错了什么?

perl buffer-overflow

3
推荐指数
1
解决办法
555
查看次数

无法在C++中重载<< for Enum

我创建了一个枚举数据类型来定义可能的航班长度.我想重载它的<<运算符,所以表示更好.

当我编译它时,我得到以下错误(为了完整性而发布.基本上multiple definitions of operator <<(ostream&, Categoria&)):

g++ -oProjectoAEDA.exe src\voo.o src\tui.o src\tripulante.o src\tipoaviao.o src\manga.o src\main.o src\datahora.o src\companhiaaerea.o src\aviao.o src\aeroporto.o
src\tripulante.o: In function `ZlsRSoR9Categoria':
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.5.1/../../../../include/c++/4.5.1/new:103: multiple definition of `operator<<(std::ostream&, Categoria&)'
src\voo.o:C:\Users\Francisco\workspace_aeda\ProjectoAEDA\Debug/../src//headers/categoria.h:20: first defined here
src\tipoaviao.o: In function `ZlsRSoR9Categoria':
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.5.1/../../../../include/c++/4.5.1/new:103: multiple definition of `operator<<(std::ostream&, Categoria&)'
src\voo.o:C:\Users\Francisco\workspace_aeda\ProjectoAEDA\Debug/../src//headers/categoria.h:20: first defined here
src\manga.o: In function `ZlsRSoR9Categoria':
c:/mingw/bin/../lib/gcc/i686-pc-mingw32/4.5.1/../../../../include/c++/4.5.1/new:103: multiple definition of `operator<<(std::ostream&, Categoria&)'
src\voo.o:C:\Users\Francisco\workspace_aeda\ProjectoAEDA\Debug/../src//headers/categoria.h:20: first defined here
src\main.o: In function `ZlsRSoR9Categoria':
C:\Users\Francisco\workspace_aeda\ProjectoAEDA\Debug/../src//headers/categoria.h:20: multiple definition of `operator<<(std::ostream&, Categoria&)'
src\voo.o:C:\Users\Francisco\workspace_aeda\ProjectoAEDA\Debug/../src//headers/categoria.h:20: first defined here
src\companhiaaerea.o: In function …
Run Code Online (Sandbox Code Playgroud)

c++ enums compiler-errors operator-overloading

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

C++初学者 - 使用结构和常量时遇到麻烦!

我目前正在为一个大学项目开发​​一个简单的Scrabble实现.

但是,我不能让它的一部分工作!

看一下这个:

我的board.h:

http://pastebin.com/J9t8VvvB

错误所在的子程序:

//Following snippet contained in board.cpp
//I believe the function is self-explanatory...
//Pos is a struct containing a char, y, a int, x and an orientation, o, which is not   //used in this particular case
void Board::showBoard()
{
    Pos temp;
    temp.o = 0;

    for (temp.y = 'A'; temp.y < (65 + TOTAL_COLUMNS); ++temp.y)
    {
        for (temp.x = 1; temp-x < (1 + TOTAL_ROWS); ++temp.x)
        {
            cout << _matrix[temp].getContents();
        }
        cout << endl;
    }
}
Run Code Online (Sandbox Code Playgroud)

编译时返回的错误: …

c++ struct class global-variables

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