PL/M-51 COMPILER 04/26/88 PAGE 1 DOS PL/M-51 V1.2 COMPILER INVOKED BY: C:\TOOLS\PLM51.EXE MESSG.P51 DEBUG /***********************************************************************/ /* */ /* MESSG.PLM (with bug in line #28) */ /* PLM program which rotates a character string in a buffer */ /* according to a timer. This program does not contain any */ /* target hardware specific procedures. */ /* */ /* This program is used as the sample program for the ICE-5100 */ /* emulator tutorial. */ /* */ /***********************************************************************/ 1 1 MAIN_DISPLAY: DO; /********************** VARIABLE DECLARATIONS *************************/ 2 1 DECLARE forever LITERALLY 'WHILE 1', false LITERALLY '0', true LITERALLY 'NOT false', /* User variables */ reset_low BYTE CONSTANT (083H), reset_high BYTE CONSTANT (0E8H), disp_buffer (50) BYTE, buff_size BYTE, int_flag BIT, message (*) BYTE CONSTANT (' Intel ICE-5100 Emulators are HOT!'), i BYTE, /* Timer 0 processor specific locations */ tm0_low BYTE at (08AH) REGISTER, tm0_high BYTE at (08CH) REGISTER; /***************** INITIALIZATION PROCEDURE DECLARATION ***************/ 3 2 INIT: PROCEDURE; /* Procedure to initialize timers */ /* Timer 0 related special function registers */ 4 2 DECLARE TMOD BYTE at (089H) REGISTER, ET0 BIT at (0A9H) REGISTER, EA BIT at (0AFH) REGISTER, TR0 BIT at (08CH) REGISTER; /* Beginning of initialization code */ PL/M-51 COMPILER MAIN_DISPLAY 04/26/88 PAGE 2 5 2 buff_size = LAST(message); /* Store the maximum index value */ 6 3 DO i = 0 TO (buff_size); 7 3 disp_buffer(i) = message(i); /* Fill the display buffer */ 8 3 END; 9 2 tm0_low = reset_low; /* Initialize timer 0 */ 10 2 tm0_high = reset_high; 11 2 TMOD = 01H; /* Timer 0 in 16 bit timer mode */ 12 2 ET0 = 1; /* Set timer 0 interrupt enable */ 13 2 EA = 1; /* Set global interrupt enable */ 14 2 TR0 = 1; /* Set timer 0 run control bit */ 15 2 int_flag = false; /* Initialize interrupt flag */ 16 1 END INIT; /**************** TIMER 0 INTERRUPT ROUTINE DECLARATION **************/ 17 2 SERVICE: PROCEDURE INTERRUPT 1; 18 2 int_flag = true; /* Set the interrupt flag */ 19 2 tm0_low = reset_low; /* reset timer 0 */ 20 2 tm0_high = reset_high; 21 2 END; /**************** PROCEDURE TO PRINT THE CHARACTER BUFFER ************/ 22 2 CHAR_DISPLAY: PROCEDURE; /* PROGRAM STUB: DISPLAY CHARACTERS ON TARGET HARDWARE */ 23 2 END; /**************** PROCEDURE TO ROTATE CHARACTER BUFFER ***************/ 24 2 ROTATE: PROCEDURE; 25 2 DECLARE INDEX_PTR BYTE, /* Temporary variables */ TEMP BYTE; /* Begin subroutine processing */ 26 2 INDEX_PTR = 1; 27 2 TEMP = disp_buffer(0); /* Rotate all the characters */ 28 3 DO WHILE (index_ptr < buff_size); /* BUG: should be "<=" */ 29 3 disp_buffer(index_ptr - 1) = disp_buffer(index_ptr); 30 3 INDEX_PTR = INDEX_PTR + 1; 31 3 END; PL/M-51 COMPILER MAIN_DISPLAY 04/26/88 PAGE 3 32 2 disp_buffer(buff_size) = TEMP; /* Put first char at end */ 33 2 PRINT: CALL CHAR_DISPLAY; /* Display the string on the target hardware */ 34 2 int_flag = false; /* Reset the interrupt flag */ 35 2 END; /***********************************************************************/ /**************** BEGIN MAIN PROGRAM ****************/ /***********************************************************************/ 36 1 START: CALL INIT; /* Initialize timer */ 37 2 DO forever; /* Call rotate after the software */ /* interrupt sets the flag */ 38 2 IF (int_flag) THEN 39 2 CALL ROTATE; 40 2 END; 41 1 END MAIN_DISPLAY; WARNINGS: 1 IS THE HIGHEST USED INTERRUPT MODULE INFORMATION: (STATIC+OVERLAYABLE) CODE SIZE = 0085H 133D CONSTANT SIZE = 0025H 37D DIRECT VARIABLE SIZE = 34H+02H 52D+ 2D INDIRECT VARIABLE SIZE = 00H+00H 0D+ 0D BIT SIZE = 01H+00H 1D+ 0D BIT-ADDRESSABLE SIZE = 00H+00H 0D+ 0D AUXILIARY VARIABLE SIZE = 0000H 0D MAXIMUM STACK SIZE = 0011H 17D REGISTER-BANK(S) USED: 0 132 LINES READ 0 PROGRAM ERROR(S) END OF PL/M-51 COMPILATION