我尝试创建一个打印"hello world"的简单引导程序.
当我调用一个只打印"hello world"的函数时,我可以这样做,但是当我调用一个函数来打印一个特定的字符串时,什么也没发生.
为此,我使用两个文件.第一个是boot.ld,第二个是boot.cpp(它也可以在C中使用boot.c).
首先,我从终端创建软盘:
dd if =/dev/zero of = floppy.img bs = 512 count = 2880
其次,我编译代码(boot.cpp和boot.ld):
gcc -c -g -Os -m64 -ffreestanding -Wall -Werror boot.cpp -o boot.o
ld -static -Tboot.ld -nostdlib --nmagic -o boot.elf boot.o
objcopy -O binary boot.elf boot.bin
最后,我将boot.bin添加到floppy.img中:
dd if = boot.bin of = floppy.img
现在我们只需要从VirtualBox的存储面板添加软盘并启动我们的虚拟机.
源代码
来自:http://www.codeproject.com/Articles/664165/Writing-a-boot-loader-in-Assembly-and-C-Part
boot.ld
ENTRY(main);
SECTIONS
{
. = 0x7C00;
.text : AT(0x7C00)
{
*(.text);
}
.sig : AT(0x7DFE)
{
SHORT(0xaa55);
}
}
Run Code Online (Sandbox Code Playgroud)
boot.cpp(或boot.c)
void cout(); …Run Code Online (Sandbox Code Playgroud) 我有API Sphinx4的问题,我无法弄清楚为什么它不起作用.
我尝试写一个小类来捕获用户的声音并在文件上写下他的发言.
1)我在Eclispe上创建了一个新的java项目.
2)我创建了TranscriberDemo类.
3)我创建了一个文件夹"file".
4)我在文件夹"file"上复制文件夹"en-us"和文件"cmudict-en-us.dict","en-us.lm.dmp","10001-90210-01803.wav" .
5)我不使用maven,所以我只包含jar文件"sphinx4-core-1.0-SNAPSHOT.jar"和"sphinx4-data-1.0-SNAPSHOT.jar".
你可以在这里下载它们:
核心:https://1fichier.com/?f3y6vqupdr
数据:https://1fichier.com/?lpzz8jyerv
我知道源代码可用
这里:https://github.com/erka/sphinx-java-api
或者在这里:http://sourceforge.net/projects/cmusphinx/files/sphinx4
但我不使用maven所以我无法编译它们.
我的课:
import java.io.InputStream;
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.SpeechResult;
import edu.cmu.sphinx.api.StreamSpeechRecognizer;
import edu.cmu.sphinx.result.WordResult;
public class TranscriberDemo
{
public static void main(String[] args) throws Exception
{
System.out.println("Loading models...");
Configuration configuration = new Configuration();
// Load model from the jar
configuration.setAcousticModelPath("file:en-us");
configuration.setDictionaryPath("file:cmudict-en-us.dict");
configuration.setLanguageModelPath("file:en-us.lm.dmp");
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);
InputStream stream = TranscriberDemo.class.getResourceAsStream("file:10001-90210-01803.wav");
stream.skip(44);
// Simple recognition …Run Code Online (Sandbox Code Playgroud) java speech-recognition speech-to-text voice-recognition sphinx4
今天我在谈论C++ 11中的新闻,如线程,to_string和stoi.
但事实上,所有这些在C++ 98中已经成为可能.
然后我决定比较旧库和新闻库:
C++ 11:
g ++ -std = c ++ 11 main.cpp
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
int main()
{
clock_t tStart = clock();
string input = "50";
for (int i = 0; i < 50000; i++)
{
int number = stoi(input);
}
cout << (double)(clock() - tStart) << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
C++ 98
g ++ main.cpp
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
using namespace std;
int main()
{
clock_t …Run Code Online (Sandbox Code Playgroud) 为什么Rust中不允许使用此语法:
fn main() {
let a = String::from("ping");
let b = a;
println!("{{{}, {}}}", a, b);
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译这段代码时,我得到了:
Run Code Online (Sandbox Code Playgroud)error[E0382]: use of moved value: `a` --> src/main.rs:5:28 | 3 | let b = a; | - value moved here 4 | 5 | println!("{{{}, {}}}", a, b); | ^ value used here after move | = note: move occurs because `a` has type `std::string::String`, which does not implement the `Copy` trait
实际上,我们可以简单地创建一个引用 - 在运行时它是不一样的:
fn main() {
let a = String::from("ping"); …Run Code Online (Sandbox Code Playgroud) c++ ×2
assembly ×1
bootloader ×1
c ×1
c++11 ×1
c++98 ×1
gcc ×1
java ×1
ownership ×1
rust ×1
scope ×1
shared-ptr ×1
sphinx4 ×1
stringstream ×1