Sign in to follow this  
piper123

Unity What's the best system on which to learn ASM?

Recommended Posts

piper123    108

Hey guys,

 

I'm looking at getting into retro game dev. I've been a game developer for the last five years and am fairly proficient in C/C++ (although I've used Unity and JS/C# for all of my game projects) but assembly is completely new to me.

 

I understand you need to really get to know the hardware (something Unity doesn't require - lol) and my school of thought was that a simpler machine would be simpler to learn... or is there more to it than that?

 

I was thinking of starting on the C64 and working my way up to 68k asm so I can make stuff for the Mega Drive, but where would you guys suggest starting?

 

Regards!

Edited by piper123

Share this post


Link to post
Share on other sites
Erik Rufelt    5901

If the goal is just to use ASM then I think straight x86 is the easiest.. has a lot of tools and you can easily use it on your desktop.

 

I'm sure it's a lot of fun to learn on an older machine, but it will be more difficult.

Edited by Erik Rufelt

Share this post


Link to post
Share on other sites
WozNZ    2010

I much preferred the 68k style of assembly over x86 just feels cleaner and nicer to work with but as Eric said, you have an x86/x64 machine so easier to play with.

 

That said in the modern world it is far harder to get to the metal than it was when I played with assembly so getting an old machine emulator and using that would be a good in.

 

For a gentile introduction in playing at a low level you could explore the old nerd classic that is http://www.corewars.org/ is is a pseudo assembly language where two programs get loaded into an "address space" and have to locate and destroy the other before they get killed :)

Share this post


Link to post
Share on other sites
alh420    5995

I'll put in a vote for 68k.  

z80 is also a nice processor.

 

One of them is probably already in a calculator near you, ready to be developed for smile.png

 

A good thing with these simpler CPUs is that their instruction set is way more limited then x86.

x86 is a big pile of layer of layer of decades of development... not really beginner friendly.

An 8 bit z80 is beautifully clean in comparison, which makes the basics so much clearer.

But the limitations of an 8 bit environment is not for everyone... With a 68k you have a lot more freedom, without the instruction set getting hugely complex.

 

I might be biased because those two cpus where the ones I started out with so long ago smile.png

 

C64 hardware is like a school book of basic computer architecture, so not a bad choice either IMO

Edited by Olof Hedman

Share this post


Link to post
Share on other sites
Erik Rufelt    5901

I'm not sure what the goal is, but if it's learning ASM then both unrestricted hardware access as well as instruction set complexity are irrelevant. Easiest way to start learning x86 ASM is inline ASM in Visual Studio, then concepts can be added one at a time.

 

Unless you actually want to get to know a hardware well, which can be great in itself, but quite a small subset of it is required to learn ASM.

Share this post


Link to post
Share on other sites
NightCreature83    5006

I much preferred the 68k style of assembly over x86 just feels cleaner and nicer to work with but as Eric said, you have an x86/x64 machine so easier to play with.

 

That said in the modern world it is far harder to get to the metal than it was when I played with assembly so getting an old machine emulator and using that would be a good in.

 

For a gentile introduction in playing at a low level you could explore the old nerd classic that is http://www.corewars.org/ is is a pseudo assembly language where two programs get loaded into an "address space" and have to locate and destroy the other before they get killed smile.png

 

Its not that hard to kick an asm function even from x64 code, the only thing that has gotten hard is that the C++ compiler no longer allows for inline ASM. https://www.youtube.com/watch?v=fHE0txCjGgI

Is a good series on getting started with x64 asm in VS2010, he shows you how to call an asm function and then moves on to explaining what all the instructions do.

 

I learned ASM on a 8088 like board with MASM as the compiler this looked so much like x86 asm that moving to PC was only getting used to the new register names like EAX and stuff.
 

The other thing you can do is write a simple function in C/C++ and see what the compiler transforms that into on PC in a debug build. You will want to do this in a debug build because in that case the compiler will actual transform all of your code in to ASM.

Edited by NightCreature83

Share this post


Link to post
Share on other sites
Brain    18906

If you're going retro I vote for the 6502.

 

It's a very simple instruction set, with only three registers plus stack pointer and flags.

 

You could probably learn it in a week if you're already programming in C or similar, and it serves as a great starting off point for x86 (which IMHO is a horrid bloated instruction set designed these days for compilers not humans and assemblers).

 

I cut my teeth on the BBC micro which is an 8 bit machine cheaply available in the UK. It's also the same hardware as the NES (famicom) so it has lots of retro uses.

 

Have fun! :)

Share this post


Link to post
Share on other sites
Infinisearch    2967

I vote 68000 but I vote for Commodore Amiga not Megadrive.  C64 with 6502 isn't a bad choice either.  The reason for computer instead of videogame system is that you'll most likely find more resources on the web for programming them and they both had demo scenes IIRC.

Share this post


Link to post
Share on other sites
Endurion    5411

I'd target the machine you actually want to target :)

 

Obviously I'm biased for the C64, there's documentation abundant and there's no problem getting decent cross compilation tools.

 

<SelfAd>I recommend C64-Studio, my Visual Studio like IDE, which uses (Win)VICE for a neat debugging experience.</SelfAd>

Share this post


Link to post
Share on other sites
Ravyne    14300

It really depends on what you value.

 

For accessibility, x86/x64 is simple because you can do it right on your PC. This means fewer headaches -- debugging your assembly code is a lot easier when its running on your host, and its also easier to write the high-level parts of your program in, say, C or C++, without the slight pain of dealing with cross-compilers, deployment to a device, etc. ARM, in the form of a raspberry Pi is also a good choice for the same reasons (With the Pi being a complete, if modest, linux-based PC).

 

What you don't on either of those platforms is unfettered access to the machine. If you're interested in that, you probably want something like an arduino or another microcontroller kit -- something where you can run bare-metal without an OS. Depending on your platform, this experience may or may not be super-transferable to larger devices if that's a goal; for example, many small microcontrollers have no caches (or very simple caches), and CPU clock-speeds low enough that RAM access is essentially single-cycle -- which is not at all true of PCs or even many higher-end microcontrollers. The Pi makes another showing here -- Its reasonably documented now, and I've seen material on programming it bare-metal-style; the only downside is that its a lot to try to understand and in many ways its more accurate to say that the Pi's SOC is a GPU that happens to have a CPU, rather than the other way around. For my money, the Gameboy Advance is a good platform in this space -- Its very well-documented by the homebrew community, tools are readily available (emulators are a great resource), the hardware capabilities are interesting but not overwhelming in complexity or number. Bonus: you can distribute what you create as a ROM if you're interested in creating complete games, or even play on a real GBA.

 

Going full-retro, its hard to recommend against the C64 (6502) or Amiga (if you want to go 68k) -- either are very interesting, very capable, and very well-documented machines with communities that are still going strong. For their times, either one can be said to be a paragon of hardware design not just for how much they were capable of, but for how elegantly they achieved it.

Share this post


Link to post
Share on other sites
MarkS    3502

I vote 68000. I learned to program on a Mac 512KE and the only processor I've actually learned assembly for was the 68000. It has a remarkably easy and rather nice instruction set.

Share this post


Link to post
Share on other sites
Khatharr    8812

I'll throw in a vote for x86 through VS. In addition to what's been said, it gives you the opportunity to fiddle with C/C++ and see how the stack and function calls work. Also, I think that if you just pick something accessible and jump right in then you'll get the basics down and you can expand from there in whatever direction you please.

Share this post


Link to post
Share on other sites
Infinisearch    2967


I'll throw in a vote for x86 through VS. In addition to what's been said, it gives you the opportunity to fiddle with C/C++ and see how the stack and function calls work.

This is quite true, and I guess you could target DOSbox if worst came to worst.

Share this post


Link to post
Share on other sites
Khatharr    8812

 


I'll throw in a vote for x86 through VS. In addition to what's been said, it gives you the opportunity to fiddle with C/C++ and see how the stack and function calls work.

This is quite true, and I guess you could target DOSbox if worst came to worst.

 

 

?

 

Desktop PCs run x86 natively.

Share this post


Link to post
Share on other sites
Promit    13246

Get yourself a Raspberry Pi2B or a BeagleBone Black.  These are ARM boards -- the ARM processor is way simpler than the x86 even though they're of the same relative vintage (ARM is RISC, x86 is Swiss Army knife).  In addition to learning ASM, you can futz with blinkenlights so you can really feel close to the metal.  Learn to love the smell of rosin-core solder, it's the smell of victory.

This is the way to go. Most of the other suggestions are useless - while Z80s, 6502s, 68ks are kinda cute to play with, they have no relevance to modern development or modern processor design. x86 is extremely useful and relevant but also complicated and psychotic. MIPS was relevant once and continues to be a popular university choice, and resources are readily available. The trouble is just that very few MIPS chips are out there and what is generally lives in highly constrained embedded systems so it's just not a very real-world skill.

 

ARM strikes a great balance of being a nice, modern design that is highly relevant to work today, but still fairly straightforward to learn.

Share this post


Link to post
Share on other sites
alh420    5995

This is the way to go. Most of the other suggestions are useless

 

Guess it depends what your goal is.

Since the OP said he was interested in retro dev, of course retro systems is what you suggest.

 

But, if the goal is to learn asm in general, then sure, ARM is a great place to start. Don't need to get a raspberry though, you probably have one in your phone already.

And if you want to get really close to metal, then you could get a Teensy (cheap arduino-compatible with ARM)

Though I guess you have more hardware to play with in the Pi :)

Edited by Olof Hedman

Share this post


Link to post
Share on other sites
AgentC    2352

The 68k is a very clean instruction set; you have a number of data registers, which all work the same, and address registers. There are nice instructions for math, including integer division / multiplication.

 

If your eventual goal is Megadrive and as you have previous C/C++ experience it doesn't seem like a stretch to go directly for the 68k.

 

However, there may be some difficulty in setting up a development toolchain so you can compile and run Megadrive programs, and also you would be learning the hardware features at the same time (to e.g. learn what addresses you need to poke to get something to show up on the screen). There are reverse-engineered / leaked resources for this, but not as abundant as for retro computers. When an 8/16bit console boots up and starts executing your program, it typically starts from almost nothing, on the other hand a computer typically has the screen already displaying some sensible data (like text), and has ROM operating system routines to help you.

 

Therefore, for the quickest, hassle-free introduction into the retro/asm programming mindset with minimal setup and immediately visible effects I'd recommend the C64 as well. For example with the VICE emulator, you can break into the built-in debugger/monitor and write & run simple asm programs directly; no toolchain setup needed. The C64 CPU instruction set is extremely limited though, you have three primary registers (A,X,Y) which all are used differently and you can forget about more complex functions like multiplication - they don't exist and must be written manually using bit-shifting arithmetic.

 

If you don't feel overwhelmed by the prospect of learning the hardware and having to set its state up from scratch, you'll waste less time going directly for your target platform though.

Edited by AgentC

Share this post


Link to post
Share on other sites
Bregma    9214

Oh, and one more thing:  I first learned all about computers using assembly language for the CARDIAC computer -- it was the early 1970s, there were no PCs.  Seriously, you could do worse.  It was easy enough for a 10-year-old to understand and serious enough to propel him on a successful career in the industry when the industry didn't yet exist.

Share this post


Link to post
Share on other sites
Infinisearch    2967

 

 


I'll throw in a vote for x86 through VS. In addition to what's been said, it gives you the opportunity to fiddle with C/C++ and see how the stack and function calls work.

This is quite true, and I guess you could target DOSbox if worst came to worst.

 

 

?

 

Desktop PCs run x86 natively.

 

Yeah but he want to get into old school game programming which is basically impossible on a modern OS.  If you want to access the VGA and soundblaster hardware directly you'll have to use dosbox.

Share this post


Link to post
Share on other sites
PurpleAmethyst    335

8 bit wise I'd go for 6502, because it is so simple. There's also modern versions like W65C816S. For more modern go for ARM, and Raspi is a really convenient way to get that. The original ARM designs were inspired by the simplicity of the 6502.

Some Z-80 might be a good place to start if your final intention is to learn x86 as they are somewhat historically related architectures. No harm in learning some X86 either. 

Share this post


Link to post
Share on other sites
CalvinCoder    139

If you absolutely want to learn assembler, as a former demo coder I second learning some 68k asm on Amiga, and maybe also some 8 bit 6502 on C64. Loads of tutorial out there and not to complex to understand... x86 is great too, but I personally think x86 has a little bit steeper learning curve.....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this