Page 1 of 1

reversible hex dump

Posted: Wed Nov 28, 2007 10:18 pm
by deadrats
hello everyone,

as the title suggests i'm trying to write a program in BASIC (using QBASIC) that would allow one to make a reversible hex dump, or more accurately a reversible binary dump.

to understand what i mean: all data is stored on a hdd (or ram for that matter) as a sequence of electrical states, either on or off, and conceptually represented as a sequence of 1's and 0's. what i want to do is look at those electrical states and write a sequence of 1's and 0's to a text file that represent that file and then recreate that file by having my program look at that text file, read the 1's and 0's and then write the electrical states to the hdd.

before anyone tells me it can't be done, it can be done in C/C++ and i did so years ago, it can be done in Pascal, but both those languages support pointers i was just wondering if it could be done with QBASIC since QBASIC does allow the reading and writing of files in binary mode and it has the PEEK/POKE commands that allow for memory manipulation, so i was wondering if it could be done.

any help would be appreciated, be it code or just a link....

thanks,

deadrats.

NOPE

Posted: Wed Nov 28, 2007 10:25 pm
by burger2227
QB cannot access RAM, so your stuck with C+.

Re: NOPE

Posted: Wed Nov 28, 2007 11:42 pm
by deadrats
burger2227 wrote:QB cannot access RAM, so your stuck with C+.
thanks for your reply, but that's not entirely accurate, following links from this very site i found that you can use assembler commands from within QB:

http://www.petesqbsite.com/sections/tut ... ls/asm.txt

http://www.petesqbsite.com/sections/tut ... 4-asm.html

which means i can use assembler from within QB to access ram, but that is beside the point. i am not exactly looking to access ram so much as to read and manipulate the electrical states that comprise a file on a hdd and i found these links on this site:

http://www.petesqbsite.com/sections/tut ... emory.html

http://www.petesqbsite.com/sections/tut ... sc.shtml#4

it even looks like someone created an entire OS coded in QB:

http://www.petesqbsite.com/sections/tut ... a_soul.txt

there are numerous other links i found that will be of great help, all in all i am finding this site to be very usefull, this is going to turn into an interesting project...

Posted: Thu Nov 29, 2007 2:37 pm
by burger2227
True that you might be able to do it with the help of assembly code. I am sure there are other options too, but you specifically said "in Qbasic". I figure if you can do it in C, why bother doing it a harder way.

Good luck on your project. Feel free to tell us of any new ideas you come up with! We are always looking for new ideas!

Ted

Posted: Fri Nov 30, 2007 3:02 am
by Nemesis
If you know how to access files in binary mode, know peek/poke and
other memory functions, then what's the problem?

Posted: Sun Dec 02, 2007 6:31 am
by Codemss
I don't understand you problem either. Is it in accessing the RAM/hdd (what is hdd? Harddisk?). Well I only know about PEEK and POKE, and BINARY files. They both handle numbers from 0-255. Is your problem that want only binary numbers, that are 0 or 1?
I don't think that it is because you seem to be a advanced programmer and this is easy to solve, but I'll ask it anyway..

Codemss

Posted: Tue Dec 04, 2007 11:04 pm
by deadrats
Codemss wrote:I don't understand you problem either. Is it in accessing the RAM/hdd (what is hdd? Harddisk?). Well I only know about PEEK and POKE, and BINARY files. They both handle numbers from 0-255. Is your problem that want only binary numbers, that are 0 or 1?
I don't think that it is because you seem to be a advanced programmer and this is easy to solve, but I'll ask it anyway..

Codemss
it's true i have done quite a bit of programming (i was a physics and comp sci major in college) but it's been years since i have actually coded anything and this project is my way of jumping back into it again.

so the answer to your question is that while i could have coded this with my eyes closed years ago years out of school without writing a single line of code has dulled the edge so to speak, while i know about numerous memory functions i'm finding it hard to put everything together into a program, basically i seem to be suffering a brain fart and can't figure out how to put everything together into a working program.

i know i have to open the file in binary mode, read each electrical state (via a loop) and test whether it corresponds to a 1 or a 0, then write the appropriate character to a text file, but i'm finding it difficult to reverse the process, until i started this project i didn't realize just how out of practice i was as far as coding is concerned.