Page 3 - K ADAK; TECHNICAL SUPPORT
AMX 86 User's Guide K ADAK i TECHNICAL SUPPORT KADAK Products Ltd. is committed to technical support for its software products. Ourprograms are designed to be easily incorporated in your systems and every effort hasbeen made to eliminate errors. Engineering Change Notices (ECNs) are provided periodi...
Page 4 - Copyright
ii K ADAK AMX 86 User's Guide Copyright © 1990-2005 by KADAK Products Ltd. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed,stored in a retrieval system, or translated into any language or computerlanguage, in any form or by any means, electronic, mechanic...
Page 5 - Section 1: System Description
AMX 86 User's Guide K ADAK iii AMX 86 USER'S GUIDE Table of Contents Page Section 1: System Description 1. AMX Overview 1 1.1 Introduction ........................................................................................ 1 1.2 Glossary ............................................................
Page 7 - Section 2: System Construction; Section 3: Programming Guide
AMX 86 User's Guide K ADAK v AMX 86 USER'S GUIDE Table of Contents (Cont'd.) Page Section 1: System Description (Cont'd.) 12. AMX Linked List Manager 139 12.1 Introduction ...................................................................................... 13912.2 Linked Lists .......................
Page 8 - Appendices
vi K ADAK AMX 86 User's Guide AMX 86 USER'S GUIDE Table of Contents (Cont'd.) Page Appendices A. AMX 86 Reserved Words 347 B. AMX 86 Error Codes 349 C. Configuration Generator Specifications 353 C.1 Introduction ....................................................................................... ...
Page 9 - The AMX
AMX Overview K ADAK 1 1. AMX Overview 1.1 Introduction The AMX ™ Multitasking Executive provides a simple solution to the complexity of real- time multitasking. AMX supervises the orderly execution of a set of application programmodules called tasks. AMX allows the system designer to concentrate on ...
Page 10 - Section Summary
2 K ADAK AMX Overview Section Summary This manual is divided into three sections. Each section is divided into chapters. Section 1 of this manual describes the AMX Multitasking System and how it is used.Separate chapters are provided for each of the AMX managers. Section 2 describes the AMX System C...
Page 15 - AMX Nomenclature
AMX Overview K ADAK 7 1.3 AMX Nomenclature The following nomenclature has been adopted throughout the AMX User's Guide. Processor registers are referenced as follows: 8-Bit Registers AH, AL, BH, BL, CH, CL, DH, DL 16-Bit Registers AX, BX, CX, DX, SP, BP, SI, DI Instruction Pointer IP Flags (Conditio...
Page 16 - This page left blank intentionally.
8 K ADAK AMX Overview This page left blank intentionally.
Page 17 - General AMX Operation; The AMX Multitasking Executive provides a simple solution to the; Example
General AMX Operation K ADAK 9 2. General AMX Operation 2.1 Introduction to Multitasking A real-time system is characterized by the need to respond rapidly to events occurring asynchronously in time. A multitasking system is one in which a number of activities orprocesses must be performed simultane...
Page 19 - AMX Startup; . Operating characteristics are defined in an AMX System
General AMX Operation K ADAK 11 2.2 AMX Operation AMX Startup Each AMX-based system consists of the AMX executive program and a set ofapplication tasks and interrupt service procedures. This collection of programs residentin the memory of the microprocessor configuration represents the entire operat...
Page 21 - The Task Scheduler
General AMX Operation K ADAK 13 The Task Scheduler Following system initialization, AMX proceeds to its Task Scheduler. The TaskScheduler searches its list of available tasks to determine the highest priority task capableof execution. Task execution priorities are determined by the system designer. ...
Page 22 - The Interrupt Supervisor; Two types of ISPs exist: nonconforming ISPs and conforming ISPs.; nonconforming ISP; must quickly service the device to remove the interrupting; conforming ISP; can make use of a subset of the AMX service procedures. A
14 K ADAK General AMX Operation The Interrupt Supervisor Tasks execute with the processor interrupt facility enabled to permit service of externaldevices. When an external interrupt occurs, the task is interrupted in the manner dictatedby the processor. The processor automatically saves the return a...
Page 23 - Timing Facilities
General AMX Operation K ADAK 15 Timing Facilities The AMX Timer Manager provides a Clock Handler and a Kernel Task to providecomplete timing control for your real-time application. The AMX Clock Handler isindependent of any particular hardware configuration. If AMX timing facilities are to beutilize...
Page 24 - Message Queuing
16 K ADAK General AMX Operation Message Queuing One of the more powerful features of AMX is its ability to queue messages for tasks.The queuing facility permits messages to pile up in a controlled fashion, freeing the ISP,Timer Procedure or task which is sending the message to continue with its appo...
Page 25 - Semaphore Manager
General AMX Operation K ADAK 17 2.3 AMX Managers AMX provides a set of managers to simplify event synchronization, resourcemanipulation and memory allocation. Not all applications will make use of all of themanagers. The system designer can decide which of the AMX managers is best suitedfor a partic...
Page 26 - Task Mailbox
18 K ADAK General AMX Operation The AMX 86 Task Mailbox facility provides a general purpose message queuing mechanism for tasks. This service is not provided by a separate AMX manager; it is aninherent feature of AMX 86. Any task can have up to four private mailboxes in whichthe task can receive AMX...
Page 27 - The; Circular List Manager; provides a general purpose circular list facility for; Linked List Manager; provides a fast, general purpose doubly-linked list facility for
General AMX Operation K ADAK 19 The Circular List Manager provides a general purpose circular list facility for maintaining compact lists of 8-bit, 16-bit or 32-bit variables. Circular lists areparticularly useful for managing character streams associated with input/output devices. The Linked List M...
Page 28 - Bit
20 K ADAK General AMX Operation 2.4 Starting AMX An AMX operating system consists of AMX, the subset of its managers which youchoose to use and your complement of application programs. All of these modules areconnected together to form the AMX operating system as described in the AMX ToolGuide. Befo...
Page 29 - Permanent Launch
General AMX Operation K ADAK 21 Permanent Launch In most applications, your AMX operating system is resident in ROM or loaded intoRAM. AMX is started in real mode and given permanent control of the processor. An AMX system can be launched permanently from a main program coded in C asillustrated in t...
Page 31 - Temporary Launch
General AMX Operation K ADAK 23 Temporary Launch Your AMX operating system can be started, allowed to run for a while and then stopped.This type of operation is called a temporary launch. The most common application ofthis type occurs on PC compatibles. An AMX operating system is started from DOS,al...
Page 33 - Application Tasks; to find the task id allocated by
Application Tasks K ADAK 25 3. Application Tasks 3.1 Task Creation The AMX Multitasking Executive provides a simple solution to the complexity of real-time multitasking. AMX supervises the orderly execution of a set of application program modules called tasks. Each task solves a particular problem a...
Page 34 - For this reason, such tasks are called; trigger tasks; ends would appear as follows:; message tasks; or
26 K ADAK Application Tasks Tasks which do not receive messages are written as Large or Medium model C functionswithout formal parameters. These tasks must be started using AMX procedure ajtrig . For this reason, such tasks are called trigger tasks . For example, a task that immediately ends would a...
Page 35 - A task is always in one of the following states:
Application Tasks K ADAK 27 3.2 Task States A task is always in one of the following states: IdleReadyRunWaitHalt When a task is created, AMX assigns it a Task Control Block and sets it in the idle state.An idle task has no outstanding requests to execute pending. It is waiting to be triggered. A re...
Page 36 - Idle
28 K ADAK Application Tasks event of interestor timeout occurs ajtrig - trigger a task ajwait - wait ajwatm - timed wait ajsenw - send message to taskmailbox and wait for ack ajmxwat - wait on a message exchange ajsmrsv - reserve a resource ajsmwat - wait on a semaphore ajevwat - wait for event task...
Page 40 - Task and Event Synchronization; wait
32 K ADAK Application Tasks 3.6 Task and Event Synchronization AMX offers several simple forms of task/event synchronization. Using the ajwait call, a task can unconditionally wait for an event. The event can be task dependent, device dependent or time dependent. The task, having issued an ajwait ca...
Page 44 - Messages can be sent to a task by:
36 K ADAK Application Tasks 3.9 Message Passing AMX supports the passing of a message to a task mailbox or message exchange. Messages can be sent to a task by: Application TasksInterrupt Service ProceduresTimer ProceduresRestart ProceduresExit Procedures You can send a message to a task mailbox or m...
Page 46 - MESSAGE EXCHANGE
38 K ADAK Application Tasks Figure 3.9-1 provides an example of the manner in which messages are allowed to queueon a message exchange. The same message queuing technique is used when messagesare sent to a task's private mailboxes within its Task Control Block (TCB). In the example, the following si...
Page 49 - Message Extension; programmers will find the message extension on the task stack at
Application Tasks K ADAK 41 Message Extension AMX delivers messages to a task by copying the message from a message envelope to amessage frame on the task's stack. AMX also presents an extension to the applicationmessage on the task's stack. The message extension identifies who sent the message and,...
Page 50 - Restart Procedures
42 K ADAK Application Tasks 3.10 Restart Procedures The manner in which the operating system begins execution is application dependent.Execution begins in the user domain providing the opportunity for hardware specific andapplication dependent setup prior to the initialization of the AMX system. For...
Page 51 - Note
Application Tasks K ADAK 43 Restart Procedures can enable specific device interrupts if required. Note that interruptsfrom a device should not be enabled until the application ISP has been installed and madeready to handle the interrupting device. Restart Procedures should not enable the processor i...
Page 52 - Exit Procedures
44 K ADAK Application Tasks 3.11 Exit Procedures An AMX system can be shut down in an orderly fashion by a task call to procedure ajexit . The manner in which the operating system ends execution is application dependent. For example, hardware interfaces may require restoration to their initialstates...
Page 54 - Task Enhancements; Task Control Block Extension; Stack Fences
46 K ADAK Application Tasks 3.12 Task Enhancements AMX offers several task enhancements which, although rarely used, can occasionallycome in handy. These enhancements are briefly summarized below. Task Control Block Extension Within a task's Task Control Block, 16 bytes are reserved for the private ...
Page 55 - AMX Kernel Task Priority; to change the priority of the AMX Kernel Task.
Application Tasks K ADAK 47 AMX Kernel Task Priority The AMX Kernel Task operates as the highest priority task in your AMX system. Itsexecution priority is zero. It has the reserved task tag 'AMXK' . Occasionally, an application is encountered in which a task must execute at very highpriority in ord...
Page 57 - Interrupt Service Procedures; Tasks must execute with the interrupt facility enabled.
Interrupt Service Procedures K ADAK 49 4. Interrupt Service Procedures 4.1 The Processor Interrupt Facility The key to event-driven, real-time, multitasking systems is the processor's interruptfacility. Tasks execute with the interrupt facility enabled permitting the system torespond to a real-time ...
Page 59 - ISPs for External Interrupts; Nonconforming ISPs; allow an interrupt to; Conforming ISPs
Interrupt Service Procedures K ADAK 51 4.2 ISPs for External Interrupts Two types of ISPs exist: nonconforming ISPs and conforming ISPs. Nonconforming ISPs A nonconforming ISP must quickly service the device to remove the interruptingcondition. The ISP must preserve all registers which it uses. The ...
Page 60 - important
52 K ADAK Interrupt Service Procedures If the Interrupt Handler requested AMX to initiate or resume execution of some task ofhigher priority than the interrupted task, the AMX Interrupt Supervisor suspends theinterrupted task and marks it as ready to resume execution at the earliest opportunity.The ...
Page 61 - Conforming ISP Construction
Interrupt Service Procedures K ADAK 53 Conforming ISP Construction The construction of an Interrupt Service Procedure (ISP) to service an external interruptis a simple process. The conforming ISP consists of two parts: the ISP root and your Interrupt Handler. The ISP root is a code fragment most eas...
Page 62 - . The ISP begins execution at address
54 K ADAK Interrupt Service Procedures The Interrupt Service Procedure should be coded using assembly language if speed ofexecution is critical. EXTRN AAINT:FAR EXTRN AAINX:FAR ;DVC_CODE SEGMENT BYTE 'CODE'; PUBLIC DVCISP ; The ISP is located in user program memory; ASSUME CS:DVC_CODE ;DVCISP PROC F...
Page 64 - Nested Interrupts; Warning
56 K ADAK Interrupt Service Procedures 4.3 Nested Interrupts AMX supports nested interrupts. The AMX Interrupt Supervisor maintains a privatenesting level indicator. AMX must be informed of the start ( AAINT ) and end ( AAINX ) of each interrupt. When AMX sees that a task has been interrupted, it sw...
Page 65 - Wait/Wake Synchronization
Interrupt Service Procedures K ADAK 57 4.4 ISP/Task Communication AMX provides a set of service procedures to ease the communication between tasks anddevice Interrupt Handlers. These AMX procedures simplify event synchronization andpermit parameter passing to tasks. Wait/Wake Synchronization The ajw...
Page 66 - Semaphore Synchronization
58 K ADAK Interrupt Service Procedures Semaphore Synchronization The AMX Semaphore Manager provides an even more powerful synchronizationcapability. It provides the automatic timeout facility and also allows more than one taskto wait for the same event, with each task determining its own waiting pri...
Page 67 - Task Triggering; call to AMX; Message Transmission; call to AMX
Interrupt Service Procedures K ADAK 59 Task Triggering An Interrupt Handler can communicate with a task by invoking the task's execution.When an interrupt occurs, the Interrupt Handler issues the ajtrig call to AMX identifying the task which it wishes to have executed. This technique can be very use...
Page 68 - Task Error Traps
60 K ADAK Interrupt Service Procedures 4.5 Task Error Traps The 80x86 processor automatically detects the occurrence of execution errors such asdivision by zero, arithmetic overflow or an array bound violation. These errors, by theirvery nature, must be handled by the application in the context of t...
Page 73 - Special Interrupts; Nonconforming Interrupts; ISPs of this type are called; nonconforming ISPs; . You must arrange in hardware that all; Occasional Task Interaction; a conforming
Interrupt Service Procedures K ADAK 65 4.7 Special Interrupts Nonconforming Interrupts In some systems there may be devices which generate interrupts requiring nocommunication or synchronization with any task in the system. For example, a high-speed scanner can interrupt the processor whenever new d...
Page 74 - Shared Interrupt Handlers
66 K ADAK Interrupt Service Procedures Shared Interrupt Handlers Occasionally a single Interrupt Handler can be used to service more than one identicaldevice. For example, an Interrupt Handler for an asynchronous serial I/O device (UART)could be used to service the UART for each of several communica...
Page 76 - Vector Table Initialization; Divide by zero; Overflow; Bound error
68 K ADAK Interrupt Service Procedures 4.8 Vector Table Initialization The 80x86 processor operating in real mode vectors to an Interrupt Service Procedure(ISP) directly through its Interrupt Vector Table which, in AMX nomenclature, is simplycalled the AMX Vector Table. The Vector Table may be locat...
Page 77 - AMX Timing Control; Task Delays and Timeouts
AMX Timing Control K ADAK 69 5. AMX Timing Control 5.1 Introduction to Timing Facilities Most real-time systems are characterized by the need to provide precise control over thetiming of activities. A hardware clock provides the timing source; AMX provides thecontrol over its use. The unit of time i...
Page 78 - Calendar Clock
70 K ADAK AMX Timing Control Calendar Clock The AMX Time/Date Manager provides Y2K compliant time of day calendar support ifrequired. The AMX calendar clock includes second, minute, hour, day, month, year andday of the week. AMX services are provided to set and read the calendar clock. Aformatting p...
Page 79 - AMX Clock Handler and Kernel Task
AMX Timing Control K ADAK 71 5.2 AMX Clock Handler and Kernel Task AMX includes a conforming clock ISP root, a Clock Handler and a Kernel Task toprovide timing facilities. Whenever a clock interrupt occurs, the clock ISP root calls yourapplication clock Interrupt Handler to dismiss the hardware cloc...
Page 80 - Clock ISP Implementation
72 K ADAK AMX Timing Control Clock ISP Implementation AMX can provide timing facilities only if a hardware clock interrupt is available. Forefficiency, it is recommended that the clock ISP be coded in assembly language asillustrated below. Note that the clock ISP root and Interrupt Handler have been...
Page 83 - Interval Timers and Timer Procedures
AMX Timing Control K ADAK 75 5.3 Interval Timers and Timer Procedures AMX supports any number of application interval timers in a system. The maximumnumber in a system is defined in your System Configuration Module (see Chapter 14.5). A timer must be created by an application before it can be used. ...
Page 85 - example, it is assumed that; is a; pointer to an application structure of type; Application Timer Procedures use the AMX Kernel Stack.
AMX Timing Control K ADAK 77 Timer Procedures can be written as Large or Medium model C functions with formalparameters. #include "amx831cf.h" /* AMX C Interface Header */ void cdecl truser( /* Timer Procedure */ AMXID timerid, /* timer id */ struct userblock FAR *userp) /* pointer to user b...
Page 86 - The Timer Procedure can be coded in assembler as a
78 K ADAK AMX Timing Control The Timer Procedure can be coded in assembler as a FAR procedure as follows: TMR_CODE SEGMENT BYTE 'CODE';; The Timer Procedure is located in user program memory; ASSUME CS:TMR_CODE ;TRUSER PROC FAR MOV DX,WORD PTR [BP] ;DX = timer id LES BX,DWORD PTR [BP+2] ;ES:BX = 32-...
Page 87 - Task Time Slicing; can be disabled again with a subsequent call to; prior to executing any
AMX Timing Control K ADAK 79 5.4 Task Time Slicing AMX provides task time slicing as an option. The AMX system must be configured toinclude a clock if time slicing is to be possible. Time slice intervals are then specified asmultiples of the AMX system tick. Time slicing is normally disabled. It is ...
Page 88 - both triggered by a higher priority task A which then ended.; Task B
80 K ADAK AMX Timing Control Figure 5.4-1 illustrates the allocation of processing time to two tasks, B and C. Task Bwas created first with a time slice interval of 100 AMX system ticks. Task C was createdlater with a time slice interval of 50 AMX system ticks. At time t1 , tasks B and C were both t...
Page 90 - Get Time and Date
82 K ADAK AMX Timing Control 5.5 Time/Date Manager Most real-time systems require the maintenance of a calendar clock. The AMXTime/Date Manager provides this facility. The Y2K compliant calendar clock maintained by the Time/Date Manager includessecond, minute, hour, day, month and year. Leap year is...
Page 91 - Operation; The Time/Date Manager
AMX Timing Control K ADAK 83 Operation The Time/Date Manager includes two components: an AMX Restart Procedure and a setof service procedures. If your AMX System Configuration Module enables the Time/Date option, AMXautomatically calls the Time/Date Restart Procedure during the launch prior to execu...
Page 96 - Time/Date ASCII Formats
88 K ADAK AMX Timing Control Time/Date ASCII Formats The Time/Date Manager procedure ajtdf can be used to format time and date into an ASCII character string in any of several popular formats. The time and date is presentedto ajtdf in the standard AMX time/date structure. The ASCII string is returne...
Page 99 - AMX Semaphore Manager; counting semaphore
AMX Semaphore Manager K ADAK 91 6. AMX Semaphore Manager 6.1 Introduction E.W. Dijkstra introduced two primitive operations to resolve two seemingly unrelatedproblems: mutually exclusive access by tasks to critical resources and thesynchronization of asynchronously occurring activities. The abstract...
Page 101 - A semaphore is created with a call to procedure; indicating the type of; to find the semaphore
AMX Semaphore Manager K ADAK 93 6.2 Semaphore Use The Semaphore Manager supports any number of semaphores. The maximum number ofsemaphores in a system is defined in your System Configuration Module (see Chapter14.5). The defined maximum sets an upper limit on the number of actual semaphoresthat can ...
Page 102 - Counting Semaphore
94 K ADAK AMX Semaphore Manager Counting Semaphore A counting semaphore is created by specifying an initial semaphore count greater than orequal to zero in the call to ajsmcre . When used for mutual exclusion, the semaphore should be given an initial value of one. If a semaphore is initialized with ...
Page 103 - Resource Semaphore
AMX Semaphore Manager K ADAK 95 Resource Semaphore AMX resource semaphores provide the simplest mechanism for controlling the access tocritical resources. Resources may include disk files, I/O devices, database components,regions of memory, specific words of memory or any other entity which is consi...
Page 104 - . However, they must specify a timeout value of less than zero so that; returns an error indication.
96 K ADAK AMX Semaphore Manager If the resource does not become available within the timeout interval specified by thetask, the task will be removed from the resource semaphore wait queue and will resumeexecution with a timeout indication. Tasks which need to use a resource but which cannot wait for...
Page 105 - Semaphore Applications; Mutual Exclusion
AMX Semaphore Manager K ADAK 97 6.3 Semaphore Applications Mutual Exclusion Assume that three tasks, A, B and C, require shared access to a common data structurebeing used to control some process. Access to the data structure must be mutuallyexclusive so that one task cannot be modifying the data in...
Page 107 - Task/Event Synchronization; A task creates a counting semaphore with an initial count of zero.
AMX Semaphore Manager K ADAK 99 Task/Event Synchronization A counting semaphore can be used to provide synchronization between a task waiting foran event and a task, ISP or Timer Procedure in which the event is detected. Thefollowing example assumes that a device ISP detects the event. A task create...
Page 108 - . The underscore is required because we
100 K ADAK AMX Semaphore Manager EXTRN AAINT:FAR ;enter ISP EXTRN AAINX:FAR ;leave ISP EXTRN AASMSIG:FAR ;signal to a semaphore EXTRN _SYNCISP:WORD ;ISP synchronization semaphore id ;;DVC_CODE SEGMENT BYTE 'CODE'; ASSUME CS:DVC_CODE ;;DVCISP PROC FAR CALL AAINT ;tell AMX :Clear interrupt sourceCheck...
Page 109 - Resource Nesting
AMX Semaphore Manager K ADAK 101 Resource Nesting Assume that two tasks, A and B, have to share a numeric coprocessor. Furthermore,these two tasks also must share a common library procedure ncmath which must use the coprocessor. A resource semaphore must be used because ownership of the numeric copr...
Page 111 - AMX Event Manager; to wait for the motor to turn on. When the motor control ISP detects
AMX Event Manager K ADAK 103 7. AMX Event Manager 7.1 Introduction The AMX Event Manager provides the most general form of event synchronizationoffered by AMX. The Event Manager provides a convenient mechanism for separatingthe tasks waiting for events from the tasks, Timer Procedures and Interrupt ...
Page 113 - Event Synchronization
AMX Event Manager K ADAK 105 7.2 Event Synchronization The AMX Event Manager supports any number of event groups in a system. Each eventgroup includes 16 event flags. The maximum number of event groups in a system isdefined in your System Configuration Module (see Chapter 14.5). The defined maximums...
Page 114 - . The caller specifies the group id of the event group which; . The Event Manager will free the event group for reuse.
106 K ADAK AMX Event Manager Events are signalled by tasks, ISPs and Timer Procedures. The event is signalled with acall to procedure ajevsig . The caller specifies the group id of the event group which contains the particular event. More than one event can be signalled in a single call to ajevsig ....
Page 115 - Event Flag Application; Note that the Timer Procedure receives its timer's id; and a parameter; neither of which is used by the procedure.
AMX Event Manager K ADAK 107 7.3 Event Flag Application The following example, coded in C, is provided to illustrate the use of the AMX EventManager for event synchronization. The example shows two tasks, A and B, which must be synchronized to the state of amotor. Task A must wait for the motor to b...
Page 119 - AMX Message Exchange Manager
AMX Message Exchange Manager K ADAK 111 8. AMX Message Exchange Manager 8.1 Introduction The AMX Message Exchange Manager provides a very flexible, general purposemechanism for inter process communication and synchronization using prioritizedmessages. In particular, it offers an instant solution to ...
Page 120 - Create a message exchange
112 K ADAK AMX Message Exchange Manager The task's wait priority is not to be confused with the message queue priority. Themessage queue priority determines the priority ordering of messages in the messageexchange when no task is waiting for a message. The task's wait priority determines theorder of...
Page 121 - Message Exchange Use; Create; Send
AMX Message Exchange Manager K ADAK 113 8.2 Message Exchange Use The Message Exchange Manager supports any number of message exchanges. Themaximum number of message exchanges in a system is defined in your SystemConfiguration Module (see Chapter 14.5). The defined maximum sets an upper limit onthe n...
Page 122 - Receive; . If the message exchange has any messages, the highest priority; to get a message from a message exchange. Only; Delete
114 K ADAK AMX Message Exchange Manager Messages are sent to message exchanges in AMX message envelopes. The MessageExchange Manager gets a free message envelope from the common pool of envelopesmaintained by AMX. You must therefore be sure to allocate enough message envelopesto meet the needs of al...
Page 123 - Message Exchange Application
AMX Message Exchange Manager K ADAK 115 8.3 Message Exchange Application The following example, coded in C, is provided to illustrate the use of the AMX MessageExchange Manager. This example illustrates a solution to the problem posed in the introduction (Chapter 8.1).Two message processing tasks, A...
Page 127 - AMX Buffer Manager
AMX Buffer Manager K ADAK 119 9. AMX Buffer Manager 9.1 Introduction The AMX Buffer Manager simplifies the management of memory buffers in a real-timesystem. It provides a general mechanism for the allocation and control of fixed sizebuffers. The AMX Buffer Manager provides fast, efficient access to...
Page 128 - Create Buffer Pool; Buffer Manager procedure; is used to create a buffer pool. The Buffer Manager; to find the buffer pool
120 K ADAK AMX Buffer Manager 9.2 Buffer Pool Use The Buffer Manager supports any number of pools of buffers. The maximum number ofbuffer pools in a system is defined in your System Configuration Module (see Chapter14.5). The defined maximum sets an upper limit on the number of actual buffer poolsth...
Page 129 - Get Buffer; Free Buffer; Use Count; Size
AMX Buffer Manager K ADAK 121 Get Buffer Once a buffer pool has been created, you may call procedure ajbget to get a buffer from the pool. The Buffer Manager unlinks a buffer from the pool's free list, sets theassociated buffer use count to one and returns a pointer to the first byte of the buffer.Y...
Page 130 - Buffer Applications; call, sending the buffer pointer in an AMX message envelope to
122 K ADAK AMX Buffer Manager 9.3 Buffer Applications Consider the following example. A process control system using AMX has a printer onwhich errors and status messages are to be logged. These messages are generated byseveral tasks as they perform their process control functions. These tasks must n...
Page 132 - Buffer Manager Caveats; buffer
124 K ADAK AMX Buffer Manager 9.4 Buffer Manager Caveats Although the Buffer Manager attempts to check as many error conditions as possible, itcannot protect against a bad system design. However, if a little care is taken duringsystem design, the Buffer Manager can help make a system more reliable t...
Page 133 - AMX Memory Manager; are usually not reentrant.
AMX Memory Manager K ADAK rev9 125 10. AMX Memory Manager 10.1 Introduction The AMX Memory Manager simplifies the management of memory in an AMX system.It provides a general mechanism for the dynamic allocation and control of memory and isspecifically designed for use in a multitasking environment. ...
Page 135 - is a contiguous, double word aligned area of Random Access
AMX Memory Manager K ADAK 127 10.2 Nomenclature The following nomenclature has been adopted by the Memory Manager. A Memory Section is a contiguous, double word aligned area of Random Access Memory Random (RAM) which has been specified by the user to be under the control ofthe Memory Manager. A sect...
Page 136 - Memory Allocation; Get Memory; to get a block of memory of any size from the pool.; Free Memory
128 K ADAK AMX Memory Manager 10.3 Memory Allocation The Memory Manager maintains a single memory pool. The memory pool consists ofany number of memory sections of varying sizes measured in bytes. Any memorysection size which is a multiple of 4 and greater than or equal to 64 bytes is allowed.Usuall...
Page 137 - to be released twice before it becomes free.; The Memory Manager procedure; can be used to obtain the size of a particular
AMX Memory Manager K ADAK 129 Use Count When the Memory Manager allocates a block of memory for the use of a task, it sets theblock's use count to one. The block owner may call the Memory Manager procedure ajmau to increase the use count. If the use count is increased by one, the block will have to ...
Page 138 - Private Memory Allocation
130 K ADAK AMX Memory Manager 10.4 Private Memory Allocation A particularly unique feature of the Memory Manager permits any block of memory(including those acquired from the Memory Manager) to be treated as a memory sectionfrom which smaller private blocks can be dynamically allocated. To use this ...
Page 139 - Memory Assignment
AMX Memory Manager K ADAK 131 10.5 Memory Assignment The sections of memory which make up the memory pool controlled by the MemoryManager must be provided by your application. The Memory Manager makes noassumptions concerning the whereabouts of the memory over which it has control. Sections of memor...
Page 140 - Memory Assignment Procedure
132 K ADAK AMX Memory Manager 10.6 Memory Assignment Procedure An application Memory Assignment Procedure must be provided to dynamically assignmemory sections to the Memory Manager. The Memory Assignment Procedure is calledby the Memory Manager when AMX is started, prior to execution of any of your...
Page 142 - The Memory Assignment Procedure can be coded in assembler as a
134 K ADAK AMX Memory Manager The Memory Assignment Procedure can be coded in assembler as a FAR procedure. USER_CODE SEGMENT BYTE 'CODE'; ASSUME CS:USER_CODE ; PUBLIC MEMPROC ;PARAM STRUC ;Define parameters on stack DW ? ;Save BP DD ? ;Return address MEMSIZEP DD ? ;A(storage for section size in byt...
Page 143 - AMX Circular List Manager; Add to bottom of circular list; Examples
AMX Circular List Manager K ADAK 135 11. AMX Circular List Manager 11.1 Circular Lists The AMX Circular List Manager provides a general circular list facility for use byapplication program modules. Circular lists must be located in alterable memory (RAM). A circular list is a data structure used by ...
Page 144 - Circular List Use; The RAM storage area must be 16-bit aligned and provide
136 K ADAK AMX Circular List Manager 11.2 Circular List Use A circular list is created by an application with a call to procedure ajrstl . The caller must provide three parameters: the number of slots in the list, the size of each slot (1, 2 or4 bytes) and a pointer to RAM storage for the circular l...
Page 145 - Circular List Structure; is
AMX Circular List Manager K ADAK 137 11.3 Circular List Structure Circular lists are application data structures which are only accessible by calls to theAMX Circular List Manager. The internal structure of the list is private to the CircularList Manager. Lists can be created dynamically or statical...
Page 146 - The same lists can be coded in assembly language as follows:
138 K ADAK AMX Circular List Manager The same lists can be coded in assembly language as follows: USER_DATA SEGMENT WORD 'DATA';; Circular Lists must be in program data;NSLOT EQU 64 ; EVEN ;Force word alignment BYTELIST LABEL WORD DW 4 DUP(?) ;Header DB NSLOT DUP(?) ;Slots ; EVEN ;Force word alignme...
Page 147 - AMX Linked List Manager
AMX Linked List Manager K ADAK 139 12. AMX Linked List Manager 12.1 Introduction The Linked List Manager provides a general set of fast linked list services suitable foruse in real-time systems. The Linked List Manager removes the tedium and potential forserious error inherent in many applications i...
Page 148 - An
140 K ADAK AMX Linked List Manager 12.2 Linked Lists Terminology A list header is a structure provided by the application to be used to anchor a list. The list header is used to identify a list. The content of the list header is private to the LinkedList Manager. An object is an application data str...
Page 150 - Linked List Use; An empty list is created by calling procedure; with a pointer to the list header; The position of an object in a keyed list can be altered by calling; with a new key; and re-inserting with
142 K ADAK AMX Linked List Manager 12.3 Linked List Use A list consists of a list header and objects linked to the list header by list nodes (or keynodes). Storage for the list header must be provided by you. A pointer to the list headeracts as the list identifier. An empty list is created by callin...
Page 151 - is defined with a key node at offset
AMX Linked List Manager K ADAK 143 The following example coded in C illustrates the use of the Linked List Manager. Anobject called uobject is defined with a key node at offset keynode in the object. An array of ten objects is provided. A keyed list keylist is created and the ten objects are added t...
Page 155 - Insufficient Memory; AMX Breakpoint Manager; . You can define your own negative
Advanced Topics K ADAK 147 13. Advanced Topics 13.1 Fatal Exit There are a number of conditions which, if encountered by AMX, are considered to befatal. Any attempt by AMX to continue execution will lead to unpredictable results atbest. All of these conditions cause AMX to force a branch to its fata...
Page 156 - Fatal Exit Procedure; Your Fatal Exit Procedure can be coded in assembly language as a
148 K ADAK Advanced Topics Fatal Exit Procedure AMX allows you to provide a Fatal Exit Procedure of your own by specifying the nameof your procedure in your System Configuration Module (see Chapter 14.5). Whenever AMX or your application forces a fatal exit, AMX checks to see if you haveprovided a F...
Page 157 - Halt Locations; Entry point; to assist you in your
Advanced Topics K ADAK 149 Your Fatal Exit Procedure can be coded as a Large model C procedure as illustrated inthe following example. #include "amx831ec.h" /* AMX Error Code Definitions */ void cdecl fatalexit(int error) /* Fatal exit error code */ { :Inhibit all interrupt sourcesProvide an...
Page 158 - User Error Procedure
150 K ADAK Advanced Topics 13.2 User Error Procedure Most AMX procedures return error status to the caller. The error status is a signedinteger. AEREROK = 0 No error AERxxx > 0 Warning: possible fault AERxxx < 0 Error: may be unrecoverable The defined error codes are summarized in Appendix B. ...
Page 160 - Task Scheduling Hooks
152 K ADAK Advanced Topics 13.3 Task Scheduling Hooks AMX does not provide direct support for specific hardware extensions such as a mathcoprocessor or a memory management unit. Instead, AMX allows a set of applicationprocedures to be connected to its Task Scheduler. These procedures can save and re...
Page 161 - Abnormal Task Termination; Stop a Task
Advanced Topics K ADAK 153 13.4 Abnormal Task Termination A task is a procedure which is called by the AMX Task Scheduler. The task endsexecution normally by returning to AMX. AMX provides procedure ajend which can be used by a task to end execution and return to AMX under circumstances in which its...
Page 162 - Kill a Task
154 K ADAK Advanced Topics Kill a Task A task can be killed. The task is first stopped as just described. All outstanding requeststo the task for its execution are purged. The effect is the same as if the task continued tomake calls to ajend to end its operation until finally there were no task exec...
Page 163 - description in Chapter 16); to end task execution.
Advanced Topics K ADAK 155 A Task Termination Procedure can be coded as a Large or Medium model C procedure asillustrated in the following example. The procedure receives an integer reason codeindicating whether the task is being stopped, killed or deleted. The mnemonics for thesereason codes are pr...
Page 165 - Termination Processing; Termination Warning
Advanced Topics K ADAK 157 Termination Processing AMX will only stop or kill a task which is running, waiting or ready to execute. A taskcan be deleted if it is in any of these states or idle. Occasionally, a request to terminate atask will occur while that task is performing some operation which AM...
Page 167 - Breakpoint Manager
Advanced Topics K ADAK 159 13.6 Breakpoint Manager The AMX Breakpoint Manager can be used to improve the operation of the debugger thatyou use to test your AMX system. Your use of the Breakpoint Manager is optional; use itonly if it augments your debugger as described below. If you enjoy the use of ...
Page 168 - Using the Breakpoint Manager; in your link specification prior to the AMX Library; Breakpoint Exit Detection; and the breakpoint exit delay to
160 K ADAK Advanced Topics Using the Breakpoint Manager The Breakpoint Manager is included in your application only if it is enabled in your UserParameter File. Use the AMX Configuration Builder to edit your User Parameter File(see Chapter 14.13). Enable the breakpoint support option in the Breakpoi...
Page 169 - Interrupt Masking
Advanced Topics K ADAK 161 Interrupt Masking The Breakpoint Manager must be tailored to inhibit interrupts at breakpoints. Whichinterrupts are to be inhibited and how this is done is both system and hardwaredependent. When you include the Breakpoint Manager in your AMX system, module AA831BKA.OBJ is...
Page 170 - NMI Breakpoints; The version of module; in the file to be non; Compatible Debuggers
162 K ADAK Advanced Topics NMI Breakpoints Some hardware debuggers may use the non-maskable interrupt (NMI) to generatebreakpoints. The Breakpoint Manager can be tailored to support such debuggers byenabling its NMI handler. When an NMI interrupt is detected, the Breakpoint Manager calls the NMI han...
Page 172 - System Configuration Builder
164 K ADAK AMX System Configuration 14.2 System Configuration Builder The AMX Configuration Builder is a software generation tool which can be used tocreate your AMX System Configuration Module. The Builder helps to reduce totalsystem implementation time by eliminating the manual generation process ...
Page 173 - Figure 14.2-1 AMX Configuration Building Process
AMX System Configuration K ADAK rev8 165 System DocumentationTemplate File AM831CG.CTD System ConfigurationTemplate File AM831CG.CT User Parameter File SYSCFG.UP Configuration Manager Enter/Edit/View AMX System Parameters Configuration Generator SYSCFG.ASM SYSCFG.TXT SystemConfigurationModuleFile Fi...
Page 174 - Using the Builder; Starting the Builder
166 K ADAK AMX System Configuration 14.3 Using the Builder Starting the Builder The AMX Configuration Builder will operate on a PC or compatible running theMicrosoft ® Windows ® operating system. The Builder is delivered with the following files. File Purpose AM831CM .EXE AMX Configuration Manager (...
Page 175 - Screen Layout; Figure 14.3-1 Configuration Manager Screen Layout
AMX System Configuration K ADAK 167 Screen Layout Figure 14.3-1 illustrates the Configuration Manager's screen layout. The title baridentifies the User Parameter File being created or edited. Below the title bar is the menubar from which the operations you wish the Manager to perform can be selected...
Page 176 - Menus; menu; menu
168 rev9 K ADAK AMX System Configuration Menus All commands to the Configuration Manager are available as items on the menus presenton the menu bar. The File menu provides the conventional New , Open , Save and Save As... commands for creating and editing your User Parameter File. It also provides t...
Page 177 - Add, Edit and Delete AMX Objects
AMX System Configuration K ADAK 169 If you have modified some of the fields on a property page and then decide that thesemodified values are not correct, use the Undo Page command on the Edit menu or Toolbar to force the Configuration Manager to restore the content of all fields on the page to theva...
Page 178 - System Parameter Definition; AMX Message Envelopes
170 K ADAK AMX System Configuration 14.4 System Parameter Definition The System Parameter window allows you to define the general operating parameters ofyour AMX system. The layout of the window is shown in Figure 14.3-1 in Chapter 14.3. Kernel Options AMX Message Envelopes AMX passes a message to a...
Page 179 - AMX Interrupt Stack Size; is the sum of the worst case stack use by each of the nested; AMX and Managers in Separate ROM; If you are using the Paradigm toolset (see AMX 86 Tool Guide, toolset
AMX System Configuration K ADAK 171 AMX Interrupt Stack Size The AMX Interrupt Supervisor requires a minimum Interrupt Stack size of 128 bytes.The stack size must be a multiple of 4 bytes. In addition to this minimum, you must allocate sufficient stack to satisfy the applicationISP with the greatest...
Page 180 - Timing Options; Hardware Clock Frequency; This field is ignored if the; check box is unchecked.
172 K ADAK AMX System Configuration Timing Options Hardware Clock Frequency This parameter defines the frequency of the AMX hardware clock in hertz. It is used byAMX to convert milliseconds to equivalent AMX system ticks. If your hardware clockfrequency is not integral, round the clock frequency to ...
Page 181 - AMX Object Allocation; Maximum Number of Tasks; have to account for the AMX Kernel Task.; Maximum Number of Timers
AMX System Configuration K ADAK 173 14.5 AMX Object Allocation The AMX Object Allocation window allows you to define the number of private AMXobjects required for each of the optional AMX managers to be included in your system.The layout of the window is shown below. Maximum Number of Tasks This par...
Page 182 - Maximum Number of Semaphores; Maximum Number of Event Groups; Maximum Number of Message Exchanges; Maximum Number of Buffer Pools
174 K ADAK AMX System Configuration Maximum Number of Semaphores This parameter defines the maximum number of resource and counting semaphoreswhich your system can support concurrently. If you do not require any semaphores, setthis parameter to 0. Otherwise, the parameter should be set to the number...
Page 183 - Memory Assignment Procedure Name
AMX System Configuration K ADAK 175 Memory Assignment Procedure Name If you use the AMX Memory Manager, you must provide a Memory AssignmentProcedure to assign memory sections to its memory pool for allocation to tasks (seeChapter 10.6). This parameter specifies the name of that procedure. If you ar...
Page 185 - Add, Edit and Delete Restart and Exit Procedures
AMX System Configuration K ADAK 177 Add, Edit and Delete Restart and Exit Procedures To add a new procedure, click on the Add button below the list. A new procedure named ---New--- will appear at the bottom of the list. Click on the name ---New--- and it will be opened ready for editing. Enter the n...
Page 186 - Task Definition; . The layout of the window is
178 K ADAK AMX System Configuration 14.7 Task Definition The Task Definition window allows you to define the tasks to be automatically created byAMX at system startup. You do not have to predefine all of your tasks in this manner;you may also create tasks dynamically using ajtkcre . The layout of th...
Page 188 - Medium Model; so that; when the task; Queue Depths
180 K ADAK AMX System Configuration Medium Model Tasks can be either Large or Medium. If your task is Medium model, check this box.Otherwise, leave this box unchecked. If you declare the task to be Medium, the Builder will allocate the task's stack in asegment which is part of group DGROUP so that D...
Page 189 - Timer Definition; . Note that AMX does; to
AMX System Configuration K ADAK 181 14.8 Timer Definition The Timer Definition window allows you to define the timers to be automatically createdby AMX at system startup. You do not have to predefine all of your timers in thismanner; you may also create timers dynamically using ajtmcre . Note that A...
Page 190 - Tag; Timer Procedure Name; Period
182 K ADAK AMX System Configuration Tag Each timer can have a unique 4-character timer tag. This parameter defines that tag.Although AMX does not restrict the content of the timer tag field, the ConfigurationManager only supports 4 ASCII characters as a tag. Id Variable This parameter defines the na...
Page 191 - Semaphore Definition; . The layout of the window is shown below.
AMX System Configuration K ADAK 183 14.9 Semaphore Definition The Semaphore Definition window allows you to define the semaphores to beautomatically created by AMX at system startup. You do not have to predefine all ofyour semaphores in this manner; you may also dynamically create resource semaphore...
Page 192 - This parameter defines the name of a public variable of type; in the System; Type; This option field defines the type of semaphore to be created,; initial value field is ignored for resource semaphores.; Initial Value
184 K ADAK AMX System Configuration Tag Each semaphore can have a unique 4-character semaphore tag. This parameter definesthat tag. Although AMX does not restrict the content of the semaphore tag field, theConfiguration Manager only supports 4 ASCII characters as a tag. Id Variable This parameter de...
Page 193 - Event Group Definition
AMX System Configuration K ADAK 185 14.10 Event Group Definition The Event Group Definition window allows you to define the event groups to beautomatically created by AMX at system startup. You do not have to predefine all ofyour event groups in this manner; you may also create event groups dynamica...
Page 195 - Message Exchange Definition
AMX System Configuration K ADAK 187 14.11 Message Exchange Definition The Message Exchange Definition window allows you to define the message exchangesto be automatically created by AMX at system startup. You do not have to predefine allof your message exchanges in this manner; you may also create m...
Page 196 - Message Queue Depths
188 K ADAK AMX System Configuration Tag Each message exchange can have a unique 4-character message exchange tag. Thisparameter defines that tag. Although AMX does not restrict the content of the messageexchange tag field, the Configuration Manager only supports 4 ASCII characters as a tag. Id Varia...
Page 197 - Buffer Pool Definition
AMX System Configuration K ADAK 189 14.12 Buffer Pool Definition The Buffer Pool Definition window allows you to define the buffer pools to beautomatically created by AMX at system startup. You do not have to predefine all ofyour buffer pools in this manner; you may also create buffer pools dynamica...
Page 198 - Buffer Size
190 K ADAK AMX System Configuration Tag Each buffer pool can have a unique 4-character buffer pool tag. This parameter definesthat tag. Although AMX does not restrict the content of the buffer pool tag field, theConfiguration Manager only supports 4 ASCII characters as a tag. Id Variable This parame...
Page 199 - Breakpoint Manager Definition; Include Breakpoint Manager
AMX System Configuration K ADAK 191 14.13 Breakpoint Manager Definition The AMX Breakpoint Manager can be used to improve the operation of your debugger inthe AMX multitasking environment. Your use of the Breakpoint Manager is optional.The layout of the window is shown below. Include Breakpoint Mana...
Page 202 - Summary of Services; System Control Kernel Services
194 K ADAK AMX Service Procedures 15.2 Summary of Services AMX provides a wide variety of services from which the real-time system designer canchoose. Many of the services are optional and, if not used, will not even be present inyour AMX system. The AMX managers are all optional. All of AMX and its...
Page 203 - Task Control
AMX Service Procedures K ADAK 195 Task Control ajend AAEND End task execution ajgmsg AAGMSG Get the highest priority message availableOptionally get a message of a specific priority ajresum AARESUM Resume a suspended task ajsend AASEND Start a task by sending it a message at one of 4 priorities ajse...
Page 204 - Timing Control
196 K ADAK AMX Service Procedures Timing Control ajclk AACLK AMX Clock Handler ajtick AATICK Read elapsed system ticks ajtmcnv AATMCNV Convert milliseconds to system ticks ajtmcre AATMCRE Create an interval timer ajtmdel AATMDEL Delete an interval timer ajtmrd AATMRD Read an interval timer ajtmtag A...
Page 205 - Message Exchange Manager
AMX Service Procedures K ADAK 197 Message Exchange Manager ajmxcre AAMXCRE Create a message exchange ajmxdel AAMXDEL Delete a message exchange ajmxget AAMXGET Get a message from a message exchange (no wait) ajmxsnd AAMXSND Send message to a message exchange ajmxsndp ajmxtag AAMXTAG Find exchange id ...
Page 207 - Processor and C Interface Procedures
AMX Service Procedures K ADAK 199 Processor and C Interface Procedures In addition to the services provided by AMX and its managers, the AMX Libraryincludes several C procedures of a general nature which simplify applicationprogramming in real-time systems on your target processor. ajcfjlong Long ju...
Page 208 - AMX 86 PC Supervisor Service Procedures
200 K ADAK AMX Service Procedures AMX 86 PC Supervisor Service Procedures In addition to the services provided by AMX and its managers, the AMX 86 PCSupervisor Library includes several C procedures which are of use only if the AMX 86PC Supervisor is used by your application. These procedures are doc...
Page 209 - Purpose; Setup
AMX 86 Procedures K ADAK 201 16. AMX 86 Procedures 16.1 Introduction A description of every AMX Library procedure is provided in this chapter. Thedescriptions are ordered alphabetically for easy reference. Italics are used to distinguish programming examples. Procedure names and variable names which...
Page 211 - Assembly Language Programming
AMX 86 Procedures K ADAK 203 Assembly Language Programming If you are programming in assembly language, refer to Appendix E for a description ofthe AMX assembly language calling conventions. The appendix includes a summary ofthe input and output register specifications for every AMX procedure. Exper...
Page 213 - ajabl; is a pointer to a circular list (see; is the 1, 2 or 4 byte item to be added to the list.
AMX 86 Procedures K ADAK 205 ajabl ajabl Purpose Add to Bottom of Circular List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup char item; /* one byte item */ int status; .. status = ajabl(&list, item);AX ES:BX CL,CX or DX:CX Where &list is a pointer to a ci...
Page 214 - ajatl
206 K ADAK AMX 86 Procedures ajatl ajatl Purpose Add to Top of Circular List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup char item; /* one byte item */ int status; .. status = ajatl(&list, item);AX ES:BX CL,CX or DX:CX Where &list is a pointer to a circu...
Page 216 - Where
208 K ADAK AMX 86 Procedures ajbcre ajbcre Purpose Create a Buffer Pool Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. AMXID poolid; struct amxbps pooldef;int status; .. status = ajbcre(&pooldef, &poolid);AX ES:BX DX= Where ...
Page 217 - Results; Call successful; See Also
AMX 86 Procedures K ADAK 209 Results Interrupts are disabled and then restored to their state at the time of thecall. Status is returned. AEROK = Call successful AERNFP = No free buffer pool AERNBF = No buffers defined in your pool definition AERBTS = Buffer size defined in your pool definition is t...
Page 218 - is the pool id of the buffer pool to be deleted.
210 K ADAK AMX 86 Procedures ajbdel ajbdel Purpose Delete a Buffer Pool Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID poolid; int status; .. status = ajbdel(poolid);AX DX Where poolid is the pool id of the buffer pool to be deleted. Results Interrupts are di...
Page 219 - is a pointer to a buffer obtained by an
AMX 86 Procedures K ADAK 211 ajbfre ajbfre Purpose Free a Buffer Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup char *buffp; int status; .. status = ajbfre(buffp);AX ES:BX Where buffp is a pointer to a buffer obtained by an ajbget call. Results Interrupts are disab...
Page 222 - ajbia
214 K ADAK AMX 86 Procedures ajbia ajbia Purpose Initialize (Reset) All Buffer Pools Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup int status; .. status = ajbia();AX Results Interrupts are disabled and then restored to their state at the time of thecall. Status is...
Page 223 - ajbip; is the pool id of the buffer pool to be initialized.
AMX 86 Procedures K ADAK 215 ajbip ajbip Purpose Initialize (Reset) One Buffer Pool Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID poolid; int status; .. status = ajbip(poolid);AX DX Where poolid is the pool id of the buffer pool to be initialized. Results In...
Page 225 - ajcfjlong
AMX 86 Procedures K ADAK 217 ajcfjlong ajcfjlong ajcfjset ajcfjset Purpose ajcfjset Sets a Mark for a Long Jumpajcfjlong Long Jumps to that Mark These procedures are provided for AMX portability. They are notreplacements for C library procedures longjmp or setjmp although they function in a similar ...
Page 228 - Interrupts must be disabled.; Interrupts must be disabled upon entry to
220 K ADAK AMX 86 Procedures ajclk ajclk Purpose AMX Clock Handler Used by o Task n ISP o Timer Procedure o Restart Procedure o Exit Procedure Setup Interrupts must be disabled. ajclk(); Results Interrupts may be enabled and/or disabled and will then be restored totheir state at the time of the call...
Page 229 - ajdi
AMX 86 Procedures K ADAK 221 ajdi ajdi ajei ajei Purpose Disable or Enable Interrupts Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup ajdi();ajei(); Results Interrupts are disabled by ajdi() or enabled by ajei() . The interrupt enable flag ( IF ) in the processor st...
Page 230 - There is no return from; can only be used to terminate the task which is making the call.
222 K ADAK AMX 86 Procedures ajend ajend Purpose End Execution of a Task Used by n Task o ISP o Timer Procedure o Restart Procedure o Exit Procedure Setup ajend(); Results There is no return from ajend . If any task is waiting for this task to finish processing its message, AMXwill automatically cal...
Page 234 - ajevdel; is the group id of an event group acquired with a call to
226 K ADAK AMX 86 Procedures ajevdel ajevdel Purpose Delete an Event Group Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID group; int status; .. status = ajevdel(group);AX BX Where group is the group id of an event group acquired with a call to ajevcre . Resul...
Page 235 - ajevnt
AMX 86 Procedures K ADAK 227 ajevnt ajevnt Purpose Get the Saved Event Flags Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup unsigned int value; .. value = ajevnt();AX Where value is the state of the 16 event flags at the time the calling task most recently complete...
Page 236 - ajevrd
228 K ADAK AMX 86 Procedures ajevrd ajevrd Purpose Read the Current Event States in an Event Group Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID group; unsigned int value;int status; .. status = ajevrd(group, &value);AX BX CX= Where group is the group id...
Page 238 - ajevtag
230 K ADAK AMX 86 Procedures ajevtag ajevtag Purpose Find an Event Group Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID group; char tag[4]; int status; .. status = ajevtag(&group, tag);AX BX= [DX:CX] see note Where &group is a pointer to storage for t...
Page 239 - ajevwat
AMX 86 Procedures K ADAK 231 ajevwat ajevwat Purpose Wait for Event(s) in an Event Group Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID group; unsigned int mask;unsigned int value;int match; long timeout; int status; .. status = ajevwat(group, mask, value, ma...
Page 242 - is an error code which will be passed to your Fatal Exit Procedure
234 K ADAK AMX 86 Procedures ajfatl ajfatl Purpose Fatal Exit from AMX Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup int errcode; .. ajfatl(errcode); CX Where errcode is an error code which will be passed to your Fatal Exit Procedure if one was provided in your Us...
Page 243 - ajflagwr
AMX 86 Procedures K ADAK 235 ajflagrd, ajflagrddi ajflagrd, ajflagrddi ajflagwr ajflagwr Purpose Read Processor FlagsRead Processor Flags and Disable InterruptsWrite Processor Flags Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned int flags; .. flags = ajfla...
Page 244 - ajgmsg
236 K ADAK AMX 86 Procedures ajgmsg ajgmsg Purpose Get Message from Task Mailbox Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup int priority; char msg[AMXMSZ]; int status; .. status = ajgmsg(priority, msg);AX CX ES:BX Where priority is the priority of the task mail...
Page 245 - ajgofs; Interrupts are untouched.; pointer; is returned in
AMX 86 Procedures K ADAK 237 ajgofs ajgofs Purpose Get Pointer Offset Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned int ofs;char FAR *pntr; .. ofs = ajgofs(pntr); Results Interrupts are untouched. The 16-bit unsigned integer value of the offset part of th...
Page 246 - ajgseg; pointer variable
238 K ADAK AMX 86 Procedures ajgseg ajgseg Purpose Get Pointer Segment Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned short int seg;char FAR *pntr; .. seg = ajgseg(pntr); Results Interrupts are untouched. The 16-bit unsigned integer value of the segment se...
Page 247 - ajgsreg; is a pointer to storage to receive the current contents of the; is defined in header
AMX 86 Procedures K ADAK 239 ajgsreg ajgsreg Purpose Get Segment Registers Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxsregs sregarray; .. ajgsreg(&sregarray); Where &sregarray is a pointer to storage to receive...
Page 249 - ajinb; is the data byte read.
AMX 86 Procedures K ADAK 241 ajinb ajinb ajinw ajinw Purpose Read an 8-Bit Input Port (Byte)Read a 16-Bit Input Port (Word) Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup int portno; char portbyte; short int portword; .. portbyte = ajinb(portno); portword = ajinw(p...
Page 250 - Interrupts are disabled.; Interrupts are disabled.; Upon entry to; , the stack must be as it was upon return from
242 K ADAK AMX 86 Procedures ajint ajint ajinx ajinx Purpose Begin Interrupt Service Used by o Task n ISP o Timer Procedure o Restart Procedure o Exit Procedure Setup ajint(); Results Interrupts are disabled. The AMX Interrupt Supervisor saves all registers on the caller's stack. If atask has just b...
Page 252 - ajitrp
244 K ADAK AMX 86 Procedures ajitrp ajitrp Purpose Install a Task Trap Handler Install a task trap handler to service divide error, overflow or bound checkerror traps. Used by n Task o ISP o Timer Procedure o Restart Procedure o Exit Procedure Setup int inttype; void handler(); int status; .. status...
Page 253 - ajivtr; is a pointer to storage for a copy of the function pointer from
AMX 86 Procedures K ADAK 245 ajivtr ajivtr Purpose Read an Interrupt Vector Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup int inttype; void (*oldproc)(); int status; .. status = ajivtr(inttype, &oldproc);AX DX ES:BX Where inttype is the 8086 interrupt type (0-...
Page 254 - is a pointer to the new interrupt handler.
246 K ADAK AMX 86 Procedures ajivtw ajivtw Purpose Write an Interrupt Vector Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup int inttype; void newproc(); int status; .. status = ajivtw(inttype, newproc);AX DX ES:BX Where inttype is the 8086 interrupt type (0-255). n...
Page 255 - ajivtx
AMX 86 Procedures K ADAK 247 ajivtx ajivtx Purpose Exchange an Interrupt Vector Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup int inttype; void (*oldproc)(); void newproc(); int status; .. status = ajivtx(inttype, newproc, &oldproc);AX DX ES:BX DS:DI Where int...
Page 256 - is a pointer to the list header.; is the node offset (in bytes) at which the list node is located in
248 K ADAK AMX 86 Procedures ajlcre ajlcre Purpose Create an Empty List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;int offset; .. ajlcre(&list, offset); DS:SI CX Where &list is a pointer to the list he...
Page 257 - ajlhead; = pointer to the first object on the list.; if the list is empty.
AMX 86 Procedures K ADAK 249 ajlhead ajlhead Purpose Find First Object on List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object; .. object = ajlhead(&list);ES:BX DS:SI Where &list is a ...
Page 258 - ajlinsc; is a pointer to the new object to be inserted before the object; is a pointer to a particular object on the list.
250 K ADAK AMX 86 Procedures ajlinsc ajlinsc Purpose Insert Object before Current Object on List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *newobj, *curobj; .. ajlinsc(&list, newobj, curobj)...
Page 259 - ajlinsh; is a pointer to the object to be inserted as the new head of the list.
AMX 86 Procedures K ADAK 251 ajlinsh ajlinsh Purpose Insert Object at Head of List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object; .. ajlinsh(&list, object); DS:SI ES:BX Where &list i...
Page 260 - is a pointer to the object to be inserted into the list.
252 K ADAK AMX 86 Procedures ajlinsk ajlinsk Purpose Insert Object into Keyed List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object;unsigned int key; .. ajlinsk(&list, object, key); DS:SI E...
Page 261 - ajlinst; is a pointer to the object to be inserted as the new tail of the list.
AMX 86 Procedures K ADAK 253 ajlinst ajlinst Purpose Insert Object at Tail of List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object; .. ajlinst(&list, object); DS:SI ES:BX Where &list i...
Page 262 - ajlmerg
254 K ADAK AMX 86 Procedures ajlmerg ajlmerg Purpose Merge Two Lists Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs destlist, srclist;struct appobj *destobj, *srcobj; .. ajlmerg(&destlist, &srclist, destobj, sr...
Page 263 - Assembly language call is:; Restrictions; You must not merge two lists if either of the lists is a keyed list.
AMX 86 Procedures K ADAK 255 Note Assembly language call is: PUSH <segment srcobj> PUSH <offset srcobj> PUSH <segment destobj> PUSH <offset destobj> PUSH <segment scrlist> PUSH <offset scrlist> PUSH <segment destlist> PUSH <offset destlist> CALL AALMER...
Page 264 - ajlnext
256 K ADAK AMX 86 Procedures ajlnext ajlnext Purpose Find Next Object on List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx83lsd.h" .. struct amxlhs list;struct appobj *object, *curobj; .. object = ajlnext(&list, curobj);ES:BX DS:SI ES:BX...
Page 265 - is a pointer to the object on the list which is to be moved within; is the value of the new key for
AMX 86 Procedures K ADAK 257 ajlordk ajlordk Purpose Reorder an Object in a Keyed List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object;unsigned int key; .. ajlordk(&list, object, key); DS:...
Page 266 - ajlprev
258 K ADAK AMX 86 Procedures ajlprev ajlprev Purpose Find Previous Object on List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object, *curobj; .. object = ajlprev(&list, curobj);ES:BX DS:SI E...
Page 267 - is a pointer to the object to be removed from the list.
AMX 86 Procedures K ADAK 259 ajlrmvc ajlrmvc Purpose Remove Object from List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object; .. ajlrmvc(&list, object); DS:SI ES:BX Where &list is a po...
Page 268 - ajlrmvh; = pointer to the object removed from the head of the list.; if the list was empty.
260 K ADAK AMX 86 Procedures ajlrmvh ajlrmvh Purpose Remove Object from Head of List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object; .. object = ajlrmvh(&list);ES:BX DS:SI Where &list...
Page 269 - ajlrmvt; = pointer to the object removed from the tail of the list.
AMX 86 Procedures K ADAK 261 ajlrmvt ajlrmvt Purpose Remove Object from Tail of List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object; .. object = ajlrmvt(&list);ES:BX DS:SI Where &list...
Page 270 - ajltail; = pointer to the last object on the list.
262 K ADAK AMX 86 Procedures ajltail ajltail Purpose Find Last Object on List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxlhs list;struct appobj *object; .. object = ajltail(&list);ES:BX DS:SI Where &list is a p...
Page 272 - is a pointer to a memory block allocated by
264 K ADAK AMX 86 Procedures ajmfre ajmfre Purpose Free Previously Allocated Block Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup char *blockp; int status; .. status = ajmfre(blockp);AX ES:BX Where blockp is a pointer to a memory block allocated by ajmget or ajmgeh...
Page 273 - ajmgeh
AMX 86 Procedures K ADAK 265 ajmgeh ajmgeh Purpose Get a Memory Block Using a Memory Handle Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup long size; char *blockp; long memsize; char *handle; int status; .. status = ajmgeh(size, &blockp, &memsize, handle);A...
Page 277 - ajmodl; is set to the base segment of group; This procedure is provided for use with mixed memory models.
AMX 86 Procedures K ADAK 269 ajmodl ajmodl Purpose Get the DGROUP Segment Value Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup ajmodl(); Results Interrupts are untouched. The data segment register DS is set to the base segment of group DGROUP . This procedure is pr...
Page 278 - ajmset
270 K ADAK AMX 86 Procedures ajmset ajmset Purpose Set (Fill) Memory Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup char *mempntr; long memsize; unsigned short int pattern;int status; .. status = ajmset(mempntr, memsize, pattern);AX ES:BX DX:CX SI Where mempntr is ...
Page 280 - is the exchange id of the message exchange to be deleted.
272 K ADAK AMX 86 Procedures ajmxdel ajmxdel Purpose Delete a Message Exchange Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID exchange; int status; .. status = ajmxdel(exchange);AX BX Where exchange is the exchange id of the message exchange to be deleted. Re...
Page 283 - ajmxsndp
AMX 86 Procedures K ADAK 275 ajmxsndp ajmxsndp Purpose Send Message to a Message Exchange Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID exchange; int priority; int status; int parm1; int parm2; .. status = ajmxsndp(exchange, priority, parm1, parm2...);AX AAM...
Page 284 - ajmxtag
276 K ADAK AMX 86 Procedures ajmxtag ajmxtag Purpose Find a Message Exchange Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID exchange; char tag[4]; int status; .. status = ajmxtag(&exchange, tag);AX BX= [DX:CX] see note Where &exchange is a pointer to ...
Page 286 - ajoutb; is the data byte to be written.; is the data word to be written.
278 K ADAK AMX 86 Procedures ajoutb ajoutb ajoutw ajoutw Purpose Write to an 8-Bit Output Port (Byte)Write to a 16-Bit Output Port (Word) Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup int portno; char portbyte; short int portword; .. ajoutb(portno, portbyte);ajout...
Page 287 - ajproc
AMX 86 Procedures K ADAK 279 ajproc ajproc ajprocq ajprocq Purpose Call Software Procedure You can use this procedure to call any software procedure which, becauseof register setup requirements, cannot otherwise be called from C. Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Proc...
Page 289 - Must follow every call to; is called, task switching
AMX 86 Procedures K ADAK 281 ajprvl ajprvl Purpose Lower Task Privilege Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup ajprvl(); Results Interrupts are disabled and then restored to their state at the time of thecall. Restrictions Must follow every call to ajprvr ....
Page 290 - Must be followed by a call to; as soon as possible to lower the; Once; has been called, the task must not issue any AMX calls
282 K ADAK AMX 86 Procedures ajprvr ajprvr Purpose Raise Task Privilege Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup ajprvr(); Results Interrupts are disabled and then restored to their state at the time of thecall. Restrictions Must be followed by a call to ajpr...
Page 291 - ajrbl
AMX 86 Procedures K ADAK 283 ajrbl ajrbl Purpose Remove from Bottom of Circular List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup char item; /* one byte item */ int status; .. status = ajrbl(&list, &item); AX ES:BX CL=, CX= or DX:CX= Where &list is a ...
Page 292 - ajresum; Resume a task known to be suspended as a result of an; is the task id of the task to be resumed.
284 K ADAK AMX 86 Procedures ajresum ajresum Purpose Resume a Suspended Task Resume a task known to be suspended as a result of an ajsusp call. Used by n Task n ISP n Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID taskid; int status; .. status = ajresum(taskid);AX DX Where taskid i...
Page 293 - is a pointer to storage for use as a circular list.
AMX 86 Procedures K ADAK 285 ajrstl ajrstl Purpose Initialize (Reset) a Circular List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup /* define type of slots */ typedef char SLOT1; /* byte slot */ typedef short int SLOT2; /* word slot */ typedef long SLOT4; /* doubl...
Page 294 - ajrtl
286 K ADAK AMX 86 Procedures ajrtl ajrtl Purpose Remove from Top of Circular List Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup char item; /* one byte item */ int status; .. status = ajrtl(&list, &item);AX BX CL=, CX= or DX:CX= Where &list is a pointer...
Page 296 - ajsendp
288 K ADAK AMX 86 Procedures ajsendp ajsendp Purpose Send a Message to a Task Mailbox To request AMX to send a message to a task at a given priority and tobegin execution of that task as soon as possible. Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID taskid;...
Page 297 - ajsenw
AMX 86 Procedures K ADAK 289 ajsenw ajsenw Purpose Send a Message to a Task Mailbox (Wait for Ack) To request AMX to send a message to a task at a given priority and tobegin execution of that task as soon as possible. The task making therequest is placed into the wait state until either: 1. the call...
Page 299 - ajsenwp
AMX 86 Procedures K ADAK 291 ajsenwp ajsenwp Purpose Send a Message to a Task Mailbox (Wait for Ack) To request AMX to send a message to a task at a given priority and tobegin execution of that task as soon as possible. The task making the request is placed into the wait state until either: 1. the c...
Page 301 - ajsgnl
AMX 86 Procedures K ADAK 293 ajsgnl ajsgnl Purpose Signal a Task Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID taskid; unsigned int tsignals;unsigned long siginfo;int status; .. status = ajsgnl(taskid, tsignals, &siginfo); AX DX BX[14..0] BX:CX= BX[15]=0...
Page 303 - ajsgrd
AMX 86 Procedures K ADAK 295 ajsgrd ajsgrd Purpose Read Pending Task Signals Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup unsigned int tsignals; .. tsignals = ajsgrd();AX Where tsignals is the current state of the calling task's task signals. Results Interrupts a...
Page 304 - ajsgres
296 K ADAK AMX 86 Procedures ajsgres ajsgres Purpose Reset Pending Task Signals Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup unsigned int tsignals; .. ajsgres(tsignals); BX[14..0]BX[15]=0 Where tsignals is a 15-bit mask identifying the task signals to be reset. O...
Page 305 - ajsgwat
AMX 86 Procedures K ADAK 297 ajsgwat ajsgwat Purpose Wait for Task Signal(s) Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup unsigned int tsignals;long timeout; int match; int status; unsigned int sigrecv; .. status = ajsgwat(tsignals, match, timeout, &sigrecv);...
Page 307 - ajsint
AMX 86 Procedures K ADAK 299 ajsint ajsint ajsintq ajsintq Purpose Generate Software Interrupt Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxregs regarray;int inttype; unsigned int regeax: .. regeax = ajsint(inttype, &...
Page 310 - is the semaphore id of a resource or counting semaphore acquired
302 K ADAK AMX 86 Procedures ajsmdel ajsmdel Purpose Delete a Semaphore Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID semid; int status; .. status = ajsmdel(semid);AX BX Where semid is the semaphore id of a resource or counting semaphore acquired by a call t...
Page 311 - ajsmfre; is the semaphore id of a resource semaphore acquired by a call to
AMX 86 Procedures K ADAK 303 ajsmfre ajsmfre Purpose Unconditionally Free a Resource Semaphore Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID semid; int status; .. status = ajsmfre(semid);AX BX Where semid is the semaphore id of a resource semaphore acquired ...
Page 312 - ajsmget; is the semaphore id of a counting semaphore acquired by a call to
304 K ADAK AMX 86 Procedures ajsmget ajsmget Purpose Get Use of a Semaphore (no wait) Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID semid; int status; . . status = ajsmget(semid);AX BX Where semid is the semaphore id of a counting semaphore acquired by a cal...
Page 313 - ajsmrls
AMX 86 Procedures K ADAK 305 ajsmrls ajsmrls Purpose Release a Resource Semaphore Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID semid; int status; .. status = ajsmrls(semid); /* nested release */ AX BX Where semid is the semaphore id of a resource semaphore ...
Page 316 - ajsmsig
308 K ADAK AMX 86 Procedures ajsmsig ajsmsig Purpose Signal a Semaphore Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID semid; int status; .. status = ajsmsig(semid);AX BX Where semid is the semaphore id of a counting semaphore acquired by a call to ajsmcre . ...
Page 318 - ajsmwat
310 K ADAK AMX 86 Procedures ajsmwat ajsmwat Purpose Wait on a Semaphore Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID semid; long timeout; unsigned int priority;int status; .. status = ajsmwat(semid, timeout, priority);AX BX DX:CX DI Where semid is the sema...
Page 319 - ajsofs; is set to the 16-bit
AMX 86 Procedures K ADAK 311 ajsofs ajsofs Purpose Set Pointer Offset Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned int ofs;char FAR *pntr; .. ajsofs(&pntr, ofs); Results Interrupts are untouched. The offset part of the FAR pointer variable pntr is se...
Page 320 - ajsseg; is set to the
312 K ADAK AMX 86 Procedures ajsseg ajsseg Purpose Set Pointer Segment Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned short int seg;char FAR *pntr; .. ajsseg(&pntr, seg); Results Interrupts are untouched. The segment selector part of the FAR pointer va...
Page 322 - ajsusp
314 K ADAK AMX 86 Procedures ajsusp ajsusp Purpose Suspend a Task Used by n Task o ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID taskid; int status; .. status = ajsusp(taskid);AX DX Where taskid is the task id of the task to be suspended. Results Interrupts are disabled and ...
Page 323 - ajtdf
AMX 86 Procedures K ADAK 315 ajtdf ajtdf Purpose Format Time and Date as an ASCII String Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxtds tdbuf;char ascii[26]; int format; int n; .. n = ajtdf(&tdbuf, format, ascii);A...
Page 324 - ajtdg; date. The structure; is defined in header file
316 K ADAK AMX 86 Procedures ajtdg ajtdg Purpose Get Current Time and Date Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxtds tdbuf; .. ajtdg(&tdbuf); ES:BX Where &tdbuf is a pointer to the structure which is to re...
Page 325 - is a pointer to the structure which contains the new time and date.
AMX 86 Procedures K ADAK 317 ajtds ajtds Purpose Set the Time and Date Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxtds tdbuf; .. Initialize tdbuf with new time and date. .. ajtds(&tdbuf); ES:BX Where &tdbuf is a...
Page 326 - ajtick; is the current value of the AMX system tick counter.
318 K ADAK AMX 86 Procedures ajtick ajtick Purpose Read System Tick Counter Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned long tickcnt; .. tickcnt = ajtick();DX:AX Results Interrupts are untouched. tickcnt is the current value of the AMX system tick count...
Page 328 - ajtkdel
320 K ADAK AMX 86 Procedures ajtkdel ajtkdel Purpose Delete a Task This procedure removes a task from your AMX system. Its task id will nolonger be valid. Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID taskid; int priority; int status; .. status = ajtkdel(tas...
Page 329 - ajtkid; is the task id of the currently executing task.
AMX 86 Procedures K ADAK 321 ajtkid ajtkid Purpose Get Task Id of Current Task Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID taskid; .. taskid = ajtkid();AX Where taskid is the task id of the currently executing task. Results Interrupts are untouched. See Al...
Page 330 - ajtkill
322 K ADAK AMX 86 Procedures ajtkill ajtkill Purpose Kill a Task This procedure will force a ready, executing or suspended task to end. Allmessages in the task's mailboxes at the time of the kill request will beflushed. All requests for task execution pending at the time of the killrequest will be e...
Page 331 - is the task id of the task whose priority is to be changed.
AMX 86 Procedures K ADAK 323 ajtkpry ajtkpry Purpose Change Task Priority Used by n Task o ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID taskid; int priority; int status; .. status = ajtkpry(taskid, priority);AX DX CX Where taskid is the task id of the task whose priority is...
Page 332 - ajtkstp
324 K ADAK AMX 86 Procedures ajtkstp ajtkstp Purpose Stop Execution of Task This procedure will force a ready, executing or suspended task to end. Used by n Task n ISP n Timer Procedure o Restart Procedure n Exit Procedure Setup AMXID taskid; int status; .. status = ajtkstp(taskid);AX DX Where taski...
Page 333 - ajtksts
AMX 86 Procedures K ADAK 325 ajtksts ajtksts Purpose Get Status of a Task Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxsbs tasksts;AMXID taskid; int status; .. status = ajtksts(taskid, &tasksts);AX DX ES:BX Where tas...
Page 334 - ajtktag
326 K ADAK AMX 86 Procedures ajtktag ajtktag Purpose Find a Task Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup char tag[4]; AMXID taskid; int status; .. status = ajtktag(&taskid, tag);AX DX= [CX:DX] see note Where &taskid is a pointer to storage for the ta...
Page 337 - ajtmcnv
AMX 86 Procedures K ADAK 329 ajtmcnv ajtmcnv Purpose Convert Milliseconds to System Ticks Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned long ms;long ntick; .. ntick = ajtmcnv(ms);DX:CX DX:CX Where ms is the number of milliseconds. ntick is the equivalent ...
Page 339 - ajtmdel; is the timer id identifying the timer to be deleted.
AMX 86 Procedures K ADAK 331 ajtmdel ajtmdel Purpose Delete an Interval Timer Used by n Task o ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID timerid; .. status = ajtmdel(timerid);AX DX Where timerid is the timer id identifying the timer to be deleted. Results Interrupts are ...
Page 340 - ajtmrd
332 K ADAK AMX 86 Procedures ajtmrd ajtmrd Purpose Read the Current Value of an Interval Timer Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID timerid; long tval; .. tval = ajtmrd(timerid);DX:CX DX Where timerid is the timer id identifying the timer whose valu...
Page 341 - ajtmtag
AMX 86 Procedures K ADAK 333 ajtmtag ajtmtag Purpose Find an Interval Timer Used by n Task o ISP o Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID timerid; char tag[4]; int status; .. status = ajtmtag(&timerid, tag);AX DX= [DX:CX] see note Where &timerid is a pointer to stor...
Page 343 - To request AMX to start a task without sending a message to the task.; is the task id of the task to be triggered.
AMX 86 Procedures K ADAK 335 ajtrig ajtrig Purpose Trigger a Task To request AMX to start a task without sending a message to the task. Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID taskid; int status; .. status = ajtrig(taskid);AX DX Where taskid is the tas...
Page 344 - ajtslv
336 K ADAK AMX 86 Procedures ajtslv ajtslv Purpose Change a Task's Time Slice Interval Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup AMXID taskid; unsigned int tslice;int status; .. status = ajtslv(taskid, tslice);AX DX CX Where taskid is the task id of the task w...
Page 346 - ajupt
338 K ADAK AMX 86 Procedures ajupt ajupt Purpose Fetch Pointer to User Parameter Table Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup #include "amx831sd.h" .. struct amxupts FAR *uptp; /* User Parameter Table pointer */ .. ajupt(&uptp); Where &uptp ...
Page 347 - ajver; is the AMX version number in the hexadecimal format; is the major revision number (; is the minor revision number (
AMX 86 Procedures K ADAK 339 ajver ajver Purpose Get AMX Version Number Used by n Task n ISP n Timer Procedure n Restart Procedure n Exit Procedure Setup unsigned long version; .. version = ajver();DX:AX Where version is the AMX version number in the hexadecimal format 0x0086rrmm where rr is the maj...
Page 349 - ajwakc
AMX 86 Procedures K ADAK 341 ajwakc ajwakc Purpose Wake Calling Task (Acknowledge Receipt of Message) To allow the current task to wake up the task which sent the messagewhich is being processed by the current task. Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup in...
Page 350 - ajwakcs
342 K ADAK AMX 86 Procedures ajwakcs ajwakcs Purpose Wake Calling Task (Acknowledge Receipt of Message with Status) To allow the current task to wake up the task which sent the messagewhich is being processed by the current task and return completion statusto that task. Used by n Task o ISP o Timer ...
Page 352 - ajwapr; This call only affects the calling task.
344 K ADAK AMX 86 Procedures ajwapr ajwapr Purpose Reset a Pending Wake Request This call only affects the calling task. Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup ajwapr(); Results Interrupts are untouched. Note This procedure provides a simplified form of tas...
Page 353 - ajwatm
AMX 86 Procedures K ADAK 345 ajwatm ajwatm Purpose Task Delay or Timed Wait for a Wake Request Used by n Task o ISP o Timer Procedure o Restart Procedure n Exit Procedure Setup long tval; int status; .. status = ajwatm(tval);AX DX:CX Where tval is the required wait interval or delay period measured ...
Page 355 - A. AMX 86 Reserved Words
AMX 86 Reserved Words K ADAK 347 A. AMX 86 Reserved Words ajpppppp AMX C procedure name pppppp AAPPPPPP AMX assembly language procedure name PPPPPP amxttttt AMX C structure name of type ttttt AMXID AMX object identifier (handle) cdecl Procedures use C parameter passing conventions AMssssss Reserved ...
Page 357 - B. AMX 86 Error Codes; Mnemonic
AMX 86 Error Codes K ADAK 349 B. AMX 86 Error Codes AMX error codes are signed integers. Codes less than zero are error codes. Codesgreater than zero are warning codes. To assist you during testing, the hexadecimal valueof the least significant 16-bits of the error code is listed as it might appear ...
Page 359 - AMX 86 Fatal Exit Codes; are
AMX 86 Error Codes K ADAK 351 AMX 86 Fatal Exit Codes Mnemonic Value Value Meaning (dec) (hex) AERFX1 ● 1 0x0001 Not enough memory in AMX Data Segment AERFX2 ● 2 0x0002 Divide, overflow, bound error in ISP AERFX3 ● 3 0x0003 Divide, overflow, bound error occurred:in a Restart Procedure orin a Timer P...
Page 361 - C. Configuration Generator Specifications; Windows; Assembly Language. Some of the language syntax used by Microsoft
Generator Specifications K ADAK 353 C. Configuration Generator Specifications C.1 Introduction If you are not doing your software development on a PC or compatible runningMicrosoft ® Windows ® , then you will be unable to use the interactive Configuration Manager for Windows to create and edit your ...
Page 362 - C.2 User Parameter File Specification; which begin in column one. Each
354 K ADAK Generator Specifications C.2 User Parameter File Specification The User Parameter File is a text file structured as illustrated in Figure C.2-1. The fileconsists of a sequence of keywords of the form ...XXX which begin in column one. Each keyword is followed by one or more parameters whic...
Page 363 - constant definitions
Generator Specifications K ADAK 355 The example in Figure C.2-1 uses symbolic names for all of the parameters followingeach of the keywords. The symbols correspond to the screen fields described in Chapter14. You are referred to that chapter for detailed descriptions of each of the parameters. The o...
Page 364 - tasks
356 K ADAK Generator Specifications Each of your predefined tasks must be defined using keyword ...TDT . The order of these definitions will determine their order of creation by AMX. If you do not wish topredefine any tasks, delete the line with keyword ...TDT. The parameters in each task definition...
Page 365 - semaphores
Generator Specifications K ADAK 357 Each of your predefined semaphores must be defined using the keyword ...SEM . The order of these definitions will determine their order of creation by AMX. If you do notwish to predefine any semaphores, delete the line with keyword ...SEM . The parameters in each ...
Page 366 - message exchanges
358 K ADAK Generator Specifications Each of your predefined message exchanges must be defined using the keyword ...MEX . The order of these definitions will determine their order of creation by AMX. If you donot wish to predefine any message exchanges, delete the line with keyword ...MEX . The param...
Page 367 - C.3 System Configuration Template
Generator Specifications K ADAK 359 C.3 System Configuration Template The System Configuration Template is an assembly language source file which defines aSystem Configuration Module for any system using AMX and its managers. It isrecommended that you list file AM831CG.CT and examine it carefully be...
Page 369 - assembler comment character (
Generator Specifications K ADAK 361 The first statement in this example is a directive defining an incremental variable named &TN . Both its initial value and increment are 1. Note that this directive begins with the assembler comment character ( ; ) and the parameter delimiter character ( ~ in ...
Page 370 - C.4 Porting the Configuration Generator
362 K ADAK Generator Specifications C.4 Porting the Configuration Generator The Configuration Manager uses the Configuration Generator to generate your SystemConfiguration Module. If you are not doing your development on a PC or compatible,you may wish to port the Configuration Generator to your dev...
Page 373 - D. AMX 86 Structure and Constant Definitions; AMX Launch Parameter (see
Structure/Constant Definitions K ADAK 365 D. AMX 86 Structure and Constant Definitions D.1 AMX C Structures and Constants AMX Launch Parameter (see AAENTR ) #define AMLPTMP 1 /* Temporary launch */ /* Default is permanent launch */ #define AMLPVA 2 /* Vector table is alterable */ /* Default is non a...
Page 374 - AMX Task Status Block Structure
366 K ADAK Structure/Constant Definitions AMX Task Status Block Structure struct amxsbs { AMXID amsbtid; /* task id */ char amsbtag1; /* task tag */ char amsbtag2; char amsbtag3; char amsbtag4; unsigned long amsbst; /* task status */ unsigned long amsbsig; /* pending signals */ long amsbtmr; /* task...
Page 375 - AMX Extended Message Parameter Structure; (passed on stack above AMX message when starting a task); AMX Function Codes (field
Structure/Constant Definitions K ADAK 367 AMX Extended Message Parameter Structure (passed on stack above AMX message when starting a task) struct amxmsgxs { AMXID amxmscid; /* calling task's id */ short int amxmsfn; /* AMX function code */ /* (see definitions) */ short int amxmsrsv[4]; /* reserved ...
Page 376 - AMX User Parameter Table Structure
368 K ADAK Structure/Constant Definitions AMX User Parameter Table Structure struct amxupts { void (**ampbrpl)(); /* A(Restart Procedure List) */ void (**ampbepl)(); /* A(Exit Procedure List) */ long ampbcfga; /* Configuration attributes */ short int ampbdgrp; /* user's DGROUP segment selector */ sh...
Page 377 - Configuration Attributes (field
Structure/Constant Definitions K ADAK 369 Configuration Attributes (field AMPBCFGA ) #define AMCAMTK 1 /* Some Medium tasks */ #define AMCAMUP 2 /* Some Medium user procedures */ #define AMCAS24 4 /* Use 24-bit address space */ AMX Time/Date Structure struct amxtds { unsigned char amtdsec; /* second...
Page 378 - AMX List Header Structure (doubly linked lists); AMX List Node Structure
370 K ADAK Structure/Constant Definitions AMX List Header Structure (doubly linked lists) struct amxlhs { struct amxlhs *amlhhead; /* list head */ struct amxlhs *amlhtail; /* list tail */ unsigned int amlhoffs; /* byte offset to object node */ }; AMX List Node Structure struct amxlns { struct amxlns...
Page 379 - AMX Register Array Structure; See Intel 80286 Programmer's Reference Manual; AMX C Root ISP Structure
Structure/Constant Definitions K ADAK 371 AMX Register Array Structure struct amxregs { unsigned short int amxrf; /* Flags (LS byte only) */ unsigned short int amxrax; /* Register AX */ unsigned short int amxrbx; /* Register BX */ unsigned short int amxrcx; /* Register CX */ unsigned short int amxrd...
Page 380 - AMX C Jump Buffer Structure
372 K ADAK Structure/Constant Definitions AMX C Jump Buffer Structure struct ajxjbuf { unsigned short int xjbretadr; /* ofs(return address) */ unsigned short int xjbcs; /* Register CS */ unsigned short int xjbsp; /* Stack pointer offset */ unsigned short int xjbss; /* Stack pointer segment */ unsign...
Page 381 - D.2 AMX Assembler Structures and Constants
Structure/Constant Definitions K ADAK 373 D.2 AMX Assembler Structures and Constants AMX Launch Parameter (see AAENTR ) AMLPTMP EQU 1 ;Temporary launch ; ;Default is permanent launch ;AMLPVA EQU 2 ;Vector table is alterable ; ;Default is non alterable table ;AMLPIE EQU 4 ;Launch with interrupts enab...
Page 389 - E. AMX 86 Assembler Interface; IN
AMX 86 Assembler Interface K ADAK 381 E. AMX 86 Assembler Interface This appendix summarizes the assembly language calling sequences for all AMXprocedures. The procedures are organized in functional groups. Within each group theprocedures are listed alphabetically. All procedures are called as follo...
Page 403 - Numerals
Index K ADAK Index-1 Numerals 24-bit memory addressing 1, 125, 171 A AACLK 73 AAENTR 22AAINT 54, 55, 56, 73AAINX 55, 56, 73 ajabl 135, 205 ajatl 135, 206 ajbau 52, 119, 121, 207 ajbcre 119, 120, 174, 189, 208 ajbdel 119, 121, 210 ajbfre 52, 76, 119, 121, 211 ajbget 52, 76, 119, 121, 212 ajbgsz 119, ...