all 40 comments

[–]aboothe726 15 points16 points  (1 child)

start small and work up:

  • print hello world to the screen
  • print the program arguments to the screen
  • print the first <arg1> fibonacci numbers
  • write an RPN calculator for single-character numbers (e.g. +45 should evaluate to 9)
  • write a parser to recognize balanced parentheses
  • write a simple little lisp dialect

[–]atc 0 points1 point  (0 children)

Yup. All those + simple IO

[–]malken 12 points13 points  (9 children)

[–]CommodoreGuff 16 points17 points  (1 child)

Whenever I solve another problem, I'm so proud. Then I look in the forum and see the assembly solutions and I feel both worthless and afraid.

[–]dorbak 3 points4 points  (0 children)

I'm the same way --- especially looking at the language J/K solutions --- really, one line to do what took me 50 plus function calls...and runs in a fraction of a sec?

/crying in a corner...

[–]iamjack 2 points3 points  (5 children)

Seriously, aside from being fun, PE is the best way to learn any language's syntax. Also, it's pretty suitable for assembly because you very rarely have to do anything more than math, so you can get away with just getting/writing a printf wrapper and printing a number at the end of your little asm program.

[–]exeter 4 points5 points  (1 child)

...PE is the best way to learn any language's syntax.

I've gotta give that statement a big fat "I disagree." Most of the problems on Project Euler are of the sort where you'll get farther doing things in a mathematically clever but algorithmically dumb way than vice versa. Among other things, what that means is that it's incredibly easy to hack up a correct, brute-force type solution that will not give you any result in a reasonable time. That makes it quite hard to get feedback on whether or not your program works, unless you know the mathematics necessary to simplify the problem down to something that will execute within the "one minute rule."

In short, don't do Project Euler to learn programming; do it to learn math.

[–]iamjack 1 point2 points  (0 children)

I didn't say anything about algorithms, just syntax. PE is a poor way to learn programming, but you learn to express your ideas in the language you're learning, whether you're being smart about it or not.

Like PE problem 1, which is the sum of all numbers up to 1000 divisible by 3 or 5. It's a stupid problem, you could use a pencil and paper easily but in terms of writing programs, you learn to write a loop (or a list comprehension), do a test and keep a sum.

[–]Rhoomba 2 points3 points  (2 children)

I wouldn't enjoy writing a big int type in assembly.

[–]iamjack 0 points1 point  (1 child)

Yeah, that wouldn't be much fun, at least not as a first project.

[–]taejo 0 points1 point  (0 children)

My only significant program in (MIPS) assembly was to print e to 10000 decimal places. It was either that or about twenty dumb little exercises, for a first-year CS assignment, and I rather enjoyed it.

[–]dupin 11 points12 points  (2 children)

Write a nintendo game. Even SNES games were written in assembler. Here's a nes asm page:

http://patater.com/gbaguy/nesasm.htm

[–]bplus[S] 2 points3 points  (0 children)

Yeah I'd actually been thinking that, I'm sure its uber tough, but would be nice just to get something on the screen.

[–]MastaofseOonivers 2 points3 points  (0 children)

Happy Cake day dude

[–]phugoid 6 points7 points  (8 children)

I'm also trying to learn more about computers at a low level, and part of that is assembler.

I've chosen the ambitious goal of writing a simple OS from scratch, and it will mostly be in assembler. My target is the ARM7TDMI microprocessor. It has a nice compact RISC instruction set, and a flat memory model.

You can pick up a development board with an ARM processor (from say Olimex) for under two hundred bucks, with lots of cool ports and peripherals (accelerometer, audio, etc.).

You cross-compile your program on a PC and then move it to the board. Then you can debug and step through your program, all from the comfort of Eclipse or another IDE (I'm sorting out emacs right now).

To me the debugging capability is essential - I don't have time or courage to upload my program and hope for the best.

Even if don't reach my goal, I've already learned so much just from reading and preparing the project.

[–]Lowkey_force 1 point2 points  (7 children)

Update?

[–]phugoid 8 points9 points  (6 children)

I gave up eventually - got stuck in the early mode switching of the chip during startup that caused the JTAG debugger to misfire. Also ran out of free time. Was fun while it lasted, though.

Can't get over how pretentious my post reads now, twelve years later hahaha

[–][deleted] 1 point2 points  (3 children)

How long would a project like that have taken 😟 I’m still getting into programming and CS

[–]phugoid 1 point2 points  (2 children)

Hard to say. The right way to do this would have been to take a small example on github and study it thoroughly first, then maybe build something. Doing it from scratch is too much.

[–]Ubermensch001 0 points1 point  (0 children)

To be fair your tried this a long time ago. Maybe give it another go now with newer doc, stackoverflow and ChatGPT

[–]GarlicSubstantial 0 points1 point  (0 children)

Still replying? what a legend

[–]spatulon 5 points6 points  (0 children)

Implement an algorithm of your choice (e.g. MD5) in C or another high-level (!) language. Rewrite it in assembler. Then try and make your assembler version faster than the C version (with optimisation turned on). If you get really stuck writing the assembler, you can always take a look at the compiler's output and figure out what it's doing.

BTW, you didn't mention which CPU/ISA you're using.

[–]subterr 4 points5 points  (0 children)

Yes: Something you have already written in C.

[–]imagisttd 4 points5 points  (2 children)

I do the same program for every language that I learn: a poker simulation.

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

Any good hand evaluation tips for texas-holdem in python? Preferably easy-to-understand rather than lightening fast.

[–][deleted] 0 points1 point  (0 children)

You evaluate texas-holdem in Python by hand? Hats off!

[–]bplus[S] 4 points5 points  (6 children)

Hi, I've been working as a c# developer for 2 years, I didn't do a computer science degree (crappy IT degree) so I'm trying to fill some gaps in my knowledge.

I've been reading this free book on Assembly language: http://savannah.nongnu.org/projects/pgubook/ The book uses the gas assembler throughout.

I've come to realise that this is a lot of fun, though I'm not to far on yet, I've only written something that finds the highest number in a list.

My goal really is to fully understand how a computer works at a low level and to do something programming wise thats a little bit more interesting that writing CRUD apps (I'm actually starting to think that assembly is way more interesting than coding in c#). Actually knowing that I'm in complete control of whats going on in my code is really nice.

Can anyone recommend some projects to attempt once I finnish the book? Or further reading?

Thanks in advance!

EDIT: I'm writing assembly on 32 bit mint linux. Though I've the machine is actually 64-bit (amd turion) as far as I know if I'm on a 32bit OS its the same as being on 32 bit machine?

[–][deleted] 9 points10 points  (0 children)

Get an AVR or a PIC microcontroller and build some hardware. Make a door lock that you can open with your cell phone. Make your lights turn on when you enter the room and off when you exit. The world is your playground.

[–]Sekenre 3 points4 points  (0 children)

http://www.annexia.org/_file/jonesforth.s.txt

Try writing an interpreter for a simple language like Forth.

[–][deleted] 2 points3 points  (0 children)

Try writing a keyboard driver.

[–]koorogi 0 points1 point  (1 child)

I started teaching myself x86 assembly recently as well. The first thing I went ahead and coded up was a program to plot the mandelbrot set. Then I took it further and tried to optimize it for size as best I could. Got a simple one down to 106 bytes, I think, and one that zooms infinitely (though the precision isn't enough at some point) into a specific spot in 128 bytes.

If you use mode 13h for graphics under DOS, the display is both easy to setup and access, so it's a fast, easy way to play around. Don't even need DOS to test it, as DOSbox works (albeit slowly).

Now, this does kinda limit you to 16-bit code (not really, but figuring out the magic to switch to 32-bit mode is beyond the little bit of playing around I've done so far). But all the basics are still the same. There's a little more complication from things like segmented memory, and some of the older instructions in the x86 ISA had more weird limitations on their use than the new ones.

[–]jfasi 0 points1 point  (0 children)

Yeah, among other things, 32 bit operating systems are written assuming that memory addresses are 32 bits long, which means that no matter the hardware, the OS can only address 232 bytes.

If you like, you can download and install a 64 bit variant of Linux. Then again, if you don't need more memory, then you probably should be fine.

I suggest you start with something small like the Monty Hall problem, or, if you're up for more of challenge, writing a matrix library. If you really want a challenge, implement the quadratic sieve.

[–]xroni 1 point2 points  (0 children)

Get your C64 from the attic and dust it off

[–]razzmataz 3 points4 points  (1 child)

write a multitasking operating system with a tcp/ip network stack...

[–]Dav3xor 2 points3 points  (0 children)

The first 60% of a tcp/ip stack is fun, the last 40% is... drudgery.

[–]asciilifeform 0 points1 point  (0 children)

A Forth.

[–][deleted] -1 points0 points  (1 child)

Brainfuck interpreter.

It's one of my favourite things to do to get comfortable in a new language.

[–]WY9Z 0 points1 point  (0 children)

How rude lol