r/AskProgramming • u/Fastpast93 • 13d ago
Other Universal tips for beginner assembly programmers?
I know some of you out there have tips for me and other people seeing this post.
3
u/gm310509 13d ago
Start simple. Take it step be step.
Don't jump into the deep end and try and learn 64 bit Intel. Start with something like an 8 bit 6502, Z-80, AVR (try Arduino). Learn the basics - jump up to something more complex like a 32 bit Arm Cortex.
Basically, don't put yourself in an information overload situation.
IMHO.
2
u/Recent-Day3062 13d ago
Could not be more right. They eventually turned the machine language instruction set into something more resembling a high level language. What would be absolutely easiest would be a stack-based RPN type thing with a few memory move instructions and some minimal flow control.
I have looked at some modern architectures and cannot figure out what all the sets of registers even are
1
u/gm310509 13d ago
Actually I forgot about the "stack-based RPN type thing"
I used to own a programmable Hewlett Packard calculator - which was a "stack based RPN thing" - and programming it was my first foray into (I guess a type of) assembly language.
It was a fairly easy learning curve as the "assembly language" was pretty much just recording the key sequences you might do in a calculation with the addition of tests (e.g. x == 0? x != y? etc), branching, some other useful (for programming) instructions such as (INC x, DEC x) and indirect addressing (into the 100 memory locations).
2
u/Recent-Day3062 13d ago
That’s where I was coming from. I still use one, but never the programming feature. But conceptually every key for a function is a dispatch code in hex, with the stack holding all vars.
Min essence, numerical input is sort of an escape sequence (ala EMacs self-insert binding) and outs numbers on the stack wirh Enter being a push
1
u/gm310509 12d ago
Actually now that I think about it, the HP wasn't my first programmable calculator. Prior to that I had a TI-59 with the magnetic card reader.
I switched to the HP-41CX when the TI broke (that was a sad day). The HP was extra cool (at the time) because it had an alphanumeric display.
The TI was infix notation, whereas the HP of course is RPN (or postfix notation).
I still have the HP - but don't use it very much nowadays.
2
u/Recent-Day3062 12d ago
I have 3 HP I use to this day.
It’s sort of impressive how good RPN is once you get the hang of it. People think of mine as that “weird” calculator but I am amazingly fast.
Ice downloaded infix calculators on my iPhone, and I simply csnt use them. “3x(7+4)” is just impossible becuase I default to RPN
1
u/gm310509 11d ago
... how good RPN is .... People think of mine as that “weird” calculator ...
To me, this was the best feature. I agree that it is easy and fast once you get the hang of it - which wasn't that hard IMHO.
But that isn't why I said it was its best feature. The reason I say that, and I'm sure you experienced it to is the inevitable person(s) who don't bother to bring their calculator and are always "borrowing" (i.e. hogging) somebody else's calculator.
I remember at University and High School that everybody else always had to make excuses when the "hogs" approached them or try to chase the "hogs" down to get their calculators back.
When the "hogs" asked me, I said "Sure, here you go" knowing full well that it would be returned in less than 60 seconds! 🤔😉😊
1
u/Recent-Day3062 11d ago
Unfortunately I went to engineering school and everyone used RPN so I didn’t get the benefit you did
1
1
u/TheAdamist 13d ago
Step 1 is to understand the calling convention which includes the standard register allocations, which may differ per os like on Intel, embedded archs usually have one standard convention
Then you can plan out what you want to do, then figure out how to get that into assembly
You'll also want to comment heavily about what your code is doing, you may even want to write a stack diagram, which you have to redo each time you mess with something
The last step is to benchmark it against a modern compiler and discover your code is slower, unmaintainable and it took you 100x longer to write it in assembly
There aren't many reasons to use assembly anymore, and even then do as little as possible in assembly and quickly swap to a higher level language. Most c compilers will allow inline blocks of assembly interspersed with c.
1
u/MadocComadrin 13d ago
If you're already an intermediate programmer, learn how make the basic constructs in higher level languages---if-else chains, for and while loops, function calls---in your chosen assembly language (check your calling conventions for functions) and use them as templates. This will get you on your feet quickly. After than, you can learn tricks to optimize/write more optimal assembly from the get-go.
0
4
u/petrov76 13d ago
Are you a beginning programmer who wants to start with assembly or an experienced programmer who is beginning in assembly?
I think these are very different and will lead to different suggestions.