Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ ROM ➜ Compiling the server ➜ Changing #define A 1 to .... (this might belong somewhere else)

Changing #define A 1 to .... (this might belong somewhere else)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Greystar   USA  (2 posts)  Bio
Date Fri 09 Aug 2002 09:52 PM (UTC)
Message
What I want to do is change the #define structure for Letters.
from
/* RT ASCII conversions -- used so we can have letters in this file */

#define A 1
#define B 2
#define C 4
#define D 8
#define E 16
#define F 32
#define G 64
#define H 128

#define I 256
#define J 512
#define K 1024
#define L 2048
#define M 4096
#define N 8192
#define O 16384
#define P 32768

#define Q 65536
#define R 131072
#define S 262144
#define T 524288
#define U 1048576
#define V 2097152
#define W 4194304
#define X 8388608

#define Y 16777216
#define Z 33554432
#define aa 67108864
#define bb 134217728
#define cc 268435456
#define dd 536870912
#define ee 1073741824

to something like

#define A 01
#define B 02
#define C 03
#define D 04
#define E 05
#define F 06
#define G 07
#define H 08

#define I 09
#define J 0A
#define K 0B
#define L 0C
#define M 0D
#define N 0E
#define O 0F
#define P 10

#define Q 11
#define R 12
#define S 13
#define T 14
#define U 15
#define V 16
#define W 17
#define X 18

#define Y 19
#define Z 1A
#define aa 1B
#define bb 1C
#define cc 1D
#define dd 1E
#define ee 1F

I want to do this to see if I can increase my allowable flags to include

#define ff 20
...
#define zz 34

Obviously I want to change them to hex code.
What I want to know is:

Has anyone done this?
Is it effective to extend the allowable flags though zz?
Does it require a lot of changes to a stock rom code?
Any suggestions are appreciated, flames to a minimum please.

Thanks
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 10 Aug 2002 12:55 AM (UTC)
Message
Your idea won't work as presented, sorry.

The problem is that each flag must be a unique 'bit' in the resulting word in memory.

For example, your idea of defining C as 3, means if you used C it would also match A and B.

Look at it from the bit pattern point of view and you'll see what I mean:

A 0001
B 0010
C 0011

In the original system each new flag is a power of 2, (2, 4, 8, 16 and so on). So the original system looks like this:

A 0001
B 0010
C 0100
D 1000

So you see that the bits don't overlap. Thus, you can have flags A and B set (which will be 0011). In your system you would have no way of distinguishing between A and B set (0011) and C being set (0011).

The original system squeezes as many flags as it can into a 32-bit word (actually there seem to be 31 of them, A-Z plus aa-ee, which probably is because they didn't want to use the 'sign' bit which is the 32nd. bit).

Your only option is to use another field (ie. another 32 bits).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 10 Aug 2002 12:59 AM (UTC)
Message
Writing them in hex does't change the underlying problem, and in any case my example shows that the system falls down even in the case of 1 to 3, which is the same in hex and decimal.

BTW - if you wanted to write in hex the syntax is:

#define M 0x0D

(Your system would compile OK, it would just behave *very* strangely when you tried to use the flags).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Greystar   USA  (2 posts)  Bio
Date Reply #3 on Sun 11 Aug 2002 02:48 AM (UTC)
Message
Thanks! I think I got what I want now though. I got it so it works with 64 bits... still testing though.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,199 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.