WORD


SUNDB86x Only

 

The WORD compiler directive allows the insertion of 16-bit values that represent machine code instructions within PL/B source code. These values perform instructions normally unavailable in PL/B. The instruction uses one of the following formats:

 

(1)

[label]

WORD

{code}

(2)

[label]

WORD

{code}:

 

 

 

{code}:

 

 

 

...etc.

 

Where:

label

Optional. A Program Execution Label.

code

Required. One or more control literals (binary, decimal, hex or octal), Data Definition Labels, or a VARLIST of valid data definition labels containing 16 bit absolute machine code inserted into the PL/B program.

Flags Affected: NONE

Note the following:

  1. The value of each item in {code} is not translated but written into the output code exactly as given, in correct byte order (i.e., the least significant 8-bits followed by the most significant 8-bits). This instruction should only be used by programmers knowledgeable in machine language. This is an area where Sunbelt may offer examples but will not provide support, except at prevailing time and material consulting rates.

  2. Multiple {code} items may be placed on a single line and may be continued onto other lines using the colon (:) line continuation technique.

  3. A Data Definition Label may be a {list} item to reference a variable. The compiler automatically inserts the address of the variable, in correct byte order, in place of the referenced variable.

  4. Multiple +/- operations may be performed on an address by placing a plus (+) or minus (-) sign and a valid Ctrl literal designating the number of offset bytes immediately following the Data Definition Label.

  5. When referencing variables within {code}, care should be taken not to overwrite the variable designator or FP/LP (as appropriate). When a Data Definition Label is used, the memory location referenced is not the first byte of the data for the variable. Therefore, it is necessary to increment this address by one (1) for FORMs or INTEGERs and by two (2) for DIMs or INITs to access the data therein.

  6. Moving data into a DIM/INIT does not automatically adjust the FP or LP as if performed through other PL/B instructions. Any data transferred may not be accessible until the FP and LP have been adjusted appropriately.

  7. If the DS, ES, SS, or SP registers are modified, they must be saved prior to such modification and restored before executing a PL/B instruction other than BYTE or WORD. The saving and restoration may be accomplished using BYTE/WORD instructions.

  8. To write out multiple 8-bit values, BYTE should be used instead of WORD.

 

Example 1:

 

*

 

 

 

.Print the screen on the default printer.

.

 

 

 

  

WORD

0x5CD

;INT 5 ;MS-DOS Print Screen

 

In this example, it is better to use BYTE since the bytes must be reversed in order to write them in correct byte order format.

 

Example 2:

 

*

 

 

 

.Determine total configured memory in bytes.

.

 

 

 

TEMP

INTEGER

2

 

MEMORY

FORM

6

 

  

BYTE

0xBF

;MOV DI,OFFSET TEMP+1

  

WORD

TEMP+1

 

  

BYTE

0xCD,0x12

;INT 12

  

BYTE

0xAB

;STOSW

  

MULT

"1024",TEMP,MEMORY

 

 

- Move the address of TEMP's data area (TEMP+1) into DI.

- INT 12 returns number of 1k blocks of configured memory in AX (in INTEGER format).

- MOVe the integer value returned in AX to TEMP (pointed to by DI) with STOSW.

- MULTiply TEMP by "1024" placing the result in MEMORY.

 

Example 3:

 

*

 

 

 

.Turn off the NUM Lock on a PC.

.

 

 

 

  

BYTE

0x1E

;PUSH DS

  

BYTE

0xB8

;MOV AX,40H

  

WORD

0x40

 

  

BYTE

0x8E,0xD8

;MOV DS,AX

  

BYTE

0x80,0x26

;AND DS:Byte Ptr [17H],NOT 20H

  

WORD

0x17

 

  

BYTE

0xDF

 

  

BYTE

0x1F

;POP DS

 

- Save contents of DS register.

- Load the AX register with next 2 bytes (0x40).

- Move the contents of AX into DS.

- Bitwise AND a byte value (the NOT value of 20H - 0xDF) into an address (0x17).

- Restore contents of DS register

 

 

 

See Also: BYTE, BYTEX, ENTERZ/EXITZ, WORDX,

 

 



PL/B Language Reference WARNING WORDX