EzDevInfo.com

8bit.js

8Bit.js Audio Library - Write music using 8bit oscillation sounds.

Is Z80 Game Boy CPU 8 or 16 bits?

I was reading a tutorial about creating a Game Boy emulator, I understand that the Game Boy uses a 8 bit CPU, but I can't understand why the gameboy uses 2 types of data: bytes (8 bits) and words (16 bits).

If the CPU have a capacity of 8 bits, why it is possible to use 16 bits?


Source: (StackOverflow)

How to convert a BufferedImage to 8 bit?

I was looking at the ImageConverter class, trying to figure out how to convert a BufferedImage to 8-bit color, but I have no idea how I would do this. I was also searching around the internet and I could find no simple answer, they were all talking about 8 bit grayscale images. I simply want to convert the colors of an image to 8 bit... nothing else, no resizing no nothing. Does anyone mind telling me how to do this.


Source: (StackOverflow)

Advertisements

How to split a 16 bit value into two 8 bit values in vb.net?

i have a 16 bit value like this:

 0000000000000011

i want to split this in two 8 bit values like :

 00000000    and    00000011

the 16 bit value is a variable byte_val1 which is a unsigned 16 bit integer

how can i do this in vb.net pls help me


Source: (StackOverflow)

Long integer in fortran95 - SELECT_INT_KIND error

I get an error message for compiling a f95 program:

$ gfortran test_SELECT_REAL_KIND.f90
test_SELECT_REAL_KIND.f90:148.23:
tINTEGER_12=12345678911
                       1
Error: Integer too big for its kind at (1). This check can be disabled with the option -fno-range-check

The programm looks like test_SELECT_REAL_KIND.f90:

program test

IMPLICIT NONE
real :: r
r = 4.34


call test_sel_real_kind()
call test_sel_int_kind()
call test_sel_real_kind_on_int()


contains




subroutine test_sel_real_kind()
IMPLICIT NONE

INTEGER, PARAMETER :: LONG1 = SELECTED_REAL_KIND(p=1)
INTEGER, PARAMETER :: LONG2 = SELECTED_REAL_KIND(p=2)
INTEGER, PARAMETER :: LONG3 = SELECTED_REAL_KIND(p=3)
INTEGER, PARAMETER :: LONG4 = SELECTED_REAL_KIND(p=4)
INTEGER, PARAMETER :: LONG5 = SELECTED_REAL_KIND(p=5)
INTEGER, PARAMETER :: LONG6 = SELECTED_REAL_KIND(p=6)
INTEGER, PARAMETER :: LONG7 = SELECTED_REAL_KIND(p=7)
INTEGER, PARAMETER :: LONG8 = SELECTED_REAL_KIND(p=8)
INTEGER, PARAMETER :: LONG9 = SELECTED_REAL_KIND(p=9)
INTEGER, PARAMETER :: LONG10 = SELECTED_REAL_KIND(p=10)
INTEGER, PARAMETER :: LONG11 = SELECTED_REAL_KIND(p=11)
INTEGER, PARAMETER :: LONG12 = SELECTED_REAL_KIND(p=12)

INTEGER(KIND=LONG1) :: tlong1
INTEGER(KIND=LONG2) :: tlong2
INTEGER(KIND=LONG3) :: tlong3
INTEGER(KIND=LONG4) :: tlong4
INTEGER(KIND=LONG5) :: tlong5
INTEGER(KIND=LONG6) :: tlong6
INTEGER(KIND=LONG7) :: tlong7
INTEGER*8 :: tlong8
INTEGER(KIND=LONG9) :: tlong9
INTEGER(KIND=LONG10) :: tlong10
INTEGER(KIND=LONG11) :: tlong11
INTEGER(KIND=LONG12) :: tlong12

write(*,*)' '
write(*,*)'Testing INTEGER SELECTED_REAL_KIND values '
write(*,*)' longs1 = ', tlong1,' at KIND =', LONG1
write(*,*)' longs2 = ', tlong2,' at KIND =', LONG2
write(*,*)' longs3 = ', tlong3,' at KIND =', LONG3
write(*,*)' longs4 = ', tlong4,' at KIND =', LONG4
write(*,*)' longs5 = ', tlong5,' at KIND =', LONG5
write(*,*)' longs6 = ', tlong6,' at KIND =', LONG6
write(*,*)' longs7 = ', tlong7,' at KIND =', LONG7
write(*,*)' longs8 = ', tlong8,' at KIND =', LONG8
write(*,*)' longs9 = ', tlong9,' at KIND =', LONG9
write(*,*)' longs10 = ', tlong10,' at KIND =', LONG10
write(*,*)' longs11 = ', tlong11,' at KIND =', LONG11
write(*,*)' longs12 = ', tlong12,' at KIND =', LONG12
write(*,*)' '

end subroutine test_sel_real_kind




subroutine test_sel_real_kind_on_int()
IMPLICIT NONE
INTEGER, PARAMETER :: LONG1 = SELECTED_real_KIND(p=1)
INTEGER, PARAMETER :: LONG2 = SELECTED_real_KIND(p=2)
INTEGER, PARAMETER :: LONG3 = SELECTED_real_KIND(p=3)
INTEGER, PARAMETER :: LONG4 = SELECTED_real_KIND(p=4)
INTEGER, PARAMETER :: LONG5 = SELECTED_real_KIND(p=5)
INTEGER, PARAMETER :: LONG6 = SELECTED_real_KIND(p=6)
INTEGER, PARAMETER :: LONG7 = SELECTED_real_KIND(p=7)
INTEGER, PARAMETER :: LONG8 = SELECTED_real_KIND(p=8)
INTEGER, PARAMETER :: LONG9 = SELECTED_real_KIND(p=9)
INTEGER, PARAMETER :: LONG10 = SELECTED_real_KIND(p=10)
INTEGER, PARAMETER :: LONG11 = SELECTED_real_KIND(p=11)
INTEGER, PARAMETER :: LONG12 = SELECTED_real_KIND(p=12)

REAL(KIND=LONG1) :: treal_1
REAL(KIND=LONG2) :: treal_2
REAL(KIND=LONG3) :: treal_3
REAL(KIND=LONG4) :: treal_4
REAL(KIND=LONG5) :: treal_5
REAL(KIND=LONG6) :: treal_6
REAL(KIND=LONG7) :: treal_7
REAL(KIND=LONG8) :: treal_8
REAL(KIND=LONG9) :: treal_9
REAL(KIND=LONG10) :: treal_10
REAL(KIND=LONG11) :: treal_11
REAL(KIND=LONG12) :: treal_12

!treal_12=12345678911
write(*,*)' '
write(*,*)'Testing REAL SELECTED_REAL_KIND values '
write(*,*)' treal_1 = ', treal_1
write(*,*)' treal_2 = ', treal_2
write(*,*)' treal_3 = ', treal_3
write(*,*)' treal_4 = ', treal_4
write(*,*)' treal_5 = ', treal_5
write(*,*)' treal_6 = ', treal_6
write(*,*)' treal_7 = ', treal_7
write(*,*)' treal_8 = ', treal_8
write(*,*)' treal_9 = ', treal_9
write(*,*)' treal_10 = ', treal_10
write(*,*)' treal_11 = ', treal_11
write(*,*)' treal_12 = ', treal_12
write(*,*)' '

end subroutine test_sel_real_kind_on_int



subroutine test_sel_int_kind()
IMPLICIT NONE
INTEGER, PARAMETER :: LONG1 = SELECTED_INT_KIND(1)
INTEGER, PARAMETER :: LONG2 = SELECTED_INT_KIND(2)
INTEGER, PARAMETER :: LONG3 = SELECTED_INT_KIND(3)
INTEGER, PARAMETER :: LONG4 = SELECTED_INT_KIND(4)
INTEGER, PARAMETER :: LONG5 = SELECTED_INT_KIND(5)
INTEGER, PARAMETER :: LONG6 = SELECTED_INT_KIND(6)
INTEGER, PARAMETER :: LONG7 = SELECTED_INT_KIND(7)
INTEGER, PARAMETER :: LONG8 = SELECTED_INT_KIND(8)
INTEGER, PARAMETER :: LONG9 = SELECTED_INT_KIND(9)
INTEGER, PARAMETER :: LONG10 = SELECTED_INT_KIND(10)
INTEGER, PARAMETER :: LONG11 = SELECTED_INT_KIND(11)
INTEGER, PARAMETER :: LONG12 = SELECTED_INT_KIND(12)

INTEGER(KIND=LONG1) :: tINTEGER_1
INTEGER(KIND=LONG2) :: tINTEGER_2
INTEGER(KIND=LONG3) :: tINTEGER_3
INTEGER(KIND=LONG4) :: tINTEGER_4
INTEGER(KIND=LONG5) :: tINTEGER_5
INTEGER(KIND=LONG6) :: tINTEGER_6
INTEGER(KIND=LONG7) :: tINTEGER_7
INTEGER(KIND=LONG8) :: tINTEGER_8
INTEGER(KIND=LONG9) :: tINTEGER_9
INTEGER(KIND=LONG10) :: tINTEGER_10
INTEGER(KIND=LONG11) :: tINTEGER_11
INTEGER(KIND=LONG12) :: tINTEGER_12


tINTEGER_12=12345678911

write(*,*)' '
write(*,*)'Testing INTEGER SELECTED_INT_KIND values '
write(*,*)' tINTEGER_1 = ', tINTEGER_1,' at KIND =', LONG1
write(*,*)' tINTEGER_2 = ', tINTEGER_2,' at KIND =', LONG2
write(*,*)' tINTEGER_3 = ', tINTEGER_3,' at KIND =', LONG3
write(*,*)' tINTEGER_4 = ', tINTEGER_4,' at KIND =', LONG4
write(*,*)' tINTEGER_5 = ', tINTEGER_5,' at KIND =', LONG5
write(*,*)' tINTEGER_6 = ', tINTEGER_6,' at KIND =', LONG6
write(*,*)' tINTEGER_7 = ', tINTEGER_7,' at KIND =', LONG7
write(*,*)' tINTEGER_8 = ', tINTEGER_8,' at KIND =', LONG8
write(*,*)' tINTEGER_9 = ', tINTEGER_9,' at KIND =', LONG9
write(*,*)' tINTEGER_10 = ', tINTEGER_10,' at KIND =', LONG10
write(*,*)' tINTEGER_11 = ', tINTEGER_11,' at KIND =', LONG11
write(*,*)' tINTEGER_12 = ', tINTEGER_12,' at KIND =', LONG12
write(*,*)' '

end subroutine test_sel_int_kind

end program test

If I delete the error-line, the output of the programm looks perfect:

./a.out

 Testing INTEGER SELECTED_REAL_KIND values
  longs1 =        32648  at KIND =           4
  longs2 =            0  at KIND =           4
  longs3 =      4202624  at KIND =           4
  longs4 =            0  at KIND =           4
  longs5 =           54  at KIND =           4
  longs6 =            0  at KIND =           4
  longs7 =                    54  at KIND =           8
  longs8 =       140223278864517  at KIND =           8
  longs9 =       140735383116288  at KIND =           8
  longs10 =   7595935609892856681  at KIND =           8
  longs11 =       140735383119738  at KIND =           8
  longs12 =                     7  at KIND =           8


 Testing INTEGER SELECTED_INT_KIND values
  tINTEGER_1 =     0  at KIND =           1
  tINTEGER_2 =     0  at KIND =           1
  tINTEGER_3 =       0  at KIND =           2
  tINTEGER_4 =      64  at KIND =           2
  tINTEGER_5 =            0  at KIND =           4
  tINTEGER_6 =           54  at KIND =           4
  tINTEGER_7 =            0  at KIND =           4
  tINTEGER_8 =           32  at KIND =           4
  tINTEGER_9 =            0  at KIND =           4
  tINTEGER_10 =   7595935609892856681  at KIND =           8
  tINTEGER_11 =       140735383119738  at KIND =           8
  tINTEGER_12 =                     7  at KIND =           8


 Testing REAL SELECTED_REAL_KIND values
  treal_1 =   4.57495923E-41
  treal_2 =    0.0000000
  treal_3 =   5.88913056E-39
  treal_4 =    0.0000000
  treal_5 =   7.56701171E-44
  treal_6 =    0.0000000
  treal_7 =   2.66795448754273134E-322
  treal_8 =   6.92795048341748080E-310
  treal_9 =   6.95325179520640954E-310
  treal_10 =   6.26338127621884380E+199
  treal_11 =   6.95325179537686219E-310
  treal_12 =   3.45845952088872581E-323

So why the do I get this error? Could you try it on your machine please and give me some background information on the error? It would be great!


Source: (StackOverflow)

Charset to save binary data

Is there charset which I could use to save 8bit data? I mean everything which is binary, without changing it content in string?


Source: (StackOverflow)

Perl Decimal to Binary 32-bit then 8-bit

I've got a number (3232251030) that needs to be translated from Decimal to Binary. Once I've gotten the binary, I need to separate 8-bits of it into digits, revealing an ip address.

Converting Decimal to Binary is simple:

sub dec2bin { my $str = unpack("B32", pack("N", shift)); $str =~ s/^0+(?=\d)//; # otherwise you'll get leading zeros return $str; }

sub bin2dec { return unpack("N", pack("B32", substr("0" x 32 . shift, -32))); }

e.g. $num = bin2dec('0110110'); # $num is 54 $binstr = dec2bin(54); # $binstr is 110110

Reference: http://www.perlmonks.org/?node_id=2664

So now, I need to split 8 digits off the binary and save it into numbers that makes an IP address.

$num = dec2bin('3232251030');

($num is "11000000 10101000 01000100 00001110" in binary)

I need to split and save each 8-bits "11000000 10101000 01000100 00001110" into "192.168.60.150".

Care to advice? I'm looking into split function for this..


Source: (StackOverflow)

Assembly , Move an 8 bit register to a 16 bit Register , how?

what i want to know is obviously said on the topic. i have problem moving 8 bit register to a 16 bit register . what i'm trying to do is to , divide a number permanently by 10 til it gets lower than 10 , and , within each division time , i try to move out the remained part of the division out from ah register , add 48 to it, then i could have its Ascii code , then i try to show the digit i got , on screen . here is the code :

 Num1 DW 255
 DIVISION :
        CMP NUM1,10
            Jl DIVEND

        MOV AX,10
        DIV NUM1
        MOV NUM1,AL ;*


        ADD AH,48
        MOV DL,AH; 
        MOV AH,02H
        INT 21H

    JMP DIVISION

but , when im trying to assemble it , it says , Operand types do not match on the line indicated by * . im using turbo assembler V4.1 ... what should i do ?


Source: (StackOverflow)

8-bit FFT for CPU architectures?

I am looking for an FFT engine that can handle 8-bit real to complex transforms (of size 65K). The need for this is to accelerate a real-time signal processing engine. It is currently limited by 8-bit -> FP32 and FP32 -> 8-bit conversions, as well as the actual FFT being memory bandwidth bound (we're using FFTW at the moment).

I thought that the Spiral project might be able to do this http://spiral.net, but the only code that seems to be available on their webpage is for single or double transforms.

Anyone know of any C or C++ libraries that can do this?


Source: (StackOverflow)

How to convert 24 bit RGB to 8 bit RGB

I was wondering what is the best way to convert a 24-bit RGB color (8 bits per color) into an 8-bit color (2bits Blue, 3 Green, 3 Red). I'd like C code for doing this.


Source: (StackOverflow)

Difference between C 8 bit 16-bit 32-bit compilers [closed]

This question may be redundant, but I didn't found exact answer.

What is the Difference between C 8 bit 16-bit 32-bit compilers.

how the .exe differ generated by different compilers for same code...........


Source: (StackOverflow)

How do 8 bit and 16 processors access more ram with two registers?

Something that has always confused me is how 8 bit computers access more than 256 bytes of RAM. I know that it must use two registers, but can any one show me an example of what this would look like in assembly code?

Like:

mov a, [x]   ???

Source: (StackOverflow)

What is an 8-bit register on a desktop cpu?

Reading through the following instruction table manual I see that integer multiplication is often much faster for 8-bit registers.

In the context of a normal desktop cpu, what does 8-bit register mean? That the value stored within ie a 32-bit register simply happens to be within an 8-bit range? There aren't actual 8-bit registers, right?


Source: (StackOverflow)

Address 0 being overwritten by NULL pointer on HCS08

On my 8-bit Freescale HCS08 micro, whenever I call a library function that returns values to pointers I pass it, and I don't really want them, I threw in a NULL, e.g.

UART_SendBlock((char *)txstr, strlen(txstr), NULL);

The type of the last argument is uint16_t * and returns the number of characters actually sent, a value I don't care about.

However, I was having problems with port A on my micro being hosed every time that function was called, and debugging pointed me to that argument screwing things up. Port A's configuration registers live at addresses 0x0000 and 0x0001, which is where NULL (aka (void *)0) points. I thought NULL was somehow magic where it wouldn't actually do anything, but it doesn't seem so.

My workaround feels really hack:

#define MNUL (void *)(&mynull)
uint32_t mynull;

Is there a better solution? I tried defining MNUL to an unused segment of memory on my processor, but that causes an immediate reset.


Source: (StackOverflow)

creating a custom getColor(byte r, byte g, byte b) method

i have a simple byte array that i want to take colours from. My plan was to have three bits from red, three bits for green, and two bits for blue. 8-bit.

I think the colours are right:

Please correct me if i'm wrong,

 byte[] colours = new byte[256]; //256 different colours, 8 * 8 * 4 
                                 //(3 bits(red) + 3 bits(green) + 2 bits(blue)
 int index = 0;
 for(byte r = 0; r < 8; r++){ 
    for(byte g = 0; g < 8; g++){
       for(byte b = 0; b < 4; b++){
           byte rr = (r & 255);
           byte gg = (g & 255);
           byte bb = (b & 255);
           colours[index++] = (rr << 5 | gg << 2 | bb);   
       }
   }
}

My goal is to make a getColor(byte r, byte g, byte b) like

public static byte getColor(byte r, byte g, byte b){
    return colours[return the right color using r g b];
}

But i don't know how. Here's where i need help.

I would like to rather not use the Color class if it's possible.

Other information: I'm using a BufferedImage.TYPE.BYTE.INDEXED to paint on.

Sorry if my english is bad :)

EDIT Fixed where it was wrong


Source: (StackOverflow)

tinyAVR: best known multiplication routines for 8-bit and 16-bit factors? [closed]

"Faster than avr200b.asm"? The mpy8u-routine from avr200b.asm for those processors of Atmel's AVR family that do not implement any of the MUL instructions seems pretty generic, but mpy16u looks sloppy for rotating both lower result bytes 16 times instead of 8. Antonio presented a fast 16×16→16 unsigned multiplication using 64 cycles worst case excluding call/return overhead.
I arbitrarily suggest as optimisation goals worst case cycle count, word count (RAM and flash), register usage, and expected cycle count in order of decreasing priority.
(There are reduced core AVRs ("single digit"-ATtiny, 10/20/40) with differences including timing, which I suggested to ignore.)

(Caution: Don't take any claim herein for granted, at least not without independent affirmation.)

What are best currently known 8×8→8/16, 16×16→16/32 and 16×8→16/24 bit multiplication routines for AVRs without MUL?


Source: (StackOverflow)