[fpc-pascal] Bit manipulation

Geno Roupsky groupsky at gmail.com
Mon Feb 20 13:49:27 CET 2006


it is as simple as this:

function isset(value: dword; bit: byte): boolean;
begin
  result := value and (1 shl pred(bit)) <> 0;
end;

2006/2/20, Pianoman <pianoman at centrum.sk>:
>
> Hi, I need to know how can I see whether a certain bit of byte/word/dword
> is
> set:  or not:
> function like this would be appreciated:
> function isset(value: byte word or dword;bit:byte):boolean;
> for example when i pass the function parrameter a of type word and I want
> to
> see whether the bit 14 is set.
> Regards
> Pianoman
> ----- Original Message -----
> From: <fpc-pascal-request at lists.freepascal.org>
> To: <fpc-pascal at lists.freepascal.org>
> Sent: Monday, February 20, 2006 12:00 PM
> Subject: fpc-pascal Digest, Vol 18, Issue 24
>
>
> > Send fpc-pascal mailing list submissions to
> > fpc-pascal at lists.freepascal.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> > or, via email, send a message with subject or body 'help' to
> > fpc-pascal-request at lists.freepascal.org
> >
> > You can reach the person managing the list at
> > fpc-pascal-owner at lists.freepascal.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of fpc-pascal digest..."
> >
> >
> > Today's Topics:
> >
> >    1.  Bug in RTL for arm (Koenraad Lelong)
> >    2. Re:  Internal error 200312122 (Koenraad Lelong)
> >    3. Re:  Internal error 200312122 (Peter Vreman)
> >    4.  How to run FPC 2.x on QNX (Michael M?ller)
> >    5.  RE: tidypas (libtidy) question (Jeff Pohlmeyer)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Sun, 19 Feb 2006 19:04:07 +0100
> > From: Koenraad Lelong <fpascal at brouwerij.homelinux.net>
> > Subject: [fpc-pascal] Bug in RTL for arm
> > To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> > Message-ID: <43F8B317.2010804 at brouwerij.homelinux.net>
> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> >
> > Hi,
> > Today I did an update via svn. When I compiled for arm (in the hope that
> > the bug I encountered a while ago would have disappeared) I found a bug
> > in rtl/linux/arm/sysnr.inc :
> > Const
> >   syscall_nr_base = syscall_nr_base;
> > I modified this to :
> > Const
> >   syscall_nr_base = $900000;
> > which is similar to fpc 2.0.2. When I compiled this I got my ususal
> error
> :
> > /home/koenraad/fpc-devel/fpc/compiler/ppcrossarm -Ur -XParm-linux- -Xc
> > -Xr -Ur -Xs  -n -Fi../inc -Fi../arm -Fi../unix -Fiarm -FE.
> > -FU/home/koenraad/fpc-devel/fpc/rtl/units/arm-linux -darm -dRELEASE  -Us
> > -Sg system.pp
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s: Assembler
> > messages:
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51368: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51376: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51383: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51390: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51398: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51406: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51414: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51422: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51430: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51438: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51446: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51454: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51462: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51470: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51478: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51624: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51632: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51640: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51648: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51655: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51662: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51669: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51676: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51683: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51690: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51697: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51704: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51711: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51718: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51725: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51732: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51739: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51746: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51753: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51760: Error:
> > unrecognized symbol type ""
> > /home/koenraad/fpc-devel/fpc/rtl/units/arm-linux/system.s:51767: Error:
> > unrecognized symbol type ""
> > threadvr.inc(30,25) Error: Error while assembling exitcode 1
> > threadvr.inc(30,25) Fatal: There were 2 errors compiling module,
> stopping
> > Fatal: Compilation aborted
> > make[5]: *** [system.ppu] Fout 1
> > make[5]: Leaving directory `/home/koenraad/fpc-devel/fpc/rtl/linux'
> > make[4]: *** [linux_all] Fout 2
> > make[4]: Leaving directory `/home/koenraad/fpc-devel/fpc/rtl'
> > make[3]: *** [rtl] Fout 2
> > make[3]: Leaving directory `/home/koenraad/fpc-devel/fpc/compiler'
> > make[2]: *** [cycle] Fout 2
> > make[2]: Leaving directory `/home/koenraad/fpc-devel/fpc/compiler'
> > make[1]: *** [compiler_cycle] Fout 2
> > make[1]: Leaving directory `/home/koenraad/fpc-devel/fpc'
> > make: *** [build-stamp.arm-linux] Fout 2
> >
> > Regards,
> > Koenraad Lelong.
> >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Sun, 19 Feb 2006 19:13:21 +0100
> > From: Koenraad Lelong <koen1 at brouwerij.homelinux.net>
> > Subject: Re: [fpc-pascal] Internal error 200312122
> > To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> > Message-ID: <43F8B541.4070000 at brouwerij.homelinux.net>
> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> >
> > Koenraad Lelong schreef:
> > > Peter Vreman schreef:
> > >
> > >>> Martin Schreiber schreef:
> > >>>
> > >>>> On Sunday 05 February 2006 17.11, Koenraad Lelong wrote:
> > >
> > > ...
> > >
> > >>
> > >> Internalerror numbers are just unique numbers be using <date><seqnr>.
> > >> They
> > >> don't have any meaning.
> > >>
> > >> Quick intro for debugging this.
> > >> - Build compiler with debug info: 'make cycle OPT=-gl'
> > >> - Compile source with this new compiler in gdb:
> > >>    - gdb --args <newcompiler> <args>
> > >>    - (gdb) br INTERNALERROR
> > >>    - (gdb) dir <pathtocompilersource>
> > >>    - (gdb) r
> > >>    - Hit breakpoint
> > >>    - (gdb) bt
> > >>    - The backtrace will give you more info. Use 'fr <framenr>' to
> jump
> to
> > >> a function in the callstack so you can watch the code and variables.
> > >>
> > > OK, I tried this, but that's as far as I can get. Enclosed the output
> of
> > > the backtrace (first lines are the commandline I used).
> > > Anything I can do further ?
> > > Thanks,
> > > Koenraad Lelong.
> > >
> > ...
> > I tried fr <frame#> for the last 20 frames :
> > (gdb) fr 20
> > #20 0x080e04ed in PROC_UNIT () at pmodules.pas:1097
> > 1097                       loadunits;
> > (gdb) fr 19
> > #19 0x080df58a in LOADUNITS () at pmodules.pas:621
> > 621                    tppumodule(pu.u).loadppu;
> > (gdb) fr 18
> > #18 0x080d6ef5 in TPPUMODULE__LOADPPU (this=0x404e6c74) at fppu.pas:1509
> > 1509                  compile(mainsource^);
> > (gdb) fr 17
> > #17 0x0808f207 in COMPILE
> >
> (FILENAME='/home/koenraad/msegui/msegui/lib/common/kernel/msebitmap.pas')
> > at parser.pas:525
> > 525                      proc_unit;
> > (gdb) fr 16
> > #16 0x080e06f0 in PROC_UNIT () at pmodules.pas:1184
> > 1184                 parse_implementation_uses;
> > (gdb) fr 15
> > #15 0x080dfd25 in PARSE_IMPLEMENTATION_USES () at pmodules.pas:839
> > 839                   loadunits;
> > (gdb) fr 14
> > #14 0x080df58a in LOADUNITS () at pmodules.pas:621
> > 621                    tppumodule(pu.u).loadppu;
> > (gdb) fr 13
> > #13 0x080d6df9 in TPPUMODULE__LOADPPU (this=0x41085734) at fppu.pas:1471
> > 1471                        load_usedunits;
> > (gdb) fr 12
> > #12 0x080d6853 in TPPUMODULE__LOAD_USEDUNITS (this=0x41085734) at
> > fppu.pas:1244
> > 1244                  tppumodule(pu.u).loadppu;
> > (gdb) fr 11
> > #11 0x080d6ef5 in TPPUMODULE__LOADPPU (this=0x40304744) at fppu.pas:1509
> > 1509                  compile(mainsource^);
> > (gdb) fr 10
> > #10 0x0808f207 in COMPILE
> > (FILENAME='/home/koenraad/msegui/msegui/lib/common/kernel/msegui.pas')
> > at parser.pas:525
> > 525                      proc_unit;
> > (gdb) fr 9
> > #9  0x080e0a5b in PROC_UNIT () at pmodules.pas:1302
> > 1302
> > gen_intf_wrappers(codesegment,current_module.localsymtable);
> > (gdb) fr 8
> > #8  0x0811d7c3 in GEN_INTF_WRAPPERS (LIST=0x411f3f34, ST=0x41401a54) at
> > ncgutil.pas:2364
> > 2364                  gen_intf_wrapper(list,tobjectdef(def));
> > (gdb) fr 7
> > #7  0x0811d758 in GEN_INTF_WRAPPER (LIST=0x411f3f34, _CLASS=0x41641d54)
> > at ncgutil.pas:2349
> > 2349
> >
> cg.g_intf_wrapper
> (list,_class.implementedinterfaces.implprocs(i,j),tmps,_cla
> ss.implementedinterfaces.ioffsets(i));
> > (gdb) fr 6
> > #6  0x0809cca5 in TCGARM__G_INTF_WRAPPER (LIST=0x411f3f34,
> > PROCDEF=0x41685744,
> >
> >
>
> LABELNAME='WRPR_MSEGUI_TINTERNALAPPLICATION_$_IMOUSE_$_1_$_MSEGUI_TINTERNALA
> PPLICATION_$__GETMOUSEWINID$$LONGWORD',
> > IOFFSET=373, this=0x40068014) at cgcpu.pas:1479
> > 1479    in cgcpu.pas
> > (gdb) fr 5
> > #5  0x080ccfb3 in TCG__G_ADJUST_SELF_VALUE (LIST=0x411f3f34,
> > PROCDEF=0x41685744, IOFFSET=373, this=0x40068014) at cgobj.pas:2001
> > 2001
> > cg.a_op_const_reg(list,OP_SUB,paraloc.size,ioffset,paraloc.register);
> > (gdb) fr 4
> > #4  0x0809a141 in TCGARM__A_OP_CONST_REG (LIST=0x411f3f34, OP=OP_SUB,
> > SIZE=OS_32, A=373, REG=16777216, this=0x40068014) at cgcpu.pas:287
> > 287     in cgcpu.pas
> > (gdb) fr 3
> > #3  0x0809a297 in TCGARM__A_OP_CONST_REG_REG (LIST=0x411f3f34,
> > OP=OP_SUB, SIZE=OS_32, A=373, SRC=16777216, DST=16777216,
> > this=0x40068014) at cgcpu.pas:323
> > 323     in cgcpu.pas
> > (gdb) fr 3
> > #3  0x0809a297 in TCGARM__A_OP_CONST_REG_REG (LIST=0x411f3f34,
> > OP=OP_SUB, SIZE=OS_32, A=373, SRC=16777216, DST=16777216,
> > this=0x40068014) at cgcpu.pas:323
> > 323     in cgcpu.pas
> > (gdb) fr 2
> > #2  0x0809a6db in TCGARM__A_OP_CONST_REG_REG_CHECKOVERFLOW
> > (LIST=0x411f3f34, OP=OP_SUB, SIZE=OS_32, A=373, SRC=16777216,
> > DST=16777216, SETFLAGS=false, OVLOC=
> >          {LOC = LOC_VOID, SIZE = 166, RESFLAGS = 186, VALUE = 134759354,
> > VALUE64 = 4713231088527885242, REFERENCE = {OFFSET = 134759354, SYMBOL =
> > 0x4168c2b4, RELSYMBOL = 0x4168c2b4, SEGMENT = 1097666932, BASE =
> > -2068527460, INDEX = 135726240, REFADDR = 60, SCALEFACTOR = 142,
> > SYMBOLDATA = 0x809ff56, SIGNINDEX = 52, SHIFTIMM = 4, ADDRESSMODE = 9,
> > SHIFTMODE = 8}, REGISTER = 134759354, REGISTER64 = {REGLO = 134759354,
> > REGHI = 1097384628}}, this=0x40068014) at cgcpu.pas:435
> > 435     in cgcpu.pas
> > (gdb) fr 1
> > #1  0x080c926f in TCG__GETINTREGISTER (LIST=0x411f3f34, SIZE=OS_32,
> > this=0x40068014) at cgobj.pas:548
> > 548               internalerror(200312122);
> > (gdb) fr 0
> > #0  INTERNALERROR (I=200312122) at verbose.pas:447
> > 447             UpdateStatus;
> > (gdb)
> >
> > Is there no-one who can give suggestions where to look next ? I want to
> > help, but I don't know much about gdb, I don't know about the internals
> > of fpc...
> > Regards,
> > Koenraad Lelong.
> >
> > ------------------------------
> >
> > Message: 3
> > Date: Mon, 20 Feb 2006 09:03:40 +0100 (CET)
> > From: "Peter Vreman" <peter at freepascal.org>
> > Subject: Re: [fpc-pascal] Internal error 200312122
> > To: "FPC-Pascal users discussions" <fpc-pascal at lists.freepascal.org>
> > Message-ID:
> > <17261.212.136.56.20.1140422620.squirrel at webmail.xs4all.nl>
> > Content-Type: text/plain;charset=iso-8859-1
> >
> > > #2  0x0809a6db in TCGARM__A_OP_CONST_REG_REG_CHECKOVERFLOW
> > > (LIST=0x411f3f34, OP=OP_SUB, SIZE=OS_32, A=373, SRC=16777216,
> > > DST=16777216, SETFLAGS=false, OVLOC=
> > >          {LOC = LOC_VOID, SIZE = 166, RESFLAGS = 186, VALUE =
> 134759354,
> > > VALUE64 = 4713231088527885242, REFERENCE = {OFFSET = 134759354, SYMBOL
> =
> > > 0x4168c2b4, RELSYMBOL = 0x4168c2b4, SEGMENT = 1097666932, BASE =
> > > -2068527460, INDEX = 135726240, REFADDR = 60, SCALEFACTOR = 142,
> > > SYMBOLDATA = 0x809ff56, SIGNINDEX = 52, SHIFTIMM = 4, ADDRESSMODE = 9,
> > > SHIFTMODE = 8}, REGISTER = 134759354, REGISTER64 = {REGLO = 134759354,
> > > REGHI = 1097384628}}, this=0x40068014) at cgcpu.pas:435
> > > 435     in cgcpu.pas
> > > (gdb) fr 1
> > > #1  0x080c926f in TCG__GETINTREGISTER (LIST=0x411f3f34, SIZE=OS_32,
> > > this=0x40068014) at cgobj.pas:548
> > > 548               internalerror(200312122);
> >
> > Fixed
> >
> >
> >
> > ------------------------------
> >
> > Message: 4
> > Date: Sun, 19 Feb 2006 14:17:13 +0100
> > From: Michael M?ller <mueller_michael at nikocity.de>
> > Subject: [fpc-pascal] How to run FPC 2.x on QNX
> > To: fpc-pascal at lists.freepascal.org
> > Message-ID: <20060219131713.GI4858 at mueller_michael.de>
> > Content-Type: text/plain; charset=us-ascii
> >
> > Hi,
> >
> > we are developing a console application under Delphi. The main task is
> > to use it under Windows. But there are some situations where we need
> > to run it under the realtime OS QNX. This is the reason why we use FPC
> > 1.0.x. But it lacks some interesting features like dynamic arrays.
> >
> > I know that QNX isn't official supported anymore. But do you see any
> > chances that it would be possible for us to make the needed changes to
> > compile FPC under QNX? Many things are Unix like and QNX supports
> > POSIX. So where are the difficulties to support QNX?
> >
> > I didn't subscribe to the list. So please CC me in your anwser.
> >
> > Regards
> >
> > Michael
> >
> > ------------------------------
> >
> > Message: 5
> > Date: Mon, 20 Feb 2006 03:52:16 -0600
> > From: "Jeff Pohlmeyer" <yetanothergeek at gmail.com>
> > Subject: [fpc-pascal] RE: tidypas (libtidy) question
> > To: fpc-pascal at lists.freepascal.org
> > Cc: listmember at letterboxes.org
> > Message-ID:
> > <a275e6d00602200152q171ffa98q38ecdc946c23e45c at mail.gmail.com>
> > Content-Type: text/plain; charset=ISO-8859-1
> >
> > > ... when I do this, I get an AV (in Delphi7).
> >
> > >    tidyOptSetValue(fTidyDoc, TidyErrFile, ctmbstr(TIDY_NULL_FILE));
> > >    tidySetErrorFile(fTidyDoc, ctmbstr(TIDY_NULL_FILE));
> > >   { where TIDY_NULL_FILE = 'NUL' for Windows }
> >
> > If you can send me (off-list) a short sample program that
> > shows the AV, maybe I can help.
> >
> >
> > Regards,
> >  - Jeff
> >
> > ------------------------------
> >
> > _______________________________________________
> > fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> >
> > End of fpc-pascal Digest, Vol 18, Issue 24
> > ******************************************
> >
> >
> > __________ Informacia od NOD32 1.1413 (20060217) __________
> >
> > Tato sprava bola preverena antivirusovym systemom NOD32.
> > http://www.eset.sk
> >
> >
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20060220/d0677884/attachment.html>


More information about the fpc-pascal mailing list