Basic Concept and Syntax

From the previous post, we know that Assembly language relies on two basic concepts
  • Mnemonic Opcode - a set of instructions that comes in a short, easy-to-remember form.
  • Symbolic Addressing - Normally, we refer to a memory address by numbers. This concept allows us to give a meaningful name to a memory address.

There are two types of syntax in Assembly language. One is "AT&T Syntax" and the other is "Intel Syntax". In this fun lesson we're going to use AT&T syntax. Why? AT&T Syntax has been used in UNIX and Linux world for long time, even though Microsoft Windows and other OSes are using Intel Syntax. AT&T Syntax is more straightforward and easier to understand, which is why we choose AT&T Syntax.

To code an Assembly language program, we have a tradition that the programmer has to follow. The following table will show you 4 different fields that we use in Assembly language (from now on, I'll use assembly instead of Assembly language). Each field are separated by a TAB.

Picture 2

  • Label Field ⁃ This field is where we give a name to a memory address, it can be used on create a function (subroutine), or create a pseudo-variable.
  • Opcode Field ⁃ This field is where we put the instruction that the CPU will execute
  • Operand Field ⁃ The instruction in the opcode field will require 0 to 3 operands. These operands are written in this field
  • Comment Field ⁃ This field consists of comment of that instruction. In assembly program, comment is very important. You can forget what the program does very quickly if you don't put the comment in.
|

Why learning Assembly Language?

People may ask why do we need to learn Assembly language while we have many powerful high-level languages like C++, Java, or Python. One answer is that Assembly language allows you to control the CPU and hardware directly like no other high-level programming languages. It also allows you to create the most efficient program. However, Assembly language is hard to learn because it lies on two basic concepts, Mnemonic Opcode and Symbolic Addressing. I'll talk about those two concepts in later posts.

Assembly Language is CPU and operating system dependent. One "cannot" port one Assembly program to another platform easily, but the concept is the same in all different kinds of Assembly Language.
|