From: Jacob Fugal Date: 2006-07-29T08:10:35+09:00 Subject: Re: [QUIZ] Chip-8 (#88) On 7/28/06, Ethan Price wrote: > On 7/28/06, Jacob Fugal wrote: > > On 7/28/06, Daniel Martin wrote: > > > Opcode 0100 will send you back to the beginning, so that the next > > > instruction read and executed is the first instruction of the file. > > > Opcode 0102 will send you back to the second instruction in the file > > > (remember that instructions are four hex digits - or two bytes - > > > long). Other addresses follow. > > > > So, should an absolute jump to N make it so that the Nth (0-based > > index) instruction is the next executed, or the (N+1)th? You're > > example above seems to put it both ways. 1000 sends you back to the > > beginning, so the "0th" instruction (first instruction in the file) is > > the next executed. But then 1002 should make it so that the "2nd" > > instruction (third instruction in the file) is the next executed, > > right? Maybe this is what you meant by "second" anyways... > > Here is how it is supposed to work. Say we have a file that reads in hex: > 1234ABCD5678 > Opcode 1000 would send us to before 1234, so after jumping the first > instruction we would read is 1234. Opcode 1002 would send us to after 1234 > and before ABCD (were moving forward 2 bytes, which equals 4 hex digits > worth of data). 1004 would send us to after ABCD and before 5678, and so on. Ah, gotcha. I was thinking in instruction addressing, rather than memory addressing. That probably reflects the fact that I read and decompile all the instructions before beginning execution. This makes sense now. So, regarding the initial quiz description, 100F would send us F (15) bytes forward from the start of the file, or only 7.5 instructions, and you'd have your instruction pointer in the middle of an instruction. Is that valid? Or was it indeed a typo as Daniel suggested? Jacob Fugal