This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double sum_array_float(const float* array, uint16_t count) { | |
double sum; | |
__asm { | |
.8086 | |
.8087 | |
mov cx, count | |
jcxz END | |
lds si, array ; ds:[si] points to array of floats size cx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
The documented way to detect an x87 FPU (or, as per Intel, Numeric Processor eXtension - NPX) | |
is to attempt to initialise it, and then read its control word. | |
If the status word is *not* 0 after this, no NPX is installed. | |
The NPX socket is supposed to be wired in such a way that at least one of | |
the lower eight bits of the status word floats high when no NPX is installed. | |
@note Must use the non-waiting instruction variants, | |
otherwise the CPU will wait forever for a non-existent NPX to respond. | |
@url https://retrocomputing.stackexchange.com/questions/16529/detecting-the-external-x87-fpu | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;8087 program to evaluate (x+y)(a+b)/(a+b)(x-y) | |
data segment | |
a dd 3.2 | |
b dd 2.1 | |
x dd 6.3 | |
y dd 7.7 | |
result dd ? | |
ends data | |
code segment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read dumb data into heterogeneous container | |
manufacturer model hwy displ year cyl drv cty trans fl class | |
(str) (str) (int) (num) (date) (int) (str) (int) (str) (str) (str) | |
0 audi a4 29 1.8 1999 4 f 18 auto(l5) p compact | |
1 audi a4 29 1.8 1999 4 f 21 manual(m5) p compact | |
2 audi a4 31 2 2008 4 f 20 manual(m6) p compact | |
3 audi a4 30 2 2008 4 f 21 auto(av) p compact | |
4 audi a4 26 2.8 1999 6 f 16 auto(l5) p compact | |
5 audi a4 26 2.8 1999 6 f 18 manual(m5) p compact |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "data_frame.h" | |
#include "read_csv.h" | |
#include "head.h" | |
#include "as_dates.h" | |
using namespace R; | |
int main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "as_dates.h" | |
#include <iomanip> | |
#include <sstream> | |
#include <stdexcept> | |
namespace R { | |
variant_vector as_dates(const variant_vector& dates, std::string format) { | |
variant_vector tm_dates; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "data_structures.h" | |
namespace R { | |
/** | |
* @brief (R-ish) as_dates convert between string representations and objects of type r_date representing | |
* calendar dates. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "head.h" | |
namespace R { | |
variant_vector head(const variant_vector& x, size_t n) { | |
return variant_vector (x.begin(), (x.size() < n) ? x.end() : x.begin() + 6); | |
} | |
data_frame head(const data_frame& x, size_t n) { | |
data_frame df; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "data_structures.h" | |
namespace R { | |
/** | |
* Returns the first n items of a variant vector | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "read_csv.h" | |
#include "tokenize.h" | |
#include <fstream> | |
#include <sstream> | |
#include <iostream> | |
namespace R { |
NewerOlder