## ALP Programming Guide and Reference

[prev][next][parent][TOC]

### Type Declarations

A Type-Declaration is a common construct used in various assembler directives to establish type attribute information for a program object. A Type-Declaration is needed to determine the data type of a variable or labeled address. The TYPEDEF directive offers a method of assigning a name to a Type-Declaration.

Type-Declaration:
TypeName
TypeName Array-Spec
Pointer-Spec
Pointer-Spec TypeName
Pointer-Spec TypeName Array-Spec
Pointer-Spec:
PTR
Distance-TypeName PTR
Pointer-Spec Array-Spec
Array-Spec:
[ Expression ]
Array-Spec [ Expression ]
TypeName:
Distance-TypeName
Scalar-TypeName
UserDefined-TypeName

The TYPEDEF directive is used to illustrate the type declaration syntax:

    CHAR        typedef   byte               ;   Alias   of   intrinsic   TypeName
    PBYTE       typedef   ptr   byte          ;   Pointer   to   intrinsic   TypeName
    PCHAR       typedef   ptr   CHAR          ;   Pointer   to   TypeDef - TypeName
    PPCHAR      typedef   ptr   PCHAR         ;   Pointer   to   a   pointer   to   a   CHAR
    PPBYTE      typedef   ptr   ptr   byte      ;   Similar   to   PPCHAR
    PVOID       typedef   ptr                ;   Pointer   to   nothing   ( pointer   to   code )
    PCODE       typedef   ptr   PROC          ;   Similar   to   PVOID
    PFCODE      typedef   far   ptr   far       ;   Far   pointer   to   far   code   address

    ;   vector   declarations

    ACHAR       typedef   CHAR [ 16 ]          ;   Array   of   16   characters
    AAWORD      typedef   word [ 2 ] [ 2 ]        ;   multi - dimensional   array
    APBYTE      typedef   ptr [ 8 ]   byte       ;   Array   of   8   pointers   to   byte
    APACHAR     typedef   ptr [ 4 ]   ACHAR      ;   Array   of   4   ptrs   to   arrays   of   16   chars

    SIZES _ T     struct                     ;   define   an   intrinsic   structure   type
       little    byte      ?
       Medium    word      ?
       BIG       dword     ?
    SIZES _ T     ends

    SIZES       typedef   SIZES _ T           ;   alias   for   intrinsic   structure   type
    PSIZES      typedef   ptr   SIZES _ T       ;   and   a   type   to   point   to   it

    PFORWARD    typedef   ptr   FORWARD       ;   Pointers   to   forward - referenced   types
    FORWARD     struct                     ;   are   assumed   to   be   pointers   to   structs
       blah      word      ?
    FORWARD     ends