d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Computer Binary > Signed Vs. None Signed.
Prev12
Add Reply New Topic New Poll
Member
Posts: 35,456
Joined: Jan 25 2009
Gold: 1,173.00
Jan 31 2014 12:43pm
Ah thanks fellas. Always learning. B)
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Jan 31 2014 08:36pm
Just to break it down a little more, you want to consider the different levels of computer architecture.

At the lowest form you have digital circuits. Which is basically the hardware passing electrical current through logic gates that then raise or lower the voltage to establish whether it is open or closed. Grouping these together you can build the basic components of a computer system (ALU, CPU, Registers, etc).

But that isn't readable by a human being. Electrical signals mean nothing. We need another layer of abstraction.

So we add in microcode. This is typically stored in ROM on the CPU, and it groups together bit patterns that make up the instructions that command the machine.But this is hard-coded instructions. We need another layer of abstraction.

So we add in machinecode. This defines the instruction set of the machine, and allows our first way of actually programming the machine. It interprets these bit patterns as 1's and 0's and gives us a way to actually call each instruction to operate the CPU. But 1's and 0's are confusing. We need another layer of abstraction.

So we add in assembly language. This allows us to represent those 1's and 0's with symbols and keywords which is then compiled back into machine code by an assembler. We have now entered the realm of low-level languages. But its still constrained by the architecture. We need another layer of abstraction.

So we add in Java. Now we are in the realm of "high-level languages." The language will abstract away all the native code making it even easier to program. Now you don't need to worry about the architecture. The compiler will take the code you write and convert it to a lower language.

So we have gone from electrical signals to using natural language to code your programs. Each layer adding more and more readability.

Now, in transition to these different layers define the data types which defines what they mean. 4 bytes for an integer, 8 bytes a double, etc. What is signed, unsigned, etc.

The programmer doesn't need to worry about those details because they are abstracted away.

And that is a high-level crash course in computer architecture.
Member
Posts: 35,456
Joined: Jan 25 2009
Gold: 1,173.00
Feb 1 2014 01:39am
That was delightfully brilliant sir, thank you.
Member
Posts: 28,331
Joined: Jun 9 2007
Gold: 11,700.00
Feb 2 2014 01:24am
Quote (NinjaSushi2 @ 31 Jan 2014 05:36)
Ah I see. So the os hands down the initial machine code values. Then any other higher languages would modify such values as need fit.


it really depends on the architecture of the specific machine and it's operating system, the following is partly right

Quote (Azrad @ 31 Jan 2014 11:21)
yeah but your use of the word modify is problematic. Lets take the binary value: 00110101, which in base10 is 53
add:
if you call a function that adds numbers with  00110101 with 00000001; you will get 00110110  or in base 10 you get 54
print
if you call a function that prints to the screen with  00110101; you will get "5" on the screen because base10 53 is ascii for the character "5"
pointer:
if you call a function to expects an memory location as an input with 00110101; the function will use whatever is stored in memory location 00110101 and use that as its input
silly:
you might even have a function that expects this kind of input based on each digit of binary:
male?:hashair?:over30?:likecupcakes?:collegegraduate?:HasDiabetes?:PlaysD2?:LikesTurtles:    in which case 00110101 would mean: A woman, who is bald, who is over 30, who likes cupcakes, is not college graduate, has diabetes, does not play d2, and like turtles.


except that the 'silly' is really a string of true/false with the interpretation left to the particular program you are using
to give you a few more options:

the string 11111111 will for some architectures mean -0, then 11111110 is -1 and 10000000 is -127 and for other architectures the string 11111111 is -1, with 11111110 being -2 and 10000000 = -128 (check up on one's and two's complement - both are different to what you got) and don't forget that there are plenty different architectures based on different "word/byte" lengths/numbers:
8-bit, 9-bit, 16-bit, 32-bit, 36-bit, 48-bit and 64-bit architectures i have used (and there are/were more like 6-bit and 128-bit)

the 'data' might as well refer to a hardware function which can be executed, not just data
also as indicated by "Azrad" it can be a pointer and some architectures use the first bit as indirect indicator, that is the following bits give the adr where you go or pick up data but if the first bit is set the rest is an adr which can again be a pointer etc etc etc
in the end it depends on the machine code what that string of bits means at the bottom level and then you can manipulate it yourself on the program level
the most interesting one i remember is within a 16-bit architecture which used to pack 3 characters into one 16-bit word, effectively using 5 1/3 bits for each character

hope you are now fully confused :D

@ "Minkomonster"

no general problem with your description but
assemblers do not compile, they assemble/translate either in single or multiple phases
basic assembly instructions are just mnemonic representation of machine code
some assembly languages have/allow for a macro layer to make the coding faster/easier

This post was edited by brmv on Feb 2 2014 01:41am
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 2 2014 03:19am
Quote (brmv @ Feb 2 2014 02:24am)


@ "Minkomonster"

no general problem with your description but
assemblers do not compile, they assemble/translate either in single or multiple phases

My bad on the word "compile." Made a mental note not to use it when I was writing the description for fear that someone would call me out on semantics. The word I meant to use was "convert," but it still managed to creep in there. Synonyms are fun.

Quote

basic assembly instructions are just mnemonic representation of machine code

Yes. I said it uses symbols and keywords. These would be mnemonic representations.

Quote

some assembly languages have/allow for a macro layer to make the coding faster/easier

I left out quite a bit of stuff, as I was not intending to teach a course on ISA.

Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll