Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-01

Re: bitwise operations using AND, OR, XOR, NOT

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernd Oppolzer
Sven Barth wrote 13 lines
> > This depends on the Pascal compiler you use; > the old Wirth "Standard" yields syntax errors, if you use and etc. on types > other than boolean: > We're here on the FPC mailing list, so I personally only care about the capabilities of FPC and that definitely supports bitwise operations (and so do TP and Delphi). Regards, Sven

In the meantime I read some articles about the history of FPC and TP and Delphi and learned that these extensions had been made very early in this history.

While I mentioned some days before that I don't want to compete with FPC with my product, which is an extension of Stanford Pascal aka AAEC Pascal (a Wirth P4 descendant) and which I ported recently to Windows, OS/2 and Linux, I anyway will continue to add features that I consider useful.

So here we go:

1 LINE # D/NEST LVL < STANFORD PASCAL, OPPOLZER VERSION OF 01.2017 > 21:55:58 10.01.2017 PAGE 1
------ ------ --- ---- ---

         1           ) program TESTAND ( OUTPUT ) ;
         2           )
         3           ) var X , Y : INTEGER ;
         4    360D  1)     A , B : BOOLEAN ;
         5    362D  1)
         6    362D  1) begin (* HAUPTPROGRAMM *)
         7           )   X := 0X0E ;
         8      1N  1)   Y := 0X1D ;
         9      1N  1)   A := FALSE ;
        10      1N  1)   B := TRUE ;
        11      1N  1)   WRITELN ( 'x        ' , X ) ;
        12      1N  1)   WRITELN ( 'y        ' , Y ) ;
        13      1N  1)   WRITELN ( 'x and y  ' , X and Y ) ;
        14      1N  1)   WRITELN ( 'x and y  ' , X & Y ) ;
        15      1N  1)   WRITELN ( 'x or y   ' , X or Y ) ;
        16      1N  1)   WRITELN ( 'x or y   ' , X | Y ) ;
        17      1N  1)   WRITELN ( 'x xor y  ' , X XOR Y ) ;
        18      1N  1)   WRITELN ( 'not x    ' , not X ) ;
        19      1N  1)   WRITELN ( 'not y    ' , not Y ) ;
        20      1N  1)   WRITELN ( 'a        ' , a ) ;
        21      1N  1)   WRITELN ( 'b        ' , b ) ;
        22      1N  1)   WRITELN ( 'a and b  ' , A and B ) ;
        23      1N  1)   WRITELN ( 'a and b  ' , A & B ) ;
        24      1N  1)   WRITELN ( 'a or b   ' , A or B ) ;
        25      1N  1)   WRITELN ( 'a or b   ' , A | B ) ;
        26      1N  1)   WRITELN ( 'a xor b  ' , A XOR B ) ;
        27      1N  1)   WRITELN ( 'not a    ' , not A ) ;
        28      1N  1)   WRITELN ( 'not b    ' , not B ) ;
        29      1N  1) end (* HAUPTPROGRAMM *) .
      ****      NO SYNTAX ERROR(S) DETECTED.
      ****      29 LINE(S) READ,    0 PROCEDURE(S) COMPILED,
      ****     232 P_INSTRUCTIONS GENERATED,   0.00 SECONDS IN COMPILATION.

and the outcome:

c:\work\herc\pcode>pcint prr=testand.prr inc=passtrx,paslibx, pas=testand.pas out=testand.prrlis

PCINT (Build 1.0 Jan 10 2017 21:51:56)

x 14
y 29
x and y 12
x and y 12
x or y 31
x or y 31
x xor y 19
not x -15
not y -30
a FALSE
b TRUE
a and b FALSE
a and b FALSE
a or b TRUE
a or b TRUE
a xor b TRUE
not a TRUE
not b FALSE

*** Pascal Programm STP ***

More information: http://bernd-oppolzer.de/job9.htm

Kind regards

Bernd

Reply by email