الاثنين، مايو ٢٩، ٢٠٠٦

Using Microsoft Word 2007 Beta

El salamo 3alikom,

I’m just trying that new feature in MSWord 2007, it seems that MS is not caring about interfaces only :D ,

No no, it cares about making user as much comfort as possible ;) , that’s why they made the ‘Blog entry’ document template,

After I finish typing that document, I’m gonna search for button to publish it on my Blogger (blogspot) , mmmm, yes, it’s up there at the left top corner ;)going to click there, salaaaaam

الجمعة، مايو ٢٦، ٢٠٠٦

Archigos revisited

el salamo 3alikom,

I've talked before about new things we have learned/used,
now i'm gonna talk about the purpose of the project itself, and before i'll try to explain what's the 'Computer Architecture' about,,,
Amigos team and Wael Abu El-Kheir (Compter & Info. Sciences-Ain Shams, 3rd Year students) worked in that project, trying to make something useful for architects and students or doctors to check their designs ;)... correct design -> correct simulator results, and vice-versa :D

What's the computer architecture?
A computer contains a CPU that process all data, Memory that stores data, and other devices such as hard-disk, I/O devices...
First, the architecture deals with how that processor works, or how to make it work... how to make it understand that a given string of 0's and 1's means ADD or SUBtract or whatever?
Second, it start looking for how to manage the processor activities with other devices arrond

A written code (Assembly, C, etc...) is first Assembled/Compiled , that produces the '.obj' file containing 0's and 1's, each code instruction has it's 'opcode' (string of 0'sand 1's) that identifies it, those binaries are stored in memory then read by the processor as input to the CLU (Control Logic Unit), that unit takes input, then inside it performs a number of logical operations, and outputs to the control lines (increment, clear, load, read, write) of the desired Register, RAM, MUX, etc..
That's all about architecture.

What Archigos do ?
The idea is to make a dynamic emulator, we may call it simulator. That takes the computer architecture design description as input, then it simulates that desgin. i doubt u got what i mean :D !
ok, the design contains some wires that are inputs to some logical gates and are not output of any logical gate,,, those wires are 'pure' inputs, that means i should feed it with there values for the CLU to work
other wires are output of some logical gates, and are not input to any other gate, those are called pure output, outputs on those wires is what i need to control my computer components
I give the simulator the CLU description, give it input, connect output wires with control lines of componenets i represent as objects in my simulator, then press 'Run' it shows the effect of given input on the computer components.
I wish it's somehow clear now :D

we used Electronics Workbench to draw the CLU and to transfer it to Netlist file, we parse (.net Regex) that netlist to produce a C# code (.net CodeDOM library) , all is logical expressions
Compiling then Invoking the generated function (.net Reflection) , returns output that is connected to my objects control lines (object references -pointers do undefined behavior :( )
That's it all.

The compuer components are till now statically repreented inside the code, that's the computer components are code defined, and so connections between components
We look to make that dynamic, no more components are defined inside the code, a user then should create the component he would like to add to his computer, and its control lines will appear for matching with the design wires,,, and so entire connections between components gonna be done graphically

Some screen shots: ( you won't notice any funky interfaces :D )


I didn't talk about ALU as i actually forgot it :D, it's that part of the computer that performs arithmetic and logical operations, it has its own parsing techniques cuz we won't draw it all, we just draw its first, and last stage , and the ith stage, that's gonna be repeated n-times

other files are the CLU design description
pressing next parses these files, and determines if there is 'resursive' connections or 'duplicate' output names (those conditions are denied).

left grid is for pure input wires and right one is for outputs (an option above is available for showing non-pure outputs too)
left column of each contains wires determined in the design, right column are control lines of objects in application
I may save matching for later use, and also names that nearly look like each other are matched automatically
Pressing next, generates the C# code, and sort statements (as some output maybe input to another statement, it should be evaluated first)
any errors (all input wires should be matched, warning that maybe some control lines are not connected to any wire), the architect is notified
Then running the simulator
The simulator performs on the latest loaded design, the architect may move step-by-step are run the appication till a breakpoint or halted

A downloadable (source and executable) version will be available soon isA

That's it :D
And now i should run to start studying for final exams :

salaaaaam :D


الأربعاء، مايو ١٧، ٢٠٠٦

Archigos

The 'Computer Architecture' third year project...
We have condensed the work in emulator, trying to make it suitable for the given computer processor drawing...
Let me talk about what new things we have learned (or done):
- Usage of .NET reflection, and CodeDOM classes
- Usage of pointers in C# (It's making undefined behavior now :s!)
- String manipulation and parsing
- Making our own controls
The latest point is not that hard, but it's new, and we have used alot of GDI+ and handling windows messages,,, it's great to think of making ur own control
Talking about Archigos will come soon isA,

الجمعة، مايو ٠٥، ٢٠٠٦

Pointers, again

el salamo 3alikom,

That's a good thing you could make with pointers,
u know, characters may be indexed either from -127 to 128 i think, or from 0-255
our dear friend has a written pseudo or scenario that index the first way,,, he doesn't wanna keep adding offset to convert it to the second way!
that's he wants:
array[-x] => returns some character

ok
do u have any idea about it ?

lets define the array:
char* ch = new char[256] //C++ Code;

//Till now we should start indexing from 0, other wise negative indexing may result in outOfRange or 'Access Violation'

resolve that by the coming trick:
ch += 127;

wow, now the pointer is pointing to the middle of the array, and the compiler has reserved a 256 bytes for ur array too,,,, it's complete now ;)

ch[-127] = '0';
kep addressing from -127 till 128

What about C# ?
u can do it:

char [] array = new char[256];
fixed ( char* ptr = &array[0])
{
char* p = ptr+127;
}

//ok, u may notice some changes,,, u couldn't increment the pointer itself, that's why we used another one 'p'
// the fixed thing,,, it's because u r taking the address of unfixed expression (the char array)

in C# , u may use -ve indexing even without shifting the pointer, but that ofcourse won't result the desired output :D

wish that was helpful
el salamo 3alikom wa ra7mato Allah

الخميس، مايو ٠٤، ٢٠٠٦

C# Pointers

el salamo 3alikom wa ra7mato Allah wa baraktoh,

how are you everybody? fine e7l

Pointers is one of many other programming language capabilities that every big system developer will need,
Inheritance, Virtual functions, and alot of keywords that when we read about years ago, we said
"structure! , that's making working more complex, i should put some extra text and a dot!"
"making a function private!!, i should not make it at all then!"
"pointers!, why should a have the variable address, i'm dealing with it's value!"

ok, years passed, and someday will come to recognize how important those things are.
Now, i'm gonna talk about how important are pointers and how are they in C#

Pointers:
Assuming a have an electronic connection, node "A" is connected to node "B", and node "C" is connected to node "A" too.

the value of "A" is calculated somehow,,, when representing these nodes as ByValue variables in ur code, then each time u gotta Update values of B and C to have the new value of A!
Update(ref bool B, ref bool C)
{
B = A;
C = A;
}
Good, but what if I've initialized B and C with the address of A ?
bool* B;
bool* C;
B = &A;
C = &A;

any changes to A gonna be reflected to automatically and seen through B and C
Pointers are not only used for dynamic memory allocation ( i think that has not become a matter in C#, as its default is dynamic by reference allocation for the majority of classes).

What do u think the action taken by the C# compiler when you write code as above ? ... pointers in Unsafe scope!!... you should specifiy that part of code to be unsafe, rick region :D
you could specify the scope of function, class, etc... by preceding it's declarator with the keyword 'unsafe'

unsafe public void func(...)
{
//use pointers asif u r in C++, only one restriction! which is...........
}
u have to initialize the pointer with address of some variable (no just 'new' address allocated for the variable)
//Error: int* ptr = new IntPtr(0);

//Correct:
int init = 0;
int* ptr = &init;
//then work with 'ptr' freely from here on, inside ur unsafe scope

u could make objects of classes contining that variables in scopes that shouldn't be unsafe (it's enough for the declaration scope only to be unsafe)

Does the garbage collector affect our pointer ?
Yes, as the variable you have assigned it's address to that pointer is of no more use, then the pointer is aloso of no more use :D
that's a good point, u don't have to 'delete' the pointer,

u may make it 'fixed' ... how ?
fixed (int* ptr = &init)
{
//ur dealing with 'ptr' here
}
i've not used 'fixed' and don't know alot of details about it, u can simply ask Dr.Google about it :D

after you have written ur unsafe code, u have to enable unsafe code compilation
Project > [project name] Properties...> 'Configuration properties' --> 'Allow unsafe code blocks'=True

that's it for now :D , wish it's useful :)

el salamo 3alikom wa ra7mato Allah