Oppolzer - Informatik / Stanford Pascal Compiler


Home       Lebenslauf       Schwerpunkte       Kenntnisse       Seminare       Kunden       Projekte       Produkte       Blog       Stanford Pascal       Kontakt

The Stanford Pascal Compiler / Evolution Steps

Back to Compiler main page

New functions MEMSET and MEMCPY

Because of limitations on string lengths (the maximum string constant length is 64, at the moment), I wanted to have a function like MEMSET to be able to initialize a larger string to blanks, for example.

I added a new module PASSTRX (which is supposed to support more string functions in the future, when I want to add a STRING datatype supporting variable length strings). At the moment, the module PASSTRX only contains an external entry $PASSTR, which implements the two new library functions MEMSET and MEMCPY.

The functions are defined much the same as their C counterparts:

At the moment, the functions are implemented using simple Pascal loops; a better solution involving loops of MVCs or MVCL has to be done later.

Here is a short example program which I used to test the new functions:


program TESTMEM ( OUTPUT ) ; var BUFFER : array [ 1 .. 1000 ] of CHAR ; BUFFER2 : array [ 1 .. 200 ] of CHAR ; I : INTEGER ; begin (* HAUPTPROGRAMM *) MEMSET ( ADDR ( BUFFER2 ) , 'A' , 200 ) ; MEMSET ( ADDR ( BUFFER ) , ' ' , 1000 ) ; MEMCPY ( ADDR ( BUFFER ) , ADDR ( BUFFER2 ) , 200 ) ; MEMCPY ( PTRADD ( ADDR ( BUFFER ) , 400 ) , ADDR ( BUFFER2 ) , 200 ) ; for I := 1 to 1000 do begin if I MOD 50 = 1 then WRITE ( I : 6 , ': ' ) ; WRITE ( BUFFER [ I ] ) ; if I MOD 50 = 0 then WRITELN ; end (* for *) end (* HAUPTPROGRAMM *) .

Back to Compiler main page