News for hackers. Stuff that matters.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by ivoras on Sunday October 30, 2022 @05:32PM (#33398960)
Crazy that once upon a time just sequences of machine code were written to files, without any headers, or checksums, or basically any modern metadata. Just plain machine code, to be directly fed into the CPU.

Cue lamentations of today's complexity mixed with feelings of life being great because of it.

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by pizza234 on Sunday October 30, 2022 @05:47PM (#33399111)
Yes, although this was for COM files only, which were limited to (64k - 0x100) bytes. EXEs didn't have this limitation, but they indeed had a header.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by WalterBright on Monday October 31, 2022 @02:39AM (#33402674)
Fun fact. The COM file size was limited to 64K. The program size was not. Most COM memory models set CS=DS=SS=ES. However, the Zortech C compiler, would have CS set differently.

CS pointed to the start of the code segment, DS to the start of the data segment. As long as the code segment plus the initialized data of the data segment was less than 64K, you could have a considerably larger runtime footprint (up to 128K) and still be a COM file with all near pointers.

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by stkdump on Monday October 31, 2022 @03:41AM (#33402999)
Actually, .com files can be larger. I don't know how exactly it was handled, but I distincly remember seeing versions of edit.com >64k
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by andrewshadura on Monday October 31, 2022 @03:55AM (#33403093)
They were .exe internally.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by WalterBright on Monday October 31, 2022 @04:24AM (#33403234)
I'm not sure when it started, but the .com and .exe extensions were ignored, and the loader looked at the first two bytes to see if it was "MZ" and was an exe file.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by sumtechguy on Monday October 31, 2022 @08:15AM (#33404693)
I like that every windows exe/dll still have the MZ on the front. Also a working DOS program there in the first hundred bytes which is pretty much a program to say 'hey run this in windows'. As the real windows header is 100 bytes in.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by teh_klev on Monday October 31, 2022 @07:05AM (#33404191)
There was a technique that used a thing called overlays[0]. You could write a program that is much larger than the available address space (64k on MS/PCDOS) but you split it up into functional areas or modules that are loaded on demand into a reserved area of your 64k address space.

[0]: https://en.wikipedia.org/wiki/Overlay_(programming)

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by Lt_Riza_Hawkeye on Sunday October 30, 2022 @05:47PM (#33399112)
And before that, they were toggled directly into the machine using physical switches!
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by WalterBright on Monday October 31, 2022 @02:41AM (#33402682)
Pretenders with your advanced technology. I had to use a plugboard.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by mikewarot on Monday October 31, 2022 @05:22AM (#33403535)
I first used toggle switches to input things into a PDP-11/?? I was trying to debug back in 1982 at Rose-Hulman. I next used them to toggle things into an IMSAI earlier this year... the PDP-11 had a better feel, but in both cases it really sucks.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by pjc50 on Sunday October 30, 2022 @05:59PM (#33399258)
If you're programming a microcontroller, that time is now.

(OK, so it'll often be the output of a C compiler, but there's usually some work to be done in asm to get the system in a state with a stack, clocks, RAM etc to run a C program!)

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by 13of40 on Sunday October 30, 2022 @06:13PM (#33399412)
MS-DOS v1 didn't have an assembler in debug.exe (or was it .com?) so the only way to author machine code on a 5150 with no extra dev tools was to code it on paper, translate it by hand, and enter it in hex.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by susam on Sunday October 30, 2022 @06:41PM (#33399739)
You are right. It was DEBUG.COM. Indeed it did not have an assembler. It had a disassembler though. An archived copy of it can be found here: https://github.com/microsoft/MS-DOS/blob/master/v1.25/bin/DE...

  C:\>DEBUG.COM
  -A
   ^ Error
  -N HELLO.COM
  -L
  -U 100 107
  0340:0100 B409          MOV     AH,09
  0340:0102 BA0801        MOV     DX,0108
  0340:0105 CD21          INT     21
  0340:0107 C3            RET
  -
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by WalterBright on Monday October 31, 2022 @02:48AM (#33402721)
Here's a one file disassembler for x86 and its successors:

https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ba...

The fun thing to do with it is send it your name and have it disassemble it.

(I use it to check the object code generated by the compiler. Instead of pretty-printing the instruction stream, it disassembles the binary object code. This helps to find mistakes in either the code generation or the disassembler, as they must match.)

Anyhow, feel free to incorporate it into your obj file dumper, exe file dumper, debugger, or any tool that can benefit by examining code.

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by 6510 on Sunday October 30, 2022 @09:25PM (#33400961)
You could load the 12 characters directly into the screen memory and make useful use of the meta data.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by yieldcrv on Sunday October 30, 2022 @10:53PM (#33401553)
Programming smart contracts is like writing to a bunch of distributed microcontrollers

The limitations are similar and you can do assembly level coding

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by londons_explore on Monday October 31, 2022 @02:51AM (#33402732)
And you frequently do do assembly level coding, either because you're cheap and need to eliminate every byte, or because you're trying to slap an 'accidental backdoor' on there to steal all your users coins...
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by dist1ll on Monday October 31, 2022 @08:21AM (#33404738)
Well, DLTs are supposed to abstract away the distributed-ness. The execution layer usually provides computational primitives, basic memory and cryptographic functions. Not much distributed computing there.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by yieldcrv on Monday October 31, 2022 @01:24PM (#33409246)
who did you write that for?

its more similar to distributed microcontrollers by a matter of fact that the nodes don't allow much processing and there are many nodes that replicate the function. it is less similar to simply microcontrollers or simply distributed computing.

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by Brian_K_White on Monday October 31, 2022 @12:38AM (#33402140)
One of my favorite old bbs taglines was "Real programmers use copy con file.exe"

Mighta been file.com. Mighta been real men.

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by anjanb on Monday October 31, 2022 @12:52AM (#33402207)
I still create one liner batch files using copy con <batchfilename.bat>
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by aricz on Monday October 31, 2022 @03:06AM (#33402806)
alt+f6 <enter> to save
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by rep_lodsb on Monday October 31, 2022 @04:26PM (#33412481)
IIRC it's just F6, which is simply an alias for Ctrl+Z (ASCII code 26). That was the end-of-file marker on CP/M.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by aricz on Tuesday November 01, 2022 @03:49AM (#33418190)
I stand corrected, you're right. You only need to press F6 <enter>.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by rep_lodsb on Monday October 31, 2022 @04:01PM (#33412056)
On the PC you can enter pretty much any byte by holding Alt and typing the (decimal) value on the number pad. But here's a "Hello world" in plain ASCII, that works on two different CPU architectures (x86 and 8080):

x)y'!B:)),DM!G@))p,T]l%)),@@@Hello, world!$XP5]A%=!P[PZ^V!wV!wX5.<(GV(gX534,!(GWr!

My first version was shorter than 80 characters and "symmetrical" (same number of bytes before and after the string), but it didn't work on the 80486 and under DOSBox. The '486 needed an extra jump to clear the pipeline, and DOSBox didn't support the CP/M "CALL 5" interface.

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by cestith on Wednesday November 02, 2022 @11:31AM (#33437479)
I don't have the code handy, but I once was hanging out with a buddy in an OS/2 lab at uni and used copy con to write a reboot COM program. I meant it to be a soft reboot, but it ended up being a simulated hard boot.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by grishka on Monday October 31, 2022 @01:56AM (#33402495)
Yes but also multitasking is a very notable UX improvement, and virtual memory, its part that gives processes separate address spaces, makes sure that one buggy program won't bring the entire OS down with it. With OSes providing applications with more services (stuff DOS didn't have like a network stack, GUI, abstracted access to all kinds of complex hardware) you start wanting dynamic libraries, which are impossible to implement sanely without some kind of metadata in the executable.
Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by rrwo on Monday October 31, 2022 @05:19AM (#33403520)
If I recall correctly, the COM (stands for something like "COre Memory image") file format is limited to 64k, and was intended to be loaded into the same memory location.

It dates back to CP/M days.

Re:A 28-byte “hello, world” program assembled with DEBUG.EXE... by IncRnd on Monday October 31, 2022 @12:11PM (#33407825)
Before that, on vax, COM files were text files that contained commands to execute.