我目前正在尝试完成Nand to Tetris课程 ( Fill.asm)第 4 章中的项目。但是,汇编程序给了我以下错误:
“在第 3 行,预期表达”
我不确定我做错了什么……但下面是我的代码片段:
@i
M=1
@sum
M=8192
(END)
@END
0,JMP
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么我在第 3 ( @sum)行收到此错误?
我搜索过的每一本书,互联网上的每个教程以及SO上的每一个问与答都说,位域必须是整数类型。这是为什么?
我不太确定为什么我的 Nand2tetris 模拟器一直告诉我第 3 行错误。谁能告诉我以下代码的任何问题:
CHIP Xor {
IN a, b;
OUT out;
PARTS:
Not(in=a, out=nota);
Not(in=b, out=notb);
And(a=a, b=notb, out=m);
And(a=nota, b=b, out=n);
Or(a=m, b=n, out=out);
}
Run Code Online (Sandbox Code Playgroud) 我一直在研究CHIP8仿真器,并且正在notepad ++中使用十六进制编辑器来查看十六进制值。我碰巧注意到,某些游戏(例如David Winter的“ Blitz”)具有奇数个字节。


在CHIP8中,每个操作码长2个字节,因此应该有偶数个字节,对吗?
通常我总是这样编译我的C代码:g ++ program.c -o program.exe
但我的大学教授要求我编译使用:g ++ -o -Wall -Wextra -Werror -pedantic -std = c ++ 0x program.exe program.c
(这对我来说是新的).
所以......我运行命令并得到以下错误:
eda.c: In function ‘int main()’:
eda.c:200: error: ISO C++ forbids variable-size array ‘v’
eda.c:207: error: ISO C++ forbids variable-size array ‘nfloat’
cc1plus: warnings being treated as errors
eda.c:215: warning: suggest a space before ‘;’ or explicit braces around empty body in ‘while’ statement
Run Code Online (Sandbox Code Playgroud)
这是我的程序的代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef struct {
float* data;
int size; …Run Code Online (Sandbox Code Playgroud) 有人可以解释Herbert Schildt的这篇文章.
"整数类型的宽度不应该被认为是它消耗的存储量,而是它为该类型的变量和表达式定义的行为.Java运行时环境可以随意使用它想要的任何大小,只要类型的行为与你声明它们一样."
我正在研究nand2tetris,我最终得到了很多文件,最终看起来像这样:
Bit(in=in[0], load=load, out=out[0]);
Bit(in=in[1], load=load, out=out]1]);
...
Bit(in=in[15], load=load, out=out[15]);
Run Code Online (Sandbox Code Playgroud)
所以我一直在第一行,然后使用15p,然后做:s/0/i/g15次(i我需要的索引在哪里).我注意到我可以替换它:s/\[\d\]/\[i\]/g,但即使在这里我手动设置i每次运行命令的值.是否有一个命令我可以运行,以便i自动计算\d+1,我可以重复每行的命令,而无需手动指定值?
为什么在同一类锁上等待并通知函数不能正常工作?
请参阅以下检查代码,了解等待和通知功能及其输出.
输出:
Thread-1
Thread-2
Thread-2 after notify
Run Code Online (Sandbox Code Playgroud)
预期结果:
Thread-1
Thread-2
Thread-2 after notify
Thread-1 after wait
Run Code Online (Sandbox Code Playgroud)
码:
public class WaitAndNotify1 {
public static void main(String[] args) {
Thread t1=new Thread(new Runnable(){
@Override
public void run(){
System.out.println("Thread-1");
try {
synchronized (this) {
wait();
System.out.println("Thread-1 after wait");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
Thread t2=new Thread(new Runnable(){
@Override
public void run(){
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Thread-2");
synchronized (this) {
notify();
System.out.println("Thread-2 …Run Code Online (Sandbox Code Playgroud) nand2tetris ×3
c ×2
java ×2
assembly ×1
bit-fields ×1
byte ×1
chip-8 ×1
g++ ×1
hdl ×1
integer ×1
java-threads ×1
vim ×1