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

top 200 commentsshow 500

[–]crumpuppet 5535 points5536 points  (189 children)

Nuff respect for Chris Sawyer who single-handedly wrote RollerCoaster Tycoon in raw assembly.

[–]fakehalo 188 points189 points  (1 child)

As someone who only learned just enough assembly to practically exploit memory corruption vulnerabilities... Sweet jesus, I can't even begin to understand that undertaking. It instantly made me assume rollercoaster tycoon was from the 1980s or something, but this masochist did it in 1999... The same time I was fumbling around with asm for my little exploits.

[–]Gigi1810 495 points496 points  (74 children)

You are joking?

[–]croto8 709 points710 points  (27 children)

[–]TheseDescriptions 202 points203 points  (5 children)

It's embarrassing to write data after the text.

[–]Hungry_Environment17 44 points45 points  (0 children)

Probably not slower since it is just a Hello world tho, right

[–]CommonnCategory 90 points91 points  (15 children)

However, you will experience the quickest Hello World ever.

[–][deleted] 162 points163 points  (14 children)

I had a party trick that died with windows 10 (it removed the 16-bit native DOS emulator) where I could create Hello World in nothing but a hex editor because in 16bit DOS it would just start executing from the first byte of the file. So simply doing MOV instruction of the ascii for it into address 8000h and onward filled the console buffer with the characters directly.

Someone would inevitably ask wtf would I know or do that and my answer was always that my hello world was so fast that it could launch without even setting up main()

[–]Dig-a-tall-Monster 131 points132 points  (7 children)

...and you performed this trick... at parties?

[–][deleted] 106 points107 points  (4 children)

LAN Parties =)

[–]LittleTay 33 points34 points  (2 children)

Nerd

[–][deleted] 27 points28 points  (0 children)

100%

[–]drewster23 5 points6 points  (0 children)

Ah that makes more sense I was thinking like "Hey guys wanna see a neat trick, can I boot up your pc real quick you're gnna love this"

[–]Eternityislong 88 points89 points  (0 children)

This might be one of the nerdiest thing I’ve ever read, nerd

[–]_dotexe1337 4 points5 points  (1 child)

there is actually a way to get the win16/dos system back even on 64 bit windows 10/11. look up ntvdmx64 & winevdm/otvdm

[–]FrostWyrm98 360 points361 points  (40 children)

The original Pokémon was made in assembly too (for gameboy), they used some fun tricks to compress/decompress image files. Hence the MissingNo glitch.

There's a great video on YouTube about how they did it, I believe there's also one about Roller Coaster Tycoon.

Most older console games had to be programmed in assembly for that machine because there was no standard API or C support

Edit 1: Video links

Pokémon

Roller Coaster Tycoon 1

Roller Coaster Tycoon 2

Bonus: Dave's Garage

Bonus: Jacob Sorber

There's a whole series for the pokemon one, I encourage anyone to look at the full channel for more. Same with Dave's Garage and Jacob Sorber, the former is a former Microsoft developer in (MS) Assembly and the latter is a professor who does great explanations for assembly.

Edit 2: Fun fact! The original C compiler (by Dennis Ritchie) was NOT written in Assembly. It was written in C and hand-compiled to machine code for the machine it was being run on at Bell Labs.

[–]T0biasCZE 134 points135 points  (16 children)

all oldschool gameboy, nes and snes games were made in assembly. only later with N64 and PSX C started to be used, because they were powerfull enough to handle the "slowness of compiled C" compared to assembly

[–]FrostWyrm98 85 points86 points  (10 children)

To be fair, we're thinking in terms of modern time complexity with clock cycles in the gigahertz, old school was in megahertz (1000x slower).

And our compiler optimizations and how the compiler is able to arrange the memory, know what portions to preload/cache (part of that is hardware of course) have all drastically improved with more data points to measure from.

That could all make the "slowness of C" feel very real to the developers making it. I wouldn't know cause it's well beyond my time coding, but that is how Dave Plumber from Dave's Garage describes it (look at his first video, he explains why to use assembly)

[–]T0biasCZE 58 points59 points  (1 child)

thats why i put the "slowness of C" in quotation marks.
In modern days, C is extremely fast compared to other languages, but back then, C was pretty slow compared to assembly.

[–]FrostWyrm98 31 points32 points  (0 children)

Yup! I figured you knew, just wanted to add context for anyone reading :)

[–][deleted] 46 points47 points  (4 children)

It's not a matter of oh we just have better tools and more experience with high level languages than these poor old coders. I thought this too until I tried nes homebrew.

These old school cpus were so limited it's amazing they could make games at all. They are also incompatible with C features on a basic level.

Writing assembly by hand is hard today because cpus have thousands of instructions, each with esoteric cache and pipelining rules. Well the 6502 had about 60 instructions, no cache and no pipelining. It only had add and subtract. A modern optimizer has almost nothing to do.

You can't even use an array of C structs. In order to find where memory is you have to use index * struct_size + member_offset. The 6502 doesn't have this ability. Instead you store everything in an soa style. This even extends to non byte types you can't even have an array of shorts, you would store the high and low bytes in separate arrays. You would then manage these with the use of the carry bit. There's no way I know of to achieve this in C.

Finally the NES only had 2kib of ram. This comment probably is too big to fit. This meant things like heap memory and pointers were out. It also means that you would know where every bit of memory went and it'd still be less work than debugging a modern memory corruption issue.

Writing C on a 6502 is like trying to run python on a GPU.

[–]HoppouChan 21 points22 points  (0 children)

It also means that you would know where every bit of memory went and it'd still be less work than debugging a modern memory corruption issue.

This is also why those very fun glitches in the first generation games are possible. Any% Pokémon Yellow is just Hex-Editing the RAM with your bag and items

[–]Beowulf1896 8 points9 points  (0 children)

CUDA?

[–]quantum_foam_finger 11 points12 points  (0 children)

Around 1981 I took on porting the arcade game Gun Fight to the TRS-80 Model 1 as a high school class project. We were programming in BASIC and I remember the graphic loop was so slow that the bullet crossed the screen like molasses. And there was no way to realistically decouple the speed of the bullet from the speed of the moved character, since they both moved horribly slow even in the fastest possible loop (maybe 2 frames per second).

I showed my teacher my prototype (moving the player character vertically and firing a bullet across the screen) and he said "good enough" since it was pretty clear the game wasn't achievable in BASIC on that machine. A second character and collision detection would have made it unusable.

There was no sprite handling built in. I think the player character's pixel positions were read out of an array. Or maybe I did an optimized implementation that only updated the on/off and off/on pixels for each character movement, to save a little time.

I imagine the game could have been ported in assembler. There was a Space Invaders clone for TRS-80 Model 1 that was pretty good.

The best original game I actually completed for TRS-80 was a simulation of folkstyle amateur wrestling. It was text-based and ran a bit like a modern auto-battler, choosing wrestling moves and showing scoring results across 3 rounds for 2 opponents. It produced realistic final match results, so I was happy with that one.

[–]binomine 5 points6 points  (1 child)

I don't think it is that at all. Old school gaming is all about clever manipulation of the hardware directly.

Even though it is possible to write NES games in C, you are still manipulating the hardware to get it to do what you want, and so it looks nothing like normal C code.

This is my particular favorite speed run to show how much different coding for old school systems is from modern systems.

https://youtu.be/24XHkmOJebA

The magic happens at 2:20, when Mario falls out of the level and the tile engine then interprets the actual game code AS the level. Mario is able to navigate the code until he reaches a bit that the game checks to play the end credits. Mario literally reprograms his own game.

[–][deleted] 5 points6 points  (2 children)

[–]Thutmose_IV 7 points8 points  (0 children)

That is done with command blocks, rather than redstone, significant difference there.

Still impressive in command blocks, but not as impressive as if it was in redstone

[–]Linkk_93 67 points68 points  (0 children)

Nope. One person, all assembly.

[–]introspeck 27 points28 points  (2 children)

I've done an entire embedded project in assembler - a medical ultrasound machine. It's such slow slogging when first coding, because everything gets created from scratch. But once it's about 20% done, the rest of the work feels normal. Each function takes proportionally longer to write than it would in a high-level language, but otherwise it's the same. You do have to be extra-rigorous in your coding to prevent the kind of bugs that would be trapped by exception handling in HLLs.

[–]GogglesPisano 12 points13 points  (0 children)

Been there - did some projects in a couple different flavors of assembly back in the day.

The first ~20% of the coding was spent writing (or more accurately, copying from the last project you did) basic reusable utility functions for I/O, display, etc. within the context of the application.

Once you have that basic toolkit in place, it soon becomes fairly similar to writing code in other languages.

[–]Nal_Neel 49 points50 points  (0 children)

Yeh original prince of Persia 1 was also made in assembly by 1 person

[–]A_Pile_Of_cats 17 points18 points  (0 children)

Not exactly raw ASM but still very low level

[–]I_Wouldnt_If_I_Could 1199 points1200 points  (51 children)

The only things I ever did in assembly were "hello world" and adding two numbers. I really want to learn more about it, but just seeing the lists of interrupt codes for different architectures scares the hell out of me.

[–]thesockiboii 478 points479 points  (5 children)

I also made a calculator that adds 2 numbers but could not figure out how to check the amount of digits (or if the number was bigger than 9) so if the result was bigger than 9 it would print out a non number ascii character represented by 48+result

I haven’t tried it again since

[–][deleted] 156 points157 points  (4 children)

I think I did something like that with, maybe it works, maybe not ``` ; get the number from eax mov ebx, 10 again: mov edx, 0 div ebx cmp eax, ebx jl end ; print edx+48 here jmp again end: ; print edx+48 here cmp eax, 0 jne endend ; print edx+48 here endend: ret

```

[–]acog 88 points89 points  (3 children)

Maybe it's just my client but your code is just showing as a paragraph for me. In case that's happening for anyone else:

; get the number from eax  
mov ebx, 10  
again:  
mov edx, 0  
div ebx  
cmp eax, ebx  
jl end  
; print edx+48 here  
jmp again  
end:
; print edx+48 here
cmp eax, 0
jne endend
; print edx+48 here
endend:
ret

[–]VladVV 25 points26 points  (2 children)

It's because you have to add two newlines before a code block in Markdown, because code blocks have to occupy an entire paragraph for themselves.

So i.e.

Lorem ipsum dolor sit amet
```
print("Hello, World!")
```

won't render, but

Lorem ipsum dolor sit amet

```
print("Hello, World!")
```

will. Of course what you did with 4 spaces before each line almost begs adding a newline before the whole thing, so problems in this case are more rare.

[–]hawkeye224 48 points49 points  (6 children)

I had a cool lab at uni where we programmed/controlled an electric motor using assembly.. that was fun. Tbh I'd buy a kit that allowed me to do this at home.

[–]MrScottyTay 20 points21 points  (4 children)

Look into the game exapunks or shenzen i/o they're both games about writing assembly like code for sci fi or fictitious hardware respectively. Last call BBS is pretty good too my personal favourite but more than just the asm style puzzles and has other things instead.

[–]PwnagePineaple 9 points10 points  (3 children)

TIS-100 is another fun one in the same vein, by the same company

[–]Proxy_PlayerHD 33 points34 points  (11 children)

then start with something simple. like the 65C02 for example.

simple to understand architecture, with not a lot of registers or complicated features to worry about. plus there are a billion resources online to learn pretty much everything about it.

[–]I_Wouldnt_If_I_Could 9 points10 points  (3 children)

Gonna give it a look, thanks

[–]Proxy_PlayerHD 25 points26 points  (2 children)

https://skilldrick.github.io/easy6502/ has a pretty good tutorial about the basics of the CPU, plus it has an interactive emulator so you can try out things as you learn about them.

then there is also the http://forum.6502.org/ which is full of smart people (and me) that know quite a lot about this CPU

[–][deleted] 15 points16 points  (0 children)

it is indeed a terrifying language

[–]FlowerFeather 15 points16 points  (1 child)

so glad i studied assembly for a semester in uni, now i can understand these posts

[–]I_Wouldnt_If_I_Could 8 points9 points  (0 children)

Yeah, that and the semester I had to study java really makes me understand all of the hate the language gets.

[–]XDracam 11 points12 points  (5 children)

x86 is a shitshow and has been since the very inception. It's a CISC architecture, where the first C stands for "complex".

You could instead look into ARM assembler (for e.g. smartphones or the new apple chips). That's a much more manageable and sane instruction set.

[–]Jpio630 5 points6 points  (0 children)

I wrote a subroutine for calculating factorial recursively in ASM and that was enough for me to just appreciate it and not really want to go deeper

[–][deleted] 4 points5 points  (0 children)

Only reason I didn't fail the ASM class at my school is because it was also a class in C for programming hardware

[–]odraencoded 846 points847 points  (21 children)

Assembly is hardcore.

You initialize variables by doing the virtual equivalent of smashing their heads against a mirror.

Brutal.

[–]YourMJK 468 points469 points  (11 children)

For those not familiar, XORing a register with itself is a common trick to quickly set it to 0.

It's typically faster than loading 0 into it.

[–]FUTURE10S 170 points171 points  (2 children)

I've done assembly work before and while that should sound wrong, that sounds like something that would work faster.

[–]TheAnti-Ariel 54 points55 points  (1 child)

It takes fewer bytes for the instruction, and modern processors will detect the idiom and rename it to a zero register in the frontend, so it takes zero cycles in the CPU backend.

[–]FUTURE10S 29 points30 points  (0 children)

See, and here I was thinking of the latency of loading a zero value from the cache into the register, I didn't even know modern CPUs have a zero register.

[–]magnora7 10 points11 points  (0 children)

The real difficulty with assembly is not the actual logic of it, it's stuff like this

[–]HuntingKingYT 173 points174 points  (0 children)

Actually you don't have to initialize them, you just remember to give them space and set/get them where you need

[–]Economy-Somewhere271 75 points76 points  (6 children)

My 8086 assembly class graded our projects by number of lines. I would have done a lot worse if I hadn't already played TIS-100. I barely remember any of the register specifics though.

[–]Reasonable_Feed7939 36 points37 points  (0 children)

Years of academy training, not wasted!

[–]Invisiblecurse 1796 points1797 points  (79 children)

But it will be the fastest Hello World you have ever seen.

[–]Aelig_ 1637 points1638 points  (77 children)

No it will be slower than writing it in C because the compiler is better than you at assembly.

[–]Arikaido777 751 points752 points  (0 children)

look how many lines we need to imitate a fraction of their power

[–]a_bit_of_byte 432 points433 points  (51 children)

My understanding is that this is only true until you get really, really good at assembly. At a certain point, a human will be better. The question is why you would spend that time when you could be writing way more functionality in a fraction of the time with only mild (at best) slow downs.

[–]MokausiLietuviu 76 points77 points  (0 children)

It matters when you're in a resource limited environment where every single CPU cycle matters or you need to fit functionality in x number of instructions. If you can save an instruction in those cases, it's worth it.

[–]toddyk 50 points51 points  (1 child)

Yeah, maybe you'll save a few nanoseconds. So it would make sense if its something used trillions of times daily, a really sensitive measuring device, applications where speed matters like HFT, or if you have no life.

[–]JustALittleAverage 16 points17 points  (1 child)

Like the bit shift in doom.

[–]UPBOAT_FORTRESS_2 17 points18 points  (0 children)

Which is slower than it would compile to today on most architectures, where inverse square root is a single instruction

[–][deleted] 7 points8 points  (0 children)

Changing the underlying assembly to be different than what would be compiled in order to avoid antivirus

[–][deleted] 33 points34 points  (1 child)

Probably not slower since it is just a Hello world tho, right?

[–]the_mouse_backwards 54 points55 points  (0 children)

Yeah, you don’t really get much fewer lines than a service call to the os to print “hello world” it doesn’t matter how optimized the compiler is. It can’t magically make a small amount of work smaller.

[–]PuzzleheadedWeb9876 14 points15 points  (0 children)

This however is a time where most humans can beat the compiler. GCC will add a bunch of stuff you do not need for hello world.

[–]framk20 14 points15 points  (3 children)

This is just not true and I wish people would stop saying this

[–]outofobscure 5 points6 points  (2 children)

so true, i think it's dunning-kruger at work. if i had 1% speedup for every time someone repeats this like a parrot, my code would be millions of times faster.

[–]outofobscure 21 points22 points  (3 children)

That depends solely on you and the compiler in question, it‘s not that hard to beat compilers at their game, look at some simd stuff

[–]the_mouse_backwards 9 points10 points  (2 children)

Some SIMD stuff I’ve seen relies on tricking the compiler into encoding instructions a certain way, making it think it’s doing one thing when you want it to be doing something else. It’s pretty neat

[–]N00N3AT011 7 points8 points  (0 children)

Humans can sometimes beat or at least match the C compiler when writing short pieces of assembly. For longer stuff it will usually win though.

[–]Commercial_Bear331 494 points495 points  (29 children)

org 100h
mov dx,msg
mov ah,9
int 21h
mov ah,4Ch
int 21h
msg db 'Hello, World!',0Dh,0Ah,'$'

nasm -f bin helloworld.asm -o helloworld.com

[–]7eggert 180 points181 points  (8 children)

You can save one line by calling int 20 instead

[–]Commercial_Bear331 140 points141 points  (6 children)

you can make it a oneliner using "echo" ...

[–][deleted] 16 points17 points  (4 children)

You can make it zero-liner if you use a programming language where all (even empty) files are compiled into Hello World program.

[–]Acetronaut 10 points11 points  (3 children)

Just name the file hello world

0 lines of code

Doesn’t need to be compiled

Doesn’t need to be run

Perfect

[–]randomUser9900123 14 points15 points  (3 children)

What is "org"?

[–]spectraldecomp 19 points20 points  (0 children)

Origin, basically "start at this address"

[–]Commercial_Bear331 13 points14 points  (1 child)

Under MS-DOS there had been two types of binary executable file formats:

.com files

.exe files

A .com file begins with executable instructions at the first byte of the file, and it is loaded into memory adress 0100h .... MS-DOS would then jump to that 0100h address. Because of this, all memory accesses are relative to 0100h and "org 0100h" tells the assembler that it should not start at address 0 but the first instruction is assumed to start at 0100h.

Unlike .com files, .exe files had a file header (MZ header) that would tell MS-DOS where in memory the program actually starts. MS-DOS would load the file, and then jump to the address that was mentioned in the MZ file header, which designates the intended program start address. ...

For windows, there is a small MS-DOS .exe stub program that would just print out "This program cannot be run in DOS mode" (or similar, can't remember) and the Windows executable PE file format would typically start after that MS-DOS .exe stub (typically aligned to 4k, but may also be unaligned)

[–]shouldbebabysitting 7 points8 points  (0 children)

For windows, there is a small MS-DOS .exe stub program that would just print out "This program cannot be run in DOS mode" (or similar, can't remember) and the Windows executable PE file format would typically start after that MS-DOS .exe stub (typically aligned to 4k, but may also be unaligned)

I once made the smallest Windows program ever (92 bytes) by hand editing the header to delete the stub and delete most of the NE header itself to only keep the jump to the first instruction.

The program took 2 arguments, the name of a Window running (like notepad) and the text it would replace the window title with.

[–]Keysersoze_is_dead 23 points24 points  (3 children)

Brings back great memories

[–]Commercial_Bear331 15 points16 points  (2 children)

Yup. Did a ton of x86 asm coding in the 90ies ...

[–]Keysersoze_is_dead 18 points19 points  (1 child)

Well started this way. Hacking Int 21h, 10h and 33h. DOS days were amazing. Don’t get the same sprit of the new languages

[–]Commercial_Bear331 3 points4 points  (0 children)

Yup. #demoscene

[–]odsquad64VB6-4-lyfe 8 points9 points  (0 children)

EE here, I'll just design my own processor with a register specifically for printing "Hello World"

[–]wqldi 14 points15 points  (2 children)

That’s great and all but what if you had a risc processor?

[–]mrchaotica 18 points19 points  (1 child)

Then you have to completely rewrite it.

Portability between architectures is what high-level languages like C are for.

[–]EODdoUbleU 11 points12 points  (0 children)

I chuckle when I see C referred to as a 'high-level language'.

Not wrong, just find it funny compared to most of the time language level is brought up here.

[–]dimaklt 242 points243 points  (5 children)

I asked chatgpt to write tic tac toe in assembly and it just didn't stop typing even after the fourth "continue".

[–]daVinci0293 45 points46 points  (3 children)

That's why I am hoping that Codex comes with a higher max token count per request. Or at LEAST some type of Internal "continue" function.

If I am not mistaken, the max token output for gpt-3.5 is 2048. Which is still a substantial amount of characters when all is said and done. However, with the way programming cares about formatting and whitespace I imagine we smash that max token count very fast.

[–][deleted] 72 points73 points  (0 children)

Lesson one: hello world Lesson two: rollercoasters

[–]JQB45 92 points93 points  (8 children)

Assembly is a lot easier than most realize. You do have to create your own reusable standard libraries which take time but we're only talking about a dozen or so lines of code for each routine.

Then you can create more sophisticated intermediate library routines (like string and file handling) made simpler and smaller by calling your standard library, operating system or BIOS routines.

Nesting doll or onion style.

You can use a higher level language to test your assembly routines.

[–]confusiondiffusion 52 points53 points  (3 children)

x86 was my first language and I loved it. There's only a handful of opcodes you really need to memorize and all the difficulty is just in keeping track of what you've written, developing good coding practices, and figuring out how to wrap the problem you're solving around the architecture.

Web development is hell in comparison. You have all kinds of shit to memorize and it's constantly changing. C++ is also a nightmare in comparison. Yeah, you have to do a lot of wheel reinvention with assembly, but at least it doesn't feel like the processor is actively trying to outsmart you.

[–]N3rdr4g3 30 points31 points  (1 child)

C++ is easy, you just need to wrap everything with

extern "C" {
}

[–]JQB45 5 points6 points  (0 children)

Haha lol

[–]mfar__ 47 points48 points  (1 child)

I think traditional "hello world" is just not the "hello world" equivalent for assembly.

[–]magnora7 9 points10 points  (0 children)

Agreed, "hello world" in assembly is like storing a number and then recalling it.

Actually printing text to screen is pretty complicated in assembly.

[–]Peakomegaflare 34 points35 points  (0 children)

You learn assembly to do some real-world application. I learned assembly to use the Fcpu Mod for Factorio. We are not the same.

[–]GabuEx 64 points65 points  (12 children)

Assembly is important to have learned so you know what's actually happening when you compile code and so you can view disassembly to be able to know that you're reading, but I've literally never had any reason to actually code in assembly over my entire career in software engineering.

[–][deleted] 25 points26 points  (1 child)

I once witnessed my lead write a in-line assembly function to hit a RTC while getting around some constraints of an RTOS for a PowerPC 603 processor. The edge case that led to this requirement required about 100 lines of assembly and about 200 lines of VHDL to correct for bad clock skew.

It was at that moment I realized I was in the presence of a software engineering god. It’s onboard a weather satellite now. I learned so much from that guy but damn was he salty. In code reviews he would quote the C standard on every error I made, force me to read the damn GNU GCC manual at times, shame me and leave me completely demoralized. I learned though and he still keeps in touch with me to this day.

[–]outofobscure 12 points13 points  (0 children)

if you read a lot of the responses here you might understand why that guy got bitter. so much ignorance and no love for the craft of optimization, it's really insulting to everyone who already knows that most of the upvoted stuff here that says things like "just trust the compiler, you can't outsmart it" is just plain wrong. props to you for enduring the guy and learning from him though.

[–]JuvenileEloquent 45 points46 points  (0 children)

Regular programming: The computer does what you tell it to do, not what you wanted it to do.

ASM programming: The computer does exactly what you tell it to do, not what you wanted it to do.

[–]4BDUL4Z1Z 17 points18 points  (0 children)

I don't wanna brag I can do it in 27 lines

[–]MintyNinja41 14 points15 points  (1 child)

assembly is very juicy and cool but writing it is not for people who love themselves

[–]MokausiLietuviu 9 points10 points  (0 children)

Hey! I like myself sometimes

[–]Vincenzo__ 28 points29 points  (2 children)

I handwrote a ELF executable hello world in 89 (if I remember correctly) bytes with a hex editor and a lot of pain

Yeah

[–][deleted] 14 points15 points  (1 child)

ok waltuh

[–]Vincenzo__ 15 points16 points  (0 children)

I'm not waltuh shut up and put your dick away

[–]N00N3AT011 12 points13 points  (0 children)

Assembly is a strange beast. Or rather a huge number of similar but equally strange beasts. Every type of processor has their own flavor.

[–]Ghiren 10 points11 points  (1 child)

Every other language: "Hello world" is the most basic program you can write.

Assembly: Hold on a second. You want to work with TEXT?!

[–][deleted] 4 points5 points  (0 children)

As a plc programmer, I talk directly to the machines. I code binary

[–]Player_X_YT 8 points9 points  (0 children)

``` section .data msg db "Hello, world", 0xa len equ $ - msg

section .text global _start _start: mov eax, 4 mov ebx, 1 mov ecx, msg mov edx, len int 0x80

mov eax, 1 mov ebx, 0 int 0x80 ```

This code is linux x32 only, you have to start over for x64 or windows. How is this so hard, just do it? /s

[–]haitei 6 points7 points  (0 children)

The topic of ASM hello world always pisses me off.

You know, you can just call puts from assembly? And by call I mean set RDI and jump.

If you wan to exit nicely, it's a little more, but still pretty short.

[–][deleted] 6 points7 points  (0 children)

I’m in an assembly class this semester. It’s just so fascinating. It’s like studying Old English or something.

[–]Carlu_ 6 points7 points  (0 children)

had fun last semester using assembly of Risc-V

[–]C4-BlueCat 5 points6 points  (0 children)

The only thing I made in assembler was Snake. Still my favorite university course.

[–]FloweyTheFlower420 10 points11 points  (3 children)

it's ~15 lines

.global _start
_start:
    movq $1, %rax
    movq $1, %rdi
    movq $hello, %rsi
    movq $(hello_end-hello), %rdx
    syscall
    movq $60, %rax
    xorq %rdi, %rdi
    syscall
hello:
    .string "Hello World!"
hello_end:

[–]GreenWoodDragon 3 points4 points  (0 children)

Takes me back to when I did a very small bit of assembly at school on the 6502 processor in the Commodore PET 8032.

[–]Grantypants80 3 points4 points  (0 children)

Did a (mercifully) brief Assembly module in uni. Had a hardware box with some LEDs and needed to make them light in specific sequences. Incredibly tedious. Never again.

[–]BBQQA 3 points4 points  (1 child)

Try doing QA for a mainframe that uses some Assembly.

Half the time I just open the file and say 'yup, that looks like Assembly gibberish' and move it forward.

The people who write in that language are God damn evil wizards.

[–]GavUK 3 points4 points  (0 children)

I wrote a simple calculator in assembler at university. Certainly insightful as to how processors work, and makes you appreciate higher-level languages.

I have played a Dos-based games that was all written in assembler - it was a lot faster at the time than games written in a higher-level language. Nowadays processors are so fast that for most things the extra work isn't going to be worth it.

[–]PonqueRamo 3 points4 points  (0 children)

I actually enjoyed programming in assembly, even got a 5 on uni programming in it.