13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

An ExampleThe following sample, deliberately trivial, illustrates some of the techniquesjust discussed. It consists of a Pascal program that calls two EXTERNALroutines-a procedure and a function. This is how it works:o The Pascal program CALLASM creates a packed array of ten byte-sizedelements, initializing it with the values 0 through 9. It displays the result.o CALLASM then calls the EXTERNAL procedure INCARRAY, a 6502routine, which increases the value of each element by 1. CALLASMdisplays the new result.o CALLASM finally calls the EXTERNAL function TIMES2 ten times. Ateach iteration, TIMES2 doubles the value of one array element andCALLASM displays it.Here is the Pascal source text:PROGRAM CALLASM;TYPE LIST• PACKED ARRAY CB .. 91 OF e .. 255;VAR N : INTEGER;AA : LIST;PROCEDURE INCARRAY CSIZE : INTEGER; VAR DATAEXTERNAL;LIST>;FUNCTION TIMES2 CDATAEXTERNAL;INTEGER>INTEGER;BEGINWRITELN C'lnitial array:'>;FOR N :• 0 TO 9 DOBEGINAACNl :• N;WRITE C' ', AACNl>END;WRITELN C'Array, incremented:'>;INCARRAY c1e, AA>;FOR N :• 0 to 9 DO WRITE C' ', AACNl>;WRITELN ('Incremented array time5 two:'>;FOR N :• H TO 9 DO WRITE C' ', TIMES2 CAACNl>>END.An ExampleIII-151

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!