Article View: comp.lang.pascal.borland
Article #247Re: BASM - Type to binary
From: Dr John Stockton
Date: Sat, 24 Jul 1999 00:00
Date: Sat, 24 Jul 1999 00:00
42 lines
2569 bytes
2569 bytes
JRS: In article <7naolk$5j$1@nnrp1.deja.com> of Fri, 23 Jul 1999
22:00:23 in news:comp.lang.pascal.borland, Robert AH Prins
<prinsra@williscorroon.com> wrote:
>
>Does anyone know, short of what I've done now, adding a constant with
>the required shift value, if there is a way to get the base-2 log of
>sizes of datastructures in BASM. (Obviously restricted to sizes that are
>powers of 2...)
I don't know enough (any) BASM - however :
You _want_ to arrange that the shift count will automatically be
correct, for the *easy* subsequent avoidance of error.
If that cannot be contrived, it *may* be possible to define the log as a
source-code constant, and arrange that assembly fails if the constant is
incorrect, thereby giving *reliable* avoidance of error, which will
suffice. I've done this in Pascal/Delphi. Perhaps you can use not a
log2 but a pow2, with some equivalent of
const A = <log2?> ;
B = 1 shl A ;
then C = 1 div (Size-B) ;
or type Ar = array [B..Size, Size..B] of byte ;
Or, maybe, some equivalent of
const X = SizeOf(SizedType) ;
A = <log2?> ;
...
if X shr A <> 1 then HALT(234) ;
so that, if wrong, the program will fail immediately on test with a
specific message.
Note : you crossposted between "publicly" and "privately" owned
newsgroups. I *think* that this reply will go only to public servers,
and be missed by TeamB.
--
� John Stockton, Surrey, UK. jrs@merlyn.demon.co.uk Turnpike v4.00 MIME. �
Web <URL: http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
Dates - miscdate.htm Year 2000 - date2000.htm Critical Dates - critdate.htm
Y2k for beginners - year2000.txt UK mini-FAQ - y2k-mfaq.txt Don't Mail News
Technical Details
Message-ID:
<mFancrAQBQm3Ewwv@merlyn.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7naolk$5j$1@nnrp1.deja.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111659,1574494622d1a1c7 X-Google-Attributes: gid111659,public X-Google-Thread: 108ebd,1574494622d1a1c7 X-Google-Attributes: gid108ebd,public From: Dr John Stockton <jrs@merlyn.demon.co.uk> Subject: Re: BASM - Type to binary Date: 1999/07/24 Message-ID: <mFancrAQBQm3Ewwv@merlyn.demon.co.uk> X-Deja-AN: 504741676 Content-Transfer-Encoding: 8bit X-NNTP-Posting-Host: merlyn.demon.co.uk:158.152.233.145 References: <7naolk$5j$1@nnrp1.deja.com> Content-Type: text/plain;charset=iso-8859-1 X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 932825801 nnrp-14:20666 NO-IDENT merlyn.demon.co.uk:158.152.233.145 Organization: Home, Surrey, UK MIME-Version: 1.0 Newsgroups: comp.lang.pascal.borland,borland.public.turbopascal