Page 219 - DCAP104_EXPOSURE_TO_COMPUTER_DISCPLINES
P. 219
Exposure to Computer Disciplines
Notes 11.2.3 Assembly Language
An assembly language is a low-level programming language for computers, microprocessors,
microcontrollers, and other programmable devices. It implements a symbolic representation of
the machine and other constants needed to program a given CPU architecture. This representation
is usually defined by the hardware manufacturer, and is based on mnemonics that symbolize
processing steps (instructions), processor registers, memory locations, and other language features.
An assembly language is thus specific to a certain physical (or virtual) computer architecture. This
is in contrast to most high-level programming languages, which, ideally, are portable.
A utility program called an assembler is used to translate assembly language statements into the
target computer’s machine code. The assembler performs a more or less isomorphic translation
(a one-to-one mapping) from mnemonic statements into machine instructions and data. This
is in contrast with high-level languages, in which a single statement generally results in many
machine instructions.
(a) Assembly instructions are just shorthand for machine instructions:
Machine Language Equivalent Assembly
1000000100100101 Load R1 5
1000000101000101 Load R2 5
1010000100000110 ADD R0 R1 R2
1000001000000110 SAVE R0 6
1111111111111111 HALT
(b) (For all assembly instructions that compute a result, the first argument is the destination.)
(c) Very easy to write an Assembly Language > Machine language translator.
What would be the assembly instruction to swap the contents of registers 1 & 2?
We are missing some crucial functionality…
Loops!
R0 3 0 ADD R3 R2 R3
R1 1 R1 SUB R0 R0 R1
R2 BZERO 4
R2 Number
R3 BRANCH 4
R3 0 4 MOVE R2 R3
5 HALT
212 LOVELY PROFESSIONAL UNIVERSITY