COS2621
EXAM PACK
,COS2621 2018 MEMO
1.1
1.2 2
1.3 1
1.4 5
1.5 1
1.6 4
1.7 5
1.8 3
1.9 5
1.10 3
1.11 1
1.12 4
1.13 1
1.14 1
1.15 3
,mov ax,2h //2 cycles to execute + 4 cycles to fetch
mov bx,3h //2 cycles to execute + 4 cycles to fetch
mul bx //5 cycles to execute + 4 cycles to fetch
add ax,bx //4 cycles to execute + 4 cycles to fetch
Total cycles = 29 cycles which requires 29 x 0.00125 μsec = 0.03625 μsec
Disadvantages
1. Development time. Writing code in assembly language takes much longer than
, writing in a high-level language.
2. Reliability and security. It is easy to make errors in assembly code. The assembler is not
checking if the calling conventions and register save conventions are obeyed.
3. Debugging and verifying. Assembly code is more difficult to debug and verify because there
are more possibilities for errors than in high-level code.
4. Maintainability. Assembly code is more difficult to modify and maintain because the
language allows unstructured spaghetti code and all kinds of tricks that are difficult for others to
understand. Thorough documentation and a consistent programming style are needed.
5. Portability. Assembly code is platform-specific. Porting to a different platform is difficult.
1. Debugging and verifying. Looking at compiler-generated assembly code or the disassembly
window in a debugger is useful for finding errors and for checking how well a compiler
optimizes a particular piece of code.
2. Making compilers. Understanding assembly coding techniques is necessary for making
compilers, debuggers and other development tools.
3. Embedded systems. Small embedded systems have fewer resources than PCs
and mainframes. Assembly programming can be necessary for optimizing code for speed or size
in small embedded systems.
4. Hardware drivers and system code. Accessing hardware, system control registers,
and so on may sometimes be difficult or impossible with high level code.
5. Accessing instructions that are not accessible from high-level language.
Certain assembly instructions have no high-level language equivalent.
6. Self-modifying code. Self-modifying code is generally not profitable because it
EXAM PACK
,COS2621 2018 MEMO
1.1
1.2 2
1.3 1
1.4 5
1.5 1
1.6 4
1.7 5
1.8 3
1.9 5
1.10 3
1.11 1
1.12 4
1.13 1
1.14 1
1.15 3
,mov ax,2h //2 cycles to execute + 4 cycles to fetch
mov bx,3h //2 cycles to execute + 4 cycles to fetch
mul bx //5 cycles to execute + 4 cycles to fetch
add ax,bx //4 cycles to execute + 4 cycles to fetch
Total cycles = 29 cycles which requires 29 x 0.00125 μsec = 0.03625 μsec
Disadvantages
1. Development time. Writing code in assembly language takes much longer than
, writing in a high-level language.
2. Reliability and security. It is easy to make errors in assembly code. The assembler is not
checking if the calling conventions and register save conventions are obeyed.
3. Debugging and verifying. Assembly code is more difficult to debug and verify because there
are more possibilities for errors than in high-level code.
4. Maintainability. Assembly code is more difficult to modify and maintain because the
language allows unstructured spaghetti code and all kinds of tricks that are difficult for others to
understand. Thorough documentation and a consistent programming style are needed.
5. Portability. Assembly code is platform-specific. Porting to a different platform is difficult.
1. Debugging and verifying. Looking at compiler-generated assembly code or the disassembly
window in a debugger is useful for finding errors and for checking how well a compiler
optimizes a particular piece of code.
2. Making compilers. Understanding assembly coding techniques is necessary for making
compilers, debuggers and other development tools.
3. Embedded systems. Small embedded systems have fewer resources than PCs
and mainframes. Assembly programming can be necessary for optimizing code for speed or size
in small embedded systems.
4. Hardware drivers and system code. Accessing hardware, system control registers,
and so on may sometimes be difficult or impossible with high level code.
5. Accessing instructions that are not accessible from high-level language.
Certain assembly instructions have no high-level language equivalent.
6. Self-modifying code. Self-modifying code is generally not profitable because it