reversible hex dump

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
deadrats
Newbie
Posts: 3
Joined: Wed Nov 28, 2007 10:01 pm

reversible hex dump

Post by deadrats » Wed Nov 28, 2007 10:18 pm

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.

User avatar
burger2227
Veteran
Posts: 2446
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

NOPE

Post by burger2227 » Wed Nov 28, 2007 10:25 pm

QB cannot access RAM, so your stuck with C+.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

deadrats
Newbie
Posts: 3
Joined: Wed Nov 28, 2007 10:01 pm

Re: NOPE

Post by deadrats » Wed Nov 28, 2007 11:42 pm

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...

User avatar
burger2227
Veteran
Posts: 2446
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Thu Nov 29, 2007 2:37 pm

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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Nemesis
Coder
Posts: 36
Joined: Mon Aug 16, 2004 12:54 pm
Location: Colorado Springs, Colorado

Post by Nemesis » Fri Nov 30, 2007 3:02 am

If you know how to access files in binary mode, know peek/poke and
other memory functions, then what's the problem?

User avatar
Codemss
Veteran
Posts: 124
Joined: Sun Jun 24, 2007 6:49 am
Location: Utrecht, The Netherlands
Contact:

Post by Codemss » Sun Dec 02, 2007 6:31 am

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
Check out my site: <a href="http://members.lycos.nl/rubynl">Click here</a>
Hope you like it. Send some feedback if you want: <a href="mailto:basicallybest@live.nl">Mail me</a>
Codemss, before known as RubyNL

deadrats
Newbie
Posts: 3
Joined: Wed Nov 28, 2007 10:01 pm

Post by deadrats » Tue Dec 04, 2007 11:04 pm

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.

Post Reply