The closest language to the machine hardware is Assembly language, which readily converts to machine code- the ones and zeros. Assembly Language is a low-level programming language. It helps in understanding the programming language to machine code. In computers, there is an assembler that helps in converting the assembly code into machine code executable. Assembly language is designed to understand the instruction and provide it to machine language for further processing. It mainly depends on the architecture of the system, whether it is the operating system or computer architecture.
Assembly Language mainly consists of mnemonic processor instructions or data and other statements or instructions. It is produced with the help of compiling the high-level language source code like C, C++. Assembly Language helps in fine-tuning the program.
In the 1950s, most computer users worked either in scientific research labs or in large corporations. The former group used computers to help them make complex mathematical calculations (e.g., missile trajectories), while the latter group used computers to manage large amounts of corporate data (e.g., payrolls and inventories). Both groups quickly learned that writing programs in the machine language of zeros and ones was not practical or reliable. This discovery led to the development of assembly language in the early 1950s, which allows programmers to use symbols for instructions (e.g., ADD for addition) and variables (e.g., X). Another program, known as an assembler, translated these symbolic programs into an equivalent binary program whose steps the computer could carry out, or “execute.”
While the first assemblers would- by necessity- have been written in machine code, later ones could be written in assembly, building on foundations already established. These days assemblers are written in higher level languages such as C.
This free software can be downloaded here. You can download the self-extracting zip - just make sure that you save it in a folder on the desktop and then extract to this folder. The zip can be deleted afterwards. Create a shortcut to the exe file afterwards and place this in your taskbar.
The simulator allows you to write and run assembly language code
Here are a selection of the learning tasks grouped together with pointers to the example programs and explanatory notes. Note that we are not learning Assembly language code, but doing some exercises so that you will always remember the joy that programmers in the 1950s experienced. If you get as far as the ascii code- great. The last exercise is a bonus or punishment depending on how you fare in the ones before this.
Example - 01first.asm - Arithmetic
Write a program that subtracts using SUB
Write a program that multiplies using MUL
Write a program that divides using DIV
Write a program that divides by zero. Make a note to avoid doing this in real life.
________________________________________
Example - 02tlight.asm - Traffic Lights
Use the notes on Hexadecimal and Binary numbers. Work out what hexadecimal numbers will activate the correct traffic lights. Modify the program to step the lights through a realistic sequence.
First light - red (only)
Second light - green (only)
Second light - amber (only)
Second light - red (only)
First light - green(only)
and so on.
________________________________________
Example - 03move.asm
Look up the ASCII codes of H, E, L, L and O and copy these values to memory locations C0, C1, C2, C3 and C4. This is a simple and somewhat crude way to display text on a memory mapped display.
________________________________________
Example - 04incjmp.asm
Rewrite the example program to count backwards using DEC BL.
Rewrite the example program to count in threes using ADD BL,3.
Rewrite the program to count 1 2 4 8 16 using MUL BL,2
Here is a more difficult task. Count 0 1 1 2 3 5 8 13 21 34 55 98 overflow. Here each number is the sum of the previous two. You will need to use two registers and two RAM locations for temporary storage of numbers. If you have never programmed before, this is a real brain teaser. Remember that the result will overflow when it goes above 127.
This number sequence was first described by Leonardo Fibonacci of Pisa (1170_1230)