Author Topic: A couple of quick questions regarding the flags register  (Read 14660 times)

0 Members and 1 Guest are viewing this topic.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: A couple of quick questions regarding the flags register
« Reply #30 on: September 26, 2010, 12:30:23 pm »

Yeah, I just started working on a Javascript emu. Messing with half-carry if fuuun... :P

I was working on an emu the other day too. Wouldn't this work pretty well for the half carry?

((A & 0xF) + (B & 0xF)) & 0x10

Just take the bottom nibbles of each and check for a carry out of them.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: A couple of quick questions regarding the flags register
« Reply #31 on: September 26, 2010, 12:32:28 pm »
Yeah, that's the third option I've heard of. I also saw one using two bitwise XORs, and that confused me :P

EDIT: Currently I'm using the one you just posted, but with % 0x10 instead of & 0xF. Should be the same, but took a bit to get my head around.

EDIT2: Wow, guess there are several people doing emus in JS...
« Last Edit: September 26, 2010, 12:35:50 pm by Deep Thought »




Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A couple of quick questions regarding the flags register
« Reply #32 on: September 26, 2010, 02:53:49 pm »
Nice. I wonder if this could be an united project between Netham45, you and Thepenguin77? It migth help finding optimizations and ways to make it run faster (and in all browsers except IE)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: A couple of quick questions regarding the flags register
« Reply #33 on: September 26, 2010, 03:37:11 pm »
Quote
I don't think the Z80 is modern enough to have all that prefetching and junk messing with timing. Things were a lot simpler in the 80's Tongue

Heres something to look at: http://www.ftp83plus.net/Tutorials/z80optiA.htm . You are correct, there is no prefetch on the z80. In the document he mentions the intel 8088 and I think that maybe he got confused. My information did not come from that file though, I had read it in an assembly programming book years ago. For the past hour I have been trying to find out exactly what the chip is doing. Ive read that Zilog has never released the internal sequencing to the z80 so I dont think that I can verify anything on paper. I remember reading about how if the same registers or instructions have already been fetched, the z80 will not have to fetch them for the next instruction, thus saving at least one clock cycle. Unfortunately, I dont have the book anymore.
Well, after doing a small bit of research, it seems that the Z80 has a "fetch/execute overlap" for some instructions. Source. Though, this doesn't mean that the timing will change from case-to-case. The thing is, timings are not calculated best-case scenario depending on whether the instruction has been "prefetched" or not. More likely, the timing is the number of cycles between the fetch of the current instruction and the fetch of the next instruction. That way, there is no room for debate on cycle times.

Edit: removed duplicate quote
« Last Edit: September 26, 2010, 03:37:55 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: A couple of quick questions regarding the flags register
« Reply #34 on: September 26, 2010, 08:13:24 pm »
Nice. I wonder if this could be an united project between Netham45, you and Thepenguin77? It migth help finding optimizations and ways to make it run faster (and in all browsers except IE)

I don't know JS, I was writing mine in C++. But I'm sure I could figure out quite a bit of it in a day since I'm already pretty good at C++.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: A couple of quick questions regarding the flags register
« Reply #35 on: September 26, 2010, 08:59:47 pm »
Ah ok. My big concern is getting JS to work fine in all browsers. I heard it was one hard task. In firefox, I think even good javascript threw full of errors x.x

If anyone take on such project, good luck! Btw, do you think it could be made so it runs at a decent framerate? To save bandwidth, Netham45 had to set his emu to about 3 frames a second.