Verified Commit d56a2a81 authored by jD91mZM2's avatar jD91mZM2

WIP: Floating point support?

parent fab4e7ae
......@@ -72,6 +72,11 @@ dependencies = [
"termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "f80"
version = "0.1.0"
source = "git+https://gitlab.redox-os.org/redox-os/f80.git?rev=d8de286#d8de286afe27934c6ac002153e1610f100853ef9"
[[package]]
name = "gdb-remote-protocol"
version = "0.1.0"
......@@ -94,6 +99,7 @@ version = "0.1.0"
dependencies = [
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"f80 0.1.0 (git+https://gitlab.redox-os.org/redox-os/f80.git?rev=d8de286)",
"gdb-remote-protocol 0.1.0",
"libc 0.2.74 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -478,6 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
"checksum f80 0.1.0 (git+https://gitlab.redox-os.org/redox-os/f80.git?rev=d8de286)" = "<none>"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum hermit-abi 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
......
......@@ -13,7 +13,7 @@ env_logger = "0.7.1"
log = "0.4.8"
byteorder = "1.3.4"
num-traits = "0.2.12"
# f80 = { git = "https://gitlab.redox-os.org/redox-os/f80.git", rev = "d8de286" }
f80 = { git = "https://gitlab.redox-os.org/redox-os/f80.git", rev = "d8de286" }
libc = "0.2.71"
[[bin]]
......
all: minimal-asm redox-asm minimal-c signal-c sighandler-c sigsegv-c
all: minimal-asm redox-asm minimal-c signal-c sighandler-c sigsegv-c float-c
clean:
rm minimal-asm redox-asm minimal-c signal-c sighandler-c
......
#include "float.h"
#include <stdio.h>
int main() {
float f1 = 0.1;
float f2 = 0.2;
float f3 = f1 + f2;
printf("%g + %g = %g\n", (double) f1, (double) f2, (double) f3);
double d1 = 0.1;
double d2 = 0.2;
double d3 = d1 + d2;
printf("%g + %g = %g\n", d1, d2, d3);
}
use byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt};
use f80::f80;
#[derive(Default)]
pub struct Registers {
......@@ -95,14 +96,14 @@ impl Registers {
fs: Some(input.read_u32::<NativeEndian>().unwrap()),
gs: Some(input.read_u32::<NativeEndian>().unwrap()),
st0: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st1: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st2: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st3: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st4: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st5: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st6: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st7: Some(input.read_u64::<NativeEndian>().map(|_| 0).unwrap()),
st0: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st1: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st2: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st3: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st4: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st5: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st6: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
st7: Some(input.read_u64::<NativeEndian>().map(|bits| f80::from_f64(f64::from_bits(bits)).to_bits()).unwrap()),
fctrl: Some(input.read_u32::<NativeEndian>().unwrap()),
fstat: Some(input.read_u32::<NativeEndian>().unwrap()),
ftag: Some(input.read_u32::<NativeEndian>().unwrap()),
......@@ -163,14 +164,14 @@ impl Registers {
output.write_u32::<NativeEndian>(self.fs.unwrap_or(0)).unwrap();
output.write_u32::<NativeEndian>(self.gs.unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(0).unwrap();
output.write_u64::<NativeEndian>(self.st0.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st1.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st2.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st3.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st4.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st5.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st6.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u64::<NativeEndian>(self.st7.map(|bits| f80::from_bits(bits).to_f64().to_bits()).unwrap_or(0)).unwrap();
output.write_u32::<NativeEndian>(self.fctrl.unwrap_or(0)).unwrap();
output.write_u32::<NativeEndian>(self.fstat.unwrap_or(0)).unwrap();
output.write_u32::<NativeEndian>(self.ftag.unwrap_or(0)).unwrap();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment