Guide to Programming Series: Week 2
Because thinking in machine language is simply too complex, people developed a simpler programming algotrithm called assembly language.
Thinking like a Processor
Instead of forcing programmers to think in binary, Assembly Language uses short, easy-to-remember commands such as JMP, MOV, and ADD, which represent specific machine-language instructions. With it, assembly language source code shorter and easier to write, but it also makes the code easier to read and modify later.
This is a basic example of an assembly language program:
SEGMT SEGMENT ASSUME CS:SEGMT, DS:SEGMT ORG 100h
Main: MOV AH,09h MOV DX,OFFSET Text INT 21h MOV AX,4C00h INT 21h
Text: DB "Hello, sylv3rblade$"
SEGMT ENDS END Main
Being able to making your code easy to read and edit is quite essential if you’re writing tons of code because debugging (basically errors) can be qutie taxing. Also, it’s probably best to set yourself on a mindset that most programs never work right the first time you use them. Better safe than end up with a headache.
Does the computer understand assembly? Sadly no. Programmers instead, created specific programs that translate assembly language into machine language. These are known as assemblers. The basic flow of a program in assembly is:
Code > Assemble > Run
To sum up, assembly language offers two advantages:
- Programs are easier to read.
- Programs are easier to develop.
Assembly is not perfect language, however. Here are the disadvantages:
- Assembly programs are slower and use more resources.
- Programs are processor specific. Because not all processors lines contain the same set of instructions, it’s hard to port the program to another machine.
- Assembly language is extremely tedious, time-consuming, and complicated.