🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.csharpbuilder.compiler
5 messages
5 total messages Started by JRobert Fri, 06 Aug 2004 21:14
Initializing a Array of Classes.
#2
Author: JRobert
Date: Fri, 06 Aug 2004 21:14
41 lines
1748 bytes
Hi all,

i'm working on a disassembler for the M68K and
have the  following situation.

	public class m68kDisassembler
	{
		#region MC68K Mnemonic Strings
		static string[] m68kMnemonics =
{"abcd","add.b","add.w","add.l", etc. etc ...
		#endregion

		class OPCODE_NODE
		{
		  ushort	op_mask;
		  ushort	op_code;
		  OPCODETYPE	opctype;
		  CPUTYPE	cpubits;
		  ADDRMODE	addrm;
		};
	}

now i want to make an array of OPCODE_NODEs and fill them with the 
correct data. I'm trying this.

	private static OPCODE_NODE[] Group_0x0 = {
		 {0xffff, 0x003C, m_ORI, opct_CCR, ALL, IMPLIED},
		 here the next initialization
		and the next
		.
		.
OPCODETYPE,CPUTYPE, and ADDRMODE are enums that are within the code, so
all symbols are existion.

This is the way i'm doing with a c++ compiler but somehow i don't get it
how to make it in cs.

Any suggestions ?

Regards,
Robert
Re: Initializing a Array of Classes.
#3
Author: Marc Rohloff TeamB
Date: Fri, 06 Aug 2004 21:24
29 lines
1559 bytes
On Fri, 06 Aug 2004 22:14:12 +0100, JRobert wrote:

Something like:

> 		class OPCODE_NODE
> 		{
> 		  ushort	op_mask;
> 		  ushort	op_code;
> 		  OPCODETYPE	opctype;
> 		  CPUTYPE	cpubits;
> 		  ADDRMODE	addrm;
   OPCODE_NODE (ushort opmask, ushort op_code, OPCODETYPE opctype,
CPUTYPE cpubits, ADDRMODE addrm)
   { this.opmask = opmask;
     ... }
> 		};
> 	}
> 
> 	private static OPCODE_NODE[] Group_0x0 = {
        new OPCODE_MODE(0xffff, 0x003C, m_ORI, opct_CCR, ALL,
IMPLIED),
      ...
      
> Any suggestions ?
You should probably be using structs instead of classes here.

-- 
Marc Rohloff [TeamB]
marc rohloff at myrealbox dot com
Re: Initializing a Array of Classes.
#4
Author: JRobert
Date: Sat, 07 Aug 2004 07:44
61 lines
2292 bytes
Thanks a lot!, the struct hint and the way you pointed me works.

Marc Rohloff [TeamB] wrote:
> On Fri, 06 Aug 2004 22:14:12 +0100, JRobert wrote:
> 
> Something like:
> 
> 
> 
>    OPCODE_NODE (ushort opmask, ushort op_code, OPCODETYPE opctype,
> CPUTYPE cpubits, ADDRMODE addrm)
>    { this.opmask = opmask;
>      ... }
> 

The struct constructor had to be done _public_. I got a an error while 
it wasn't.

> 
>         new OPCODE_MODE(0xffff, 0x003C, m_ORI, opct_CCR, ALL,
> IMPLIED),
>       ...
>       

This works also be only with this line:
	...
new OPCODE_NODE (0xffff, 0x003C, MNEMONIC.ORI, OPCODETYPE.CCR,
CPUTYPE.ALL, ADDRMODE.IMPLIED),

I have to use the enum Name. Somehow there is a namespace problem if i 
don't use the enum name.

My code looks like this.

----------->
namespace madis
{
		#region MC68K Enumerations

		public enum M68KType {M68000 = 0};
		public enum MNEMONIC { ABCD=0,
	ADDB,		ADDW, 	ADDL,
	ADDAW, 	ADDAL,
	.
	ORI,
	.
	public class m68kDisassembler
	{
	.
	.
	.
		private static OPCODE_NODE[] Group_0x0 = {
			new OPCODE_NODE (0xffff, 0x003C, MNEMONIC.ORI, OPCODETYPE.CCR, 
CPUTYPE.ALL, ADDRMODE.IMPLIED),
	.
	.
	.
---------->

Regards,
Robert
Re: Initializing a Array of Classes.
#5
Author: Eric
Date: Mon, 09 Aug 2004 22:44
7 lines
963 bytes
Robert,

Is this going to be an open source project? I wrote some open source
IDE's for embedded processors using Delphi, and I'd like to do some of
this with C#.

Eric
Re: Initializing a Array of Classes.
#6
Author: JRobert
Date: Tue, 10 Aug 2004 05:58
21 lines
1572 bytes
Hello Eric,

Eric wrote:
> Robert,
> 
> Is this going to be an open source project?

I cannot say this at this moment since i've just started to learn C# and 
.NET, but if all goes alright I also plan to do a dubugger out of this 
for several binary formats and architectures not only the m68k.

  I wrote some open source
> IDE's for embedded processors using Delphi, and I'd like to do some of
> this with C#.
>
As far as i've seen C# is very suitable to do a IDE. :-) Good luck!

> Eric

Regards,
Robert
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads