show understanding of the relationship between assembly language and machine code, including symbolic and absolute addressing, directives and macros
Assembly Code and Machine CodeAssembly language is different from most high-level languages in that each assembly languages is specific to the CPU you are working with whereas most high-level languages can be used across multiple architectures. Assembly language is very close to machine code, with normally an instruction being the same in machine code, the only difference being that assembly language is easily understood by human beings where machine code is the lowest level of representation - binary. It is rare for anyone to program in numerical machine code these days due to the difficulty in working with it.
|
Absolute and Symbolic Addressing
Symbolic and absolute addressing are two different ways of referring to a memory location when programming in assembly language. Absolute addressing is when you specify the actual memory location to which you are referring to (for example #208). However this is not preferred because it comes with problems such as not having any indication about what data is stored at the location and you are also running the risk that another application isn't already using it.
In LMC after the final halt instruction we reserve memory locations. In the image to the right, two reservations have been named and labelled FIRST and SECOND. This is symbolic addressing where the programmer can refer to a label as the memory address, and the assembler is left to worry about which memory location to store it in.
In LMC after the final halt instruction we reserve memory locations. In the image to the right, two reservations have been named and labelled FIRST and SECOND. This is symbolic addressing where the programmer can refer to a label as the memory address, and the assembler is left to worry about which memory location to store it in.
Preprocessor Directives
|
The preprocessor examines the code and makes adjustments before handing it over to the compiler to compile it. One job it always undertakes is the removal of comments from the code. Preprocessor directives are lines included in the code of programs, but they are not program statements, but instructions for the preprocessor. An example of this is when a developer wants a certain line of code to run when the code is being run in a debugger, but doesn't want it to be in the finished version. This could be a print statement that you wish to see when testing the code, but not when the final code is compiled. Preprocessor directives are more common in languages like C and C++ and are always proceeded by a # (but do not confuse this with the # used to comment in Python).
|