C++: working with bits?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
Laserbeak43
Posts: 188
Joined: Fri Sep 21, 2007 4:31 pm
Contact:

C++: working with bits?

Post by Laserbeak43 »

Hello,
I'm reading a 6502 programming book, and have decided to code every peice mentioned in the book, put it together and make it work.

so, i've got the boost libraries installed and am using 8 and 16 bit integer types. but i can't measure them( sizeof() only measures in bytes ) and i don't know how i can work with bits if i'm only measuring bytes.

anyone know of a solution to this?

Code: Select all

#include <iostream>
#include <boost/cstdint.hpp>

using namespace std;

int main()
{
	static const boost::int8_t	int8;
	cout << "sizeof(int8) = " << sizeof(int8) << endl;
    return 0;
}
Noob sticky!!
Please document this part of the NESdevWiki!! XD
YOU NEED A RETROMACHINESHOP!!
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

int8_t is a signed 8-bit integer. sizeof gives the size of an object, in bytes. sizeof (char) is defined to be 1. numeric_limits<type>::digits gives the number of bits in a type. But, why C++ for learning 6502?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

blargg wrote:But, why C++ for learning 6502?
I don't know about Laserbeak43's situation, but at least my own projects use custom tools written in C to build lookup tables and to convert assets (images, maps, sound) to NES-friendly formats.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Yeah, but he's learning, not building a game or anything...
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

blargg wrote:But, why C++ for learning 6502?
- I have no clue too. ^_^;;
User avatar
Laserbeak43
Posts: 188
Joined: Fri Sep 21, 2007 4:31 pm
Contact:

Post by Laserbeak43 »

hehe, well it was my original idea to build the things that i read about the 6502 as i go along, but it it turns out that this rodnay zaks book is part 2 of a series of like seven books or something. and the actual book that has the actual tech info on the 6502 is the volume before this one... so i might not be able to do that and just concentrate on 6502 programming.

new thread coming in the newb section :)
Noob sticky!!
Please document this part of the NESdevWiki!! XD
YOU NEED A RETROMACHINESHOP!!
atari2600a
Posts: 324
Joined: Fri Jun 29, 2007 10:25 pm
Location: Earth, Milkyway Galaxy, The Universe, M-Theory
Contact:

Post by atari2600a »

Oh how I wish atariarchive.org was still up...

Code: Select all

          *=$0000
loop      JMP loop
          .eof
User avatar
Laserbeak43
Posts: 188
Joined: Fri Sep 21, 2007 4:31 pm
Contact:

Post by Laserbeak43 »

atari2600a wrote:Oh how I wish atariarchive.org was still up...
why?
Noob sticky!!
Please document this part of the NESdevWiki!! XD
YOU NEED A RETROMACHINESHOP!!
Post Reply