X86 ENTER: What’s That Second Parameter?

[Raymond Chen] wondered why the x86 ENTER instruction had a strange second parameter that seems to always be set to zero. If you’ve ever wondered, [Raymond] explains what he learned in a recent blog post.

If you’ve ever taken apart the output of a C compiler or written assembly programs,  you probably know that ENTER is supposed to set up a new stack frame. Presumably, you are in a subroutine, and some arguments were pushed on the stack for you. The instruction puts the pointer to those arguments in EBP and then adjusts the stack pointer to account for your local variables. That local variable size is the first argument to ENTER.

The reason you rarely see it set to a non-zero value is that the final argument is made for other languages that are not as frequently seen these days. In a simple way of thinking, C functions live at a global scope. Sure, there are namespaces and methods for classes and instances. But you don’t normally have a C compiler that allows a function to define another function, right?

Turns out, gcc does support this as an extension (but not g++). However, looking at the output code shows it doesn’t use this feature, but it could. The idea is that a nested function can “see” any local variables that belong to the enclosing function. This works, for example, if you allow gcc to use its extensions:

#include <stdio.h>

void test()
{
   int a=10;
   /* nested function */
   void testloop(int n)
   {
      int x=a;
      while(n--) printf("%d\n",x);
   }
   testloop(3);
   printf("Again\n");
   testloop(2);
   printf("and now\n");
   a=33;
   testloop(5);
}

void main(int argc, char*argv[])
{
   test();
}

Continue reading “X86 ENTER: What’s That Second Parameter?”

Can Google’s New AI Read Your Datasheets For You?

We’ve seen a lot of AI tools lately, and, of course, we know they aren’t really smart, but they sure fool people into thinking they are actually intelligent. Of course, these programs can only pick through their training, and a lot depends on what they are trained on. When you use something like ChatGPT, for example, you assume they trained it on reasonable data. Sure, it might get things wrong anyway, but there’s also the danger that it simply doesn’t know what you are talking about. It would be like calling your company’s help desk and asking where you left your socks — they simply don’t know.

We’ve seen attempts to have AI “read” web pages or documents of your choice and then be able to answer questions about them. The latest is from Google with NotebookLM. It integrates a workspace where you can make notes, ask questions, and provide sources. The sources can be text snippets, documents from Google Drive, or PDF files you upload.

You can’t ask questions until you upload something, and we presume the AI restricts its answers to what’s in the documents you provide. It still won’t be perfect, but at least it won’t just give you bad information from an unknown source. Continue reading “Can Google’s New AI Read Your Datasheets For You?”

Modern Spark Gap Transmitter Uses A Rotary Gap

In the “don’t try this at home” category, [Joe Smith] builds a spark gap transmitter with a twist. The twist is that the drive power is from a signal generator attached to a FET. From there, though, things go classic using an automotive ignition coil and a tank circuit. He shows how adjusting the spark frequency changes the signal’s sound in a standard receiver.

We say don’t try this at home because the output of a transmitter like this will likely spew RF all over the place. Granted, there’s probably not much power, but it may well irritate your neighbors.

Switching to AM, you can really hear the tone from the spark frequency in the receiver. [Joe] posted some earlier videos where he made a 160-meter spark gap transmitter using an electric fly swatter. There are more details about how the tank circuits work in those videos. You can also see what the output looks like on a spectrum analyzer. You can hear what that transmitter sounds like, too.

Continue reading “Modern Spark Gap Transmitter Uses A Rotary Gap”

Fast Paper Tape For The Nuclear Family

We’ve enjoyed several videos from [Chornobyl Family] about the computers that controlled the ill-fated nuclear reactor in Chornobyl (or Chernobyl, as it was spelled at the time of the accident). This time (see the video below) they are looking at a high-speed data storage device. You don’t normally think of high-speed and paper tape as going together, but this paper tape reader runs an astonishing 1,500 data units per second. Ok, so that’s not especially fast by today’s standards, but an ASR33, for example, did about 10 characters per second.

An IBM2400 tape drive, for reference, could transfer at least 10 times that amount of data in a second, and a 3400 could do even better. But this is paper tape. Magnetic tape had much higher density and used special tricks to get higher speeds mechanically using vacuum columns. It was still a pretty good trick to move 4 meters of paper tape a second through the machine.

Continue reading “Fast Paper Tape For The Nuclear Family”

SteamPunk Factory Comes To Life With An Arduino

It is one thing to make an artistic steampunk display. But [CapeGeek] added an Arduino to make the display come alive. The display has plenty of tubes and wires. The pressure gauge dominates the display, but there are lots of other interesting bits. Check it out in the video below.

From the creator:

The back-story is a fictional factory that cycles through a multistage process. It starts up with lights and sounds starting in a small tube in one corner, the needle on a big gauge starts rising, then a larger tube at the top lights up in different colors. Finally, the tall, glass reactor vessel lights up to start cooking some process. All this time, as the sequence progresses, it is accompanied by factory motor sounds and bubbling processes. Finally, a loud glass break noise hints that the process has come to a catastrophic end! Then the sequence starts reversing, with lights sequentially shutting down, the needle jumps around randomly, then decreases, finally, all lights are off, indicating the factory shutting down.

Continue reading “SteamPunk Factory Comes To Life With An Arduino”

Printing With Glass Fiber Filament

[ModBot] has been trying different engineering plastics for 3D printing. He recently looked at carbon fiber mixed with PET, but this time, he shows us his results with PET with glass fiber, or PET-GF. You can see how it all turned out in the video below.

The first part of the video compares the specifications, and, as you might expect, some factors are better for carbon fiber, and others are better for glass fibers. Once he gets to the printing, he covers the high temperatures needed (280-320C). He also talks about how either fiber will chew up nozzles and extruders.

Continue reading “Printing With Glass Fiber Filament”

Clockhands For Faster CPU Execution

When you design your first homebrew CPU, you probably are happy if it works and you don’t worry as much about performance. But, eventually, you’ll start trying to think about how to make things run faster. For a single CPU, the standard strategy is to execute multiple instructions at the same time. This is feasible because you can do different parts of the instructions at the same time. But like most solutions, this one comes with a new set of problems. Japanese researchers are proposing a novel way to work around some of those problems in a recent paper about a technique they call Clockhands.

Suppose you have a set of instructions like this:

LOAD A, 10
LOAD B, 20
SUB A,B
LOAD B, 30
JMPZ  DONE
INC B

If you do these one at a time, you have no problem. But if you try to execute them all together, there are a variety of problems. First, the subtract has to wait for A and B to have the proper values in them. Also, the INC B may or may not execute, and unless we know the values of A and B ahead of time (which, of course, we do here), we can’t tell until run time. But the biggest problem is the subtract has to use B before B contains 30, and the increment has to use it afterward. If everything is running together, it can be hard to keep straight.

Continue reading “Clockhands For Faster CPU Execution”