Page 196 - ARM 64 Bit Assembly Language
P. 196
Abstract data types 183
6.4 Chapter summary
The abstract data type is a structured programming concept which contributes to software re-
liability, eases maintenance, and allows for major revisions to be performed in as safe way.
Many high-level languages enforce, or at least facilitate, the use of ADTs. Assembly lan-
guage does not. However, the ethical assembly language programmer will give the extra effort
to write code that conforms to the standards of structured programming, using abstract data
types to help ensure safety, reliability, and maintainability.
ADTs also facilitate the implementation of software modules in more than one language. The
interface specifies the components of the ADT, but not the implementation. The implementa-
tion can be in any language. As long as assembly programmers and compiler authors generate
code that conforms to a well-known standard, their code can be linked to code written in other
languages.
Poor coding practices and poor design can lead to dire consequences, including loss of life.
It is the responsibility of the programmer, regardless of the language used, to make ethical
decisions in the design and implementation of software. Above all, the programmer must be
aware of the possible consequences of the decisions they make.
Exercises
6.1. What are the advantages of designing software using abstract data types?
6.2. Why is the Pixel data type hidden from client code in Listing 6.2?
6.3. High level languages provide mechanisms for information hiding, but assembly does
not. Why should the assembly programmer not simply bypass all information hiding
and access the internal data structures directly?
6.4. The assembly code in wl_print_numerical accesses the internal structure of the
wordlistnode data type. Why is it allowed to do so? Should it be allowed to do so?
6.5. Given the following definitions for a stack ADT:
1 /* File: stack.h */
2
3 typedef struct IntStackStruct *IntStack;
4
5 /* create an empty stack and return a pointer to it */
6 IntStack InitStack ();
7
8 /* Push value onto the stack.
9 Return 1 for success. Return 0 if stack is full. */
10 int Push (IntStack stack, int k);
11
12 /* Remove value from top of stack.