torusle's comments

torusle | 10 days ago | on: Building a TB-303 from Scratch

The fun thing was the Roland Sync. You could sync up all the TB-303, TB-909 and all the others with a 5-pole DIN cable. The sync was badly implemented. It lagged, it had latency.

However!

As soon as you cabled all together their imperfections added up and they started to groove like nothing that has been heard before.

torusle | 3 months ago | on: Functional Quadtrees

"I could only find a couple tutorials/guides and both were imperative"

Aren't Quadtrees covered by almost all basic data-structure books? It is the most simple form of taking the binary tree into the next (2D) dimension.

torusle | 1 year ago | on: Reciprocal Approximation with 1 Subtraction

There are couple of tricks you can do if you fiddle with the bits of a floating point value using integer arithmetic and binary logic.

That was a thing back in the 90th..

I wonder how hard the performance hit from moving values between integer and float pipeline is nowadays.

Last time I looked into that was the Cortex-A8 (first I-Phone area). Doing that kind of trick costed around 26 cycles (back and forth) due to pipeline stalls back then.

torusle | 1 year ago | on: Show HN: A1 – Faster, Dynamic, More Reliable NFC Transactions

> 1. Apple having just announced it is opening up NFC > to developers means that both major mobile > platforms can now act as responding devices;

> 2. Mobile consumer hardware is sufficiently fast for the application > operations (eg. Cryptographic operations)

You are right here. It is possible to emulate a card using mobile phones. We've been able to shim/emulate any card for much longer.

The thing is: To connect to the payment system you need a certificate. And you simply don't get it unless you can prove that you have all kinds of security measures applied.

For android and apple, the actual payment stuff runs inside a isolated little micro-controller which has been certified and is temper proof/protected. This little thing is fortified so far that it will destruct itself when you try to open it up. There are alarm meshes, light sensors and much more inside the chip to detect any intrusion just to protect the certificate.

If you don't have that security, the payment providers will deny you their certificate, plain and simple.

You can build your own thing using card emulation via apps, but you will take all the risks.

How it works in practice is the following: These temper proof micro-controllers can run java-card code. You can write an applet for them, get it installed (if you have the key from apple/google - not easy). Then install it and you have a two-way communication: Your applet inside the secure world communicating with the payment world, and your ordinary mobile app showing things on the screen.

torusle | 1 year ago | on: Show HN: A1 – Faster, Dynamic, More Reliable NFC Transactions

I've worked in the payment industry and among other things built a payment terminal, so I know a thing or two about it.

1st: The message overhead during communication is not an issue. It is tiny compared to the time it takes for the credit card to do it's crypto thing.

2nd: This won't be adapted ever. There is simply way to much working infrastructure out there build on the APDU protocol. And there are so many companies and stakeholders involved that doing any change will take years. If they start aligning on a change, it would be something that makes a difference, not something that safes time in the order of 5 to 20 milliseconds. per payment.

torusle | 1 year ago | on: Things I learned while writing an x86 emulator (2023)

Another bonus quirk, from the 486 and Pentium area..

BSWAP EAX converts from little endian to big endian and vice versa. It was a 32 bit instruction to begin with.

However, we have the 0x66 prefix that switches between 16 and 32 bit mode. If you apply that to BSWAP EAX undefined funky things happen.

On some CPU architectures (Intel vs. AMD) the prefix was just ignored. On others it did something that I call an "inner swap". E.g. in your four bytes that are stored in EAX byte 1 and 2 are swapped.

  0x11223344 became 0x11332244.

torusle | 1 year ago | on: Own Constant Folder in C/C++

Nah, it is not that bad.

Sure you can mess up your performance by picking bad compiler options, but most of the time you are fine with just default optimizations enabled and let it do it's thing. No need to understand the black magic behind it.

This is only really necessary if you want to squeeze the last bit of performance out of a piece of code. And honestly, how often dies this occur in day to day coding unless you write a video or audio codec?

torusle | 1 year ago | on: Fast linked lists

In embedded, you often need message queues.

A common way to implement these is to have an array of messages, sized for the worst case scenario and use this as the message pool.

You keep the unused messages in a single linked "free-list", and keep the used messages in a double linked queue or fifo structure.

That way you get O(1) allocation, de-allocation, enqueue and dequeue operations for your message queue.

Another example for this paradigm are job queues. You might have several actuators or sensors connected to a single interface and want to talk to them. The high level "business" logic enqueues such jobs and an interrupt driven logic works on these jobs in the background, aka interrupts.

And because you only move some pointers around for each of these operations it is perfectly fine to do so in interrupt handlers.

What you really want to avoid is to move kilobytes of data around. That quickly leads to missing other interrupts in time.

torusle | 1 year ago | on: Fast linked lists

> Linked lists are taught as fundamental data structures in programming courses, but they are more commonly encountered in tech interviews than in real-world projects.

I beg to disagree.

In kernels, drivers, and embedded systems they are very common.

torusle | 1 year ago | on: The Myth of Loss: Bitboys

Hardware existed.

Around 2006 I had some automotive entertainment system from NEC on my table which had one of the Bitboys GPU chips on it. Wrote some vector graphics API for it.

It wasn't bad honestly. It supported OpenGL/ES 1.0 I only had to contact them twice for driver bugs. They resolved that within a few days.

torusle | 2 years ago | on: The Netwide Assembler (NASM)

I wrote thousands lines of assembler for NASM. It was such a nice update to the good old turbo assembler back in the 90th.

torusle | 2 years ago | on: MS-DOS v1.25 and v2.0 is now open-source (2014)

It wasn't that bad. You had different memory models back then. If you wanted to keep things easy you just compiled for a memory model in which each pointer was either 16 bit (for code/data smaller than 64kb) or a memory model with far pointers (access to all the memory).

There have been mixed memory models and you could go crazy with near and far to break out of the limits of the easy memory models.

Most of the time it was just a mater of picking a suitable memory model for your code and forget about near/far though. Not so different than today.

torusle | 2 years ago | on: MS-DOS v1.25 and v2.0 is now open-source (2014)

Oh, nice..

I browsed a little through the code, and found that sort.com used self-modified to change the sorting order:

  ; note! jae is patched to a jbe if file is to be sorted in reverse!
  ;
  CODE_PATCH LABEL BYTE
         JAE     INNER_SORT_LOOP

I committed similar crimes in the 90th as well, but that was just me as a teenager programming stupid games in asm for fun and giggles. Not for commercial software.
page 1