Skip to content

Instantly share code, notes, and snippets.

View ifknot's full-sized avatar
💭
Get off my lawn!

ifknot ifknot

💭
Get off my lawn!
View GitHub Profile
@ifknot
ifknot / sum_array_float.h
Last active February 1, 2023 22:38
double precision sum an array single precision floats assembly language 8087 x87 NPX FPU math coprocessor
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
@ifknot
ifknot / is_installed_npx.h
Last active February 1, 2023 19:20
Detect if installed assembly language 8087 x87 NPX FPU math coprocessor
/**
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
*/
@ifknot
ifknot / expr.asm
Created January 29, 2023 16:49 — forked from tanayseven/expr.asm
8087 assembly level program to evaluate (x+y)(a+b)/(a+b)(x-y), floating point
;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
@ifknot
ifknot / example.txt
Created October 17, 2020 16:08
read_csv, as_dates example
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
@ifknot
ifknot / main.cpp
Created October 17, 2020 16:05
read_csv, as_dates example
#include <iostream>
#include "data_frame.h"
#include "read_csv.h"
#include "head.h"
#include "as_dates.h"
using namespace R;
int main() {
@ifknot
ifknot / as_dates.cpp
Created October 17, 2020 16:01
convert int or string to dates
#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;
@ifknot
ifknot / as_dates.h
Created October 17, 2020 16:00
convert int or string to dates
#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.
*
@ifknot
ifknot / headp.cpp
Created October 17, 2020 15:53
r-ish head
#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;
@ifknot
ifknot / head.h
Created October 17, 2020 15:52
r-ish head
#pragma once
#include "data_structures.h"
namespace R {
/**
* Returns the first n items of a variant vector
*/
@ifknot
ifknot / read_csv.cpp
Last active October 17, 2020 15:51
read csv data
#include "read_csv.h"
#include "tokenize.h"
#include <fstream>
#include <sstream>
#include <iostream>
namespace R {