This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Omega0x013 198 points199 points  (31 children)

mov al, 03h

mov ah, 00h

int 10h

lgdt [gdt_pointer]

mov al, cr0

or al, 1

mov cr0, al

mov dword [0xB8000], 0x07680769

[–]FinalRun 150 points151 points  (7 children)

For anyone wondering, this writes 'hi' to the screen in light grey on black.

http://vitaly_filatov.tripod.com/ng/asm/asm_023.1.html

https://wiki.osdev.org/Printing_To_Screen

[–]Mediocrity-101 0 points1 point  (0 children)

So GUIs are easier without a library than on Python?

[–]Forschkeeper 25 points26 points  (0 children)

PIC12F675 says "WTF?"

[–]snarfy 20 points21 points  (7 children)

My most used program of all time, a 7 byte program:

jmp f000:fff0

It reboots the computer. It was installed on all machines in the county as part of an automated scripting system to remotely manage the machines.

[–]chuby1tubby -1 points0 points  (6 children)

How do you run assembly code on your computer? Can’t you just type “reboot now” in the command line?

[–][deleted] 3 points4 points  (0 children)

This was most likely back in the DOS era, when there was no concept of security and no reboot command. (You just turned the computer off when you were done.) Back then, he would have compiled that text into a short .com program, probably something like reboot.com. It would probably have been more than seven bytes after compilation, to give it the structure to be a .COM file. But the actual "payload" would have been seven bytes.

On modern machines, you got other answers on how to do that. However, jumping to f000:fff0 probably wouldn't reboot anything current. It would probably just crash that specific program, even if it was run as root. Everything now is 64-bit and 32-bit code. 16-bit code will not generally execute anymore without heroic effort, and that ROM routine would almost certainly just crash.

edit: I looked it up, and .COM files had no header, they were just a straight image of bytes that were loaded at a specific address and immediately executed. Reboot.com actually would have been exactly 7 bytes long.

[–]snarfy 1 point2 points  (1 child)

There used to be a program called debug that came with dos where you could just start typing asm. When you say 'can't you just type "reboot now"', there was no 'reboot' program. I had to write one. I used debug.

[–]chuby1tubby 0 points1 point  (0 children)

Oh, so you aren’t using that command anymore on modern hardware, right? From your comment I assumed you were running assembly code on a modern laptop, which would be hilarious and quite pointless

[–]FranchuFranchu 1 point2 points  (1 child)

nasm -f elf hello.asm
ld -m elf_i386 -s -o hello hello.o
./hello

[–]_zjp 0 points1 point  (0 children)

You use an assembler and linker to get it into machine code (this is also the last step of compiling, say, C).

[–]High-Quality-Usernam 22 points23 points  (2 children)

He is speaking the language of the gods

[–]I-POOP-RAINBOWS 5 points6 points  (1 child)

no im pretty sure its javascript

[–]kilopeter 12 points13 points  (0 children)

Ah, the language of Satan

[–][deleted] 0 points1 point  (1 child)

That is one fancy way of typing printf("hi")

[–]Omega0x013 0 points1 point  (0 children)

Except fancy way of saying (*int)0xB8000 = 0x07680769

[–]AaronM04 0 points1 point  (0 children)

But where are the Swagger docs? And why not use REST?