another binary question?

forcer

OSNN Senior Addict
Joined
18 Oct 2002
Messages
413
if i have a bit pattern such as ... 0101 001

can the computer tell if its a number, character or an instruction, if so how?

thanx
 
you may want to look into machine language (assembly). you actually enter in binary values. it's a super fast language, but pretty dang hard to code in.

just googlize "machine language" or "assembly language". :)
 
computers would not be able to tell from a simple bit pattern - and these days eight bits would not be enough for them to deduce anything much - it is all context sensistive.

(I am still programming in assembler, so I have some idea!)

In basic terms - a computer keeps a place marker for where it is up to in memory - typically known perhaps as a Program Status Word (PSW). From there it may look forward to see if it has an instruction code during execution, and each different instruction code will have different formats which the computer (or rather the Operating System) will recognise.

Whenever a computer tries to execute something that is NOT an instruction you will know about it pretty soon - the program will be highly unlikely to get much further!

Usually in machine language you are only patching - if you want to code close to the metal you best bet is assembler which allows mnemonics - so that I can write B for a branch instead of coding x'47F0address'. Then better yet you have macros on top - so that you can wrap up common constructs as you require them.... Keep going like that and you'll write a language perhaps!
 
The "computer" can't tell diddly about what the bit pattern represents. It just does things to 1' and 0's.

The programming language keeps track of what each group of 1/0's are for. The language can be assembly (lowest level programming language, close to the 1/0's in the machine), Basic, Pascal, C (and dozens of others that are dead or dying).

Each language handles the characters, numbers, strings (of letters) a little differently so when looking at the 1/0's you need to have an idea of what language the code was written in.

Sometime you can open the program file in notepad and see strings of text (these are in ascii text format that is a standard across all compuer languages). Never save a program file you open with any kind of word processor!!!!!! It may be corrupted.

Ascii uses 8 bit data groups allowing 256 characters. The first 128 are well defined (numbers, letters, punctuation and some control characters that go back to the old teletype terminals) and the last 128 can vary with the application. Note The ascii charaters do not correspond directly to anything. i.e. 0 is not 0, etc.

And to answer your question the programming language has a compiler and linker that change the instructions you write into machine instructions, text, numeric data, etc and put it all in a format the machine can read and execute.

Some of the new web pseudo languages like HTML, JAVA, etc use interpreters that take the programming instructions directly or precompile them into an intermediate language (used to be called pseudo code) that is easier for machines to use. In this case each machine must have the final compiler installed on it so it can take the code on the fly and interpret it. This kind of compiling is inherently slower but allows for compatibility between machines (same web pages runs (almost) the same way in IE, Netscape or on a Mac)

Well that ought to keep you busy till the turkeys done ;)
 
Originally posted by LeeJend

The "computer" can't tell diddly about what the bit pattern represents. It just does things to 1' and 0's.

actually, if you really want to get technical, computers don't even understand numbers...

only if a transistor is "on" (we represent that as the number 1) or "off" (we represent that as the number 0). :p
 
Wow, this thread is full of new stuff to learn, we hear what Machine Assembler Language is, we learn that computers only have transisters that can go on and off.

If you have a binary sequence like you showed, it can represent anything.

It can be 0101 001b which could then be put into hexadecimal, decimal, and any other base.

0101 001 is meaningless without specifying anything. If used in a C++ program, you can use it to manipulate other numbers, or do bitwise operations with it. If used in a sentence, it would just be a few characters, and not a lot more, which would then be represented in the memory by:

8x lenght of string.
 
i'm not sure about using binary in a c++ program. i went to a tech school and took a couple of years of programming classes, including c++, and never encountered using binary with it per se. we did however, have to learn binary and hexidecimal in c programming. i think it was more of a logic test than anything else.

i think binary numbers are mainly used with assembly language. i've never taken a class on assembly, but i've heard it's extremely difficult.

c++ is a higher programming language, meaning that it's easier for people to program in it, than say machine language (the lowest programming language because it's the closest thing you can get to direct instructions to the computer).
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back