Path: news.cs.au.dk!news.net.uni-c.dk!howland.erols.net!sunqbc.risq.qc.ca!news.uunet.ca!not-for-mail From: Karl Waclawek Newsgroups: comp.lang.beta Subject: Problem with %getByte Date: Fri, 15 Jan 1999 04:24:46 +0000 Organization: UUNET Canada News Transport Lines: 44 Sender: IDENT:karl2 Message-ID: <369EC30E.9BFD77C9@idirect.com> NNTP-Posting-Host: 207.136.101.27 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [en] (X11; U; Linux 2.0.36 i586) X-Accept-Language: en Xref: news.cs.au.dk comp.lang.beta:11795 In my quest for speeding up my CRC program (it runs about 10 times as slow as my Delphi-coded equivalent I looked into the basic libraries code to see how they do it there. Doing that, I found that the putHex function did not work properly. I traced the problem back to the %getByte function, which returns incorrect values depending on the context. Just run the following program. It prints out the Byte values of an integer variable, first using the constants 3, 2, 1 and 0 as input to %getByte, then using the loop variable in a for loop. On my machine (Beta release 4.1) the outputs are different, i.e. the for loop produces incorrect output. ORIGIN '~beta/basiclib/v1.6/betaenv' -- program: Descriptor -- (# TestInt, j: @Integer; do 16x20304050 -> TestInt; 'Using Constants\n' -> putText; 'Byte Index: 3 Byte Value: ' -> putText; 3 -> TestInt.%getByte -> putInt; '\n' -> putText; 'Byte Index: 2 Byte Value: ' -> putText; 2 -> TestInt.%getByte -> putInt; '\n' -> putText; 'Byte Index: 1 Byte Value: ' -> putText; 1 -> TestInt.%getByte -> putInt; '\n' -> putText; 'Byte Index: 0 Byte Value: ' -> putText; 0 -> TestInt.%getByte -> putInt; '\n' -> putText; 'Using a For loop\n' -> putText; (for i: 4 repeat (4-i) -> j; 'Byte Index: ' -> putText; j -> putInt; ' ' -> putText; 'Byte Value: ' -> putText; j -> TestInt.%getByte -> putInt; '\n' -> putText; for); #) -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Karl Waclawek KD Soft Inc. * Phone: (905) 579-3443 * E-Mail: waclawek@idirect.com