On Fri, 8 Sep 2000, Maarten ter Huurne wrote:

> On Fri, 08 Sep 2000, you wrote:
> 
> > > Who need numbers in an arbitrary base anyway? Hexadecimal, decimal and
> > > binary are enough. Octal is supported by many languages, but it is rarely
> > > used in practice (the only use I know is Unix file permissions).
> >
> > Arbitrary base is easily implemented and might be useful in some cases. I
> > don't know when really. But I want to give the possibility.
> 
> In the very few cases anyone needs it, they can simply take a calculator and 
> convert the number to decimal.

Since it's not hard to implement (I already did it anyway), I don't see
any reason to remove it.

> > > Please don't use the C system for header files. It is better to make
> > > the assembler remember which header files are already included and
> > > don't process a single header file twice.
> >
> > I preprocess the source with gcc -E -P -C. Of course this implies that I
> > do use the C system for header files. I just don't feel like rewriting the
> > whole preprocessor again, while I do want its full functionality.
> 
> On most Unix systems, gcc is already installed. But on Windows or Mac, it 
> would require a separate installation, which is quite large as well.

The assembler I made is meant for posix anyway :) For dos/win-xx there are
others, like tni-asm.

> You don't have to write the whole preprocessor again, only the parts you 
> need. Implementing file inclusion is straightforward.

Maybe, but I don't see a reason for doing it.

> I'm not in favor of using C macros in assembly. I'll give a simple example 
> that shows a problem with C macros.
--- snip ---
> But the core of the problem is that the macro doesn't express what X really 
> is: a constant.

Therefore, my assembler can use equ.

#define can be used like this:

#define write_vdp_register(reg,val) \
ld a,val\
out (&h99),a\
ld a,+(reg) or &h80\
out (&h99),a

The +(reg) notation is not nice, but I don't have so much problems with it
that I want to rewrite it.

> I know that C also has constants using the "const" statement. However, these 
> are actually variables that don't allow assignment. Using a typecast, you can 
> change the value of such a "constant". But the most important difference is 
> the way it's compiled: a constant is always placed in memory. But it's more 
> efficient to calculate constant expressions in advance, which is impossible 
> if the value is in memory. That's why C macros are often used in constants.

True. This is, however, C. My assembler does not use the C compiler and
therefore it does not know about `const'. But because I also don't like
the way #define is used for constants, I did include the equ command in
the assembler.

bye,

 main(){int  c[4]   ,x=4  ,l=getpid()  ,i;;   for(  srand(l);c[  x]=-   rand
()%6         ,x--   ;);;  for(         ;44>   x;){  char         a[9] ,*p=
 "%.1f\n",   b[9];x=i=0;  gets(a);for   (l=4 ;l--   ;)x+=-(a[l]  -=48)==
       (b[l  ]=c[   l]);  ;for           (l=0;16    >i;l         =++i %4)x
+=(b[i/4]+   a[l]   ?0:(  a[l]=b[i/4]     =10))     ;printf(p,x  *.1)   ;};}



****
Problems? contact [EMAIL PROTECTED] See also http://www.faq.msxnet.org/
****

Reply via email to