Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Writing Hex or Binary

Author
Message
Eddie Gordo
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 25th Aug 2003 21:49
I believe, correct me if i am wrong, but isn't Binary written in Bits which DBPro doesn't have access to writing...I believe the smallest unit of DBPros access is Byte...so if i wanted to write Binary or Hex what can i write it in using DBPro...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 25th Aug 2003 21:53
With no language can you write just a bit - the minimum would be 8 bits. If you want to write just a bit, your going to have to write 8, I'm afraid.


Eddie Gordo
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 25th Aug 2003 22:28
Well how can i write binary to a file using darkbasic? Bytes? i know there are 8 Bits i want to know how to write them...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Dreamora
23
Years of Service
User Offline
Joined: 20th Sep 2002
Location: Switzerland
Posted: 25th Aug 2003 22:40
sometimes I'm not sure if people have found out wherefor the F1 key is exactly ...



WRITE BYTE
This command will write a byte of data to the file from an integer value. The file specified by the file number must be open or the command will fail.

SYNTAX
WRITE BYTE File Number, Variable
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 25th Aug 2003 22:44 Edited at: 25th Aug 2003 22:46
Well, do you want to write binary as text or as a number ?

You could write one bit if your writing text.



or



Quote: "sometimes I'm not sure if people have found out wherefor the F1 key is exactly"

Does make you wonder, doesn't it..


Eddie Gordo
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 26th Aug 2003 01:15
Quote: "sometimes I'm not sure if people have found out wherefor the F1 key is exactly ..."


sometimes I'm not sure if anyone reads the posts before they answer the questions...

So when i write a set of zeros and ones to the bytes that will be the binary i am trying to write? I am trying to write a simple compiler but i am not sure how to write the machine code in binary to a file...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 26th Aug 2003 01:25
Well, you can achieve the bits you want using bytes. If you want the bit pattern 10110011 then the decimal representation is 179. So writing a byte of value 179 would give you that bit pattern.

Remember, everything from sound to images to program EXEs to the formatting structure of your harddisk is stored in binary. Strings are stored as binary etc.

The eight bits of a binary byte represent these values -
128-64-32-16-8-4-2-1

You can make any decimal value between 0 and 255 using that system. So 65 is: 01000001

But anyway, admit it eddie. You're just being pedantic. You don't actually need binary or hex! Come on! Admit it!

Insiiiiiiiiiiiiiiiiiiiiiiiide!
Dreamora
23
Years of Service
User Offline
Joined: 20th Sep 2002
Location: Switzerland
Posted: 26th Aug 2003 02:34
gosh ... wants to write bites and has no idea what binary hex actually is like ... and someone like you had the visual DBP project? i think i know why we never saw it ... typical software "programmer" with no idea of IT and elementary things in it ...
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 26th Aug 2003 05:21
KEY
This crash course in basic mathematics uses standard suffix denominations on all numbers to denote which number base is being shown.

b = Binary
d = Dinary
o = Octal
h = Hexadecimal



A byte can represent any number up to 255 and is comprised of 8 bits. The value of each bit doubles so that each unique bit combination provides a different number. The value of the last bit is 1, with each proceeding bit doubling in value.

00000001b = 1d
00000010b = 2d
00000011b = 3d
00000100b = 4d
00000101b = 5d
and so on

There are 256 bit combinations (0-255), when combining 2 bytes together (called a word) this gives values up to 256x256=65535. 4 bytes together is a long word or double word and can value up to 256x256x256x256=4294967295. We have to count zero as the first possible combination, which is why all these numbers are 1 under the number of combinations possible.

Bytes are often represented with hexademial. Hexadecimal is a process where each character can be a value of 0-15, rather than our normal numbering system called dinary 0-9. Binary is simply another numbering system 0-1. There is also octal 0-7.

To physically represent the hexadecimal values of 10 or more we start using the alphabet.

10d = Ah
11d = Bh
12d = Ch
13d = Dh
14d = Eh
15d = Fh

Using two hexadecimal characters together allows us 256 combinations, so bytes are frequently represented in this manner. ie. FFh 0Bh 4Eh.



I see you are intending to write a machine code compiler. I applaud your zeal, but must express that I have a niggling doubt that your project is possible for you at this time given that you did not know this. I would encourage you to rethink it, or perhaps I have missunderstood your intentions.

Pneumatic Dryll
Thade
22
Years of Service
User Offline
Joined: 20th Aug 2003
Location:
Posted: 26th Aug 2003 06:17
In the Menu goto: Help / Principles / Numerical Bases
You will read this:

Numerical bases are the method by which a value is represented. Most number systems use Base 10 which essentially consists of digits
zero through nine. This however is not the only method of representing a value. There are many other forms of numerical
representation, some of which are supported below:

BINARY
numerical value representing Base 2 and consists only of values zero and one. Counting from zero through to ten, the binary values
would look like 0, 01, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010. A binary value is coded with a '%' symbol prefix to inform the
compiler that the value is binary. In binary, the value ten would be coded %1010.

OCTAL
numerical value representing Base 8 and consists of values zero through seven. Counting from zero through to ten, the octal values
would look like 00, 01, 02, 03, 04, 05, 06, 07, 10, 11, 12. An octal value is coded with a '0c' prefix to inform the compiler that the value
is octal. In octal, the value ten would be coded 0c12.

HEXADECIMAL
numerical value representing Base 16 and consists of values 0 through F. Counting from zero through to twenty, the hexadecimal values
would look like 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11, 12, 13, 14. A hexadecimal value is coded with a
'0x' prefix to inform the compiler that the value is hex. In hexadecimal, the value twenty would be coded 0x14.
Eddie Gordo
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 26th Aug 2003 07:45
Thank you fallout thats what i was looking for, i couldn't find it for some reason...thanks again for the help!!!

@Dreamflower(no flame intended) but, yeah i know what binary and hex are like if thats what you meant cause binary hex must be 64 bit windows or just looking at both at the same time...i dunno...anyways i am curious, is that so wrong at least i(who is 16 years of age) is attemping to learn...typical ***hole pretends to know everything when he cant even answer the question...ok i guess that was a bit of a flame my apologies but i think everyone agrees that you are not exactly helping me with your snooty comments about the F1 key...

at the rest of you i already knew that, but thanks, i may ask question but that is because i aspire to be more than i am...and not because i am dumb...beside the wise man can admit when he is the fool when the fool admits he is a wise man...

All i really needed to know was how to write the bits...i know how to write the machine code...i know what it is...well sort of...

you are misunderstanding PD i am not really trying to create a compiler as i just learned how the machine codes work but i am trying to learn how to write a compiler...not write one...maybe some day but even i am not ambitious enough to take on the task of writing a new expandable form of basic using downloadable libraries so that you can extend the code base of the language...nope not at all...no honestly i just wanna know how it works...i enjoy learning about computers...i am 16 and i am smarter than all of my teacher so i am always trying to learn somthing new...that explains the reason i have yet to release the IDE...because i got side tracked...again...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)
Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 28th Aug 2003 05:41
Golly you guys, quit bein' so pissy! It's not required to know Binary Coding to program, that's what man made PROGRAMMING LANGUAGES for.

Don't turn your back on me, I won't be ignored! Faint - Linkin Park

One minute your on top! Next you're not, watch you drop! Linkin Park- Hit the Floor
Mattman
23
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 28th Aug 2003 05:55
I've always wondered how things are created on the pc. I mean, how would you write binary code?

Got a knack for finding secrets??? Jingot Racing --- A new brand of Racing --- Only from Nightwatch Studios
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 28th Aug 2003 15:14
That's the thing. People don't actually write binary machine code. Assembler is about as low as you go. Even when you're coding software for a mobile phone chipset or something.

You're given a list of functions the CPU can perform and they're each given a neumonic representation. So your ADD or BRG or JMP commands are all direct representations of machine code, and they're exact functions your CPU can perform. Its not like a high level language where ADD goes off and does a load of different things. ADD in the assembler sense is 1 single operation the CPU can do it'll get the ADD command (which might be represented as 10010011) and then it's circuitry will add the following number to the number after that and put the answer in the accumulator circuit.

The point is Assembler is, in essense, machine code. For every word you see on screen, there are no sub structures. Each word is a specific cpu operation and therefore only needs to be converted to its binary equivilent and you have raw machine code (with the exclusion of line numbers etc. depending what sort of assembler program you're using).

To make the machine code program, it's just a certain order of 0s and 1s that specifies its an executable. If you have low enough level access to what information is written to the harddisk when you save, you could save a file with the binary structure that specifies it an executable, and there you have it, a program.

Insiiiiiiiiiiiiiiiiiiiiiiiide!

Login to post a reply

Server time is: 2026-07-23 00:17:23
Your offset time is: 2026-07-23 00:17:23