Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - C and Assembler

Reply to topic
Author Message
Chris
  • Guest
Reply with quote
C and Assembler
Post Posted: Tue Jul 06, 1999 4:19 am
I know that Assembler is way faster than C alone but is it a waste of time to do stuff like this:

asm{
mov ax, z80.bc
mov bx, z80.de
add ax, bx
mov z80.bc, ax
}

intead of simply writing...
z80.bc += z80.de

And be done with it? The reason why I'm writing my own Z80 CPU core instead of using Marat's
or anyone elses is because I like things fast and accurate. I don't want to waste hours studying
someone else's functions and codes just to use the damn thing nor do I want to use Marat's core
and wind up with a slow emu. But at any rate I want to speed up development and accuracy
with my Z80 emulator. Any suggestions?

Chris :o)

 
ziggy880
  • Guest
Reply with quote
Post Posted: Tue Jul 06, 1999 10:19 am

Quote
> I know that Assembler is way faster than C alone but is it a waste of time to do stuff like this:

> asm{
> mov ax, z80.bc
> mov bx, z80.de
> add ax, bx
> mov z80.bc, ax
> }

> intead of simply writing...
> z80.bc += z80.de

> And be done with it? The reason why I'm writing my own Z80 CPU core instead of using Marat's
> or anyone elses is because I like things fast and accurate. I don't want to waste hours studying
> someone else's functions and codes just to use the damn thing nor do I want to use Marat's core
> and wind up with a slow emu. But at any rate I want to speed up development and accuracy
> with my Z80 emulator. Any suggestions?

> Chris :o)
>

Its been discussed before the amount of speed youll achieve by writing the processor emulator in asm
is normally fairly minimal but it does help to know asm when you are writing it to better understand what
your code is doing and if its wasting anything here or there
 
Eric
  • Guest
Reply with quote
Post Posted: Tue Jul 06, 1999 8:00 pm
Quote
> I know that Assembler is way faster than C alone but is it a waste of time to do stuff like this:

> asm{
> mov ax, z80.bc
> mov bx, z80.de
> add ax, bx
> mov z80.bc, ax
> }

> intead of simply writing...
> z80.bc += z80.de

> And be done with it? The reason why I'm writing my own Z80 CPU core instead of using Marat's
> or anyone elses is because I like things fast and accurate. I don't want to waste hours studying
> someone else's functions and codes just to use the damn thing nor do I want to use Marat's core
> and wind up with a slow emu. But at any rate I want to speed up development and accuracy
> with my Z80 emulator. Any suggestions?

There's a good chance that " z80.bc += z80.de" will simply compile into something equivalent to the assembly code you used above. The best way to check is see if your compiler will generate an assembly file. Then you can see how your C code is being compiled.

Also, if you're using 32-bit assembly-language, avoid using the 16-bit registers, as the size-overrides can eat up performance. Only use the 32-bit and 8-bit registers in 32-bit mode.

Finally, the x86 can add a register and a memory operand. You may be able to combine the last two lines of your code into one, depending on how z80.bc is addressed.

Eric
 
Chris
  • Guest
Reply with quote
I think you're right again
Post Posted: Wed Jul 07, 1999 5:05 am
Quote
> There's a good chance that " z80.bc += z80.de" will simply compile into something equivalent to the assembly code you used above. The best way to check is see if your compiler will generate an assembly file. Then you can see how your C code is being compiled.

> Also, if you're using 32-bit assembly-language, avoid using the 16-bit registers, as the size-overrides can eat up performance. Only use the 32-bit and 8-bit registers in 32-bit mode.

> Finally, the x86 can add a register and a memory operand. You may be able to combine the last two lines of your code into one, depending on how z80.bc is addressed.

> Eric

I did the "generate Asm source" in Borland C++ and it showed something similar to my assembler. But
why is the Generated ASM source so messy??? I'd rather just compile it and not know what my program
is doing. As long as it can send values back and fourth like the real system I'm all game.

Aww man. Can you believe how many combinations there are for simple bit instructions!!?? Set 0-7
bits for register A-L. Then you got Bit 0-7 for register A-L which checks the status of the bit. And then
you got Res 0-7 bits for resiger A-L which sets the bit to one. That's another 100 lines easy right there.

Chris :o)
 
Reply to topic



Back to the top of this page

Back to SMS Power!