Hey guys,
what I've measured is actually only the time to execute that function.
@Brendan, yes madanra is right, as I said it's currently about 3ms faster with the dword-access, due to less memory writes.
I compiled it twice for simplicity, when writing to 32bits its:
Code: Select all
080597ea <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)>:
80597ea: 55 push %ebp
80597eb: 89 e5 mov %esp,%ebp
80597ed: 83 ec 20 sub $0x20,%esp
80597f0: 8b 45 0c mov 0xc(%ebp),%eax
80597f3: 8b 50 04 mov 0x4(%eax),%edx
80597f6: 8b 45 08 mov 0x8(%ebp),%eax
80597f9: 0f b7 40 0a movzwl 0xa(%eax),%eax
80597fd: 0f b7 c0 movzwl %ax,%eax
8059800: 0f af c2 imul %edx,%eax
8059803: 89 c2 mov %eax,%edx
8059805: 8b 45 08 mov 0x8(%ebp),%eax
8059808: 8b 40 0c mov 0xc(%eax),%eax
805980b: 01 d0 add %edx,%eax
805980d: 89 45 fc mov %eax,-0x4(%ebp)
8059810: 8b 45 0c mov 0xc(%ebp),%eax
8059813: 8b 10 mov (%eax),%edx
8059815: 8b 45 0c mov 0xc(%ebp),%eax
8059818: 8b 40 08 mov 0x8(%eax),%eax
805981b: 01 d0 add %edx,%eax
805981d: 89 45 f0 mov %eax,-0x10(%ebp)
8059820: 8b 45 0c mov 0xc(%ebp),%eax
8059823: 8b 50 04 mov 0x4(%eax),%edx
8059826: 8b 45 0c mov 0xc(%ebp),%eax
8059829: 8b 40 0c mov 0xc(%eax),%eax
805982c: 01 d0 add %edx,%eax
805982e: 89 45 ec mov %eax,-0x14(%ebp)
8059831: 8b 45 0c mov 0xc(%ebp),%eax
8059834: 8b 40 04 mov 0x4(%eax),%eax
8059837: 89 45 f8 mov %eax,-0x8(%ebp)
805983a: eb 5d jmp 8059899 <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0xaf>
805983c: 8b 45 fc mov -0x4(%ebp),%eax
805983f: 89 45 e8 mov %eax,-0x18(%ebp)
8059842: 8b 45 0c mov 0xc(%ebp),%eax
8059845: 8b 00 mov (%eax),%eax
8059847: 89 45 f4 mov %eax,-0xc(%ebp)
805984a: eb 34 jmp 8059880 <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0x96>
805984c: 8b 45 f4 mov -0xc(%ebp),%eax
805984f: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
8059856: 8b 45 e8 mov -0x18(%ebp),%eax
8059859: 01 c2 add %eax,%edx
805985b: 8b 45 10 mov 0x10(%ebp),%eax
805985e: 8b 40 08 mov 0x8(%eax),%eax
8059861: 0f af 45 f8 imul -0x8(%ebp),%eax
8059865: 89 c1 mov %eax,%ecx
8059867: 8b 45 f4 mov -0xc(%ebp),%eax
805986a: 01 c8 add %ecx,%eax
805986c: 8d 0c 85 00 00 00 00 lea 0x0(,%eax,4),%ecx
8059873: 8b 45 14 mov 0x14(%ebp),%eax
8059876: 01 c8 add %ecx,%eax
8059878: 8b 00 mov (%eax),%eax
805987a: 89 02 mov %eax,(%edx)
805987c: 83 45 f4 01 addl $0x1,-0xc(%ebp)
8059880: 8b 45 f4 mov -0xc(%ebp),%eax
8059883: 3b 45 f0 cmp -0x10(%ebp),%eax
8059886: 72 c4 jb 805984c <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0x62>
8059888: 8b 45 08 mov 0x8(%ebp),%eax
805988b: 0f b7 40 0a movzwl 0xa(%eax),%eax
805988f: 0f b7 c0 movzwl %ax,%eax
8059892: 01 45 fc add %eax,-0x4(%ebp)
8059895: 83 45 f8 01 addl $0x1,-0x8(%ebp)
8059899: 8b 45 f8 mov -0x8(%ebp),%eax
805989c: 3b 45 ec cmp -0x14(%ebp),%eax
805989f: 72 9b jb 805983c <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0x52>
80598a1: c9 leave
80598a2: c3 ret
80598a3: 90 nop
With 24 bits, its:
Code: Select all
080597ea <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)>:
80597ea: 55 push %ebp
80597eb: 89 e5 mov %esp,%ebp
80597ed: 83 ec 20 sub $0x20,%esp
80597f0: 8b 45 0c mov 0xc(%ebp),%eax
80597f3: 8b 50 04 mov 0x4(%eax),%edx
80597f6: 8b 45 08 mov 0x8(%ebp),%eax
80597f9: 0f b7 40 0a movzwl 0xa(%eax),%eax
80597fd: 0f b7 c0 movzwl %ax,%eax
8059800: 0f af c2 imul %edx,%eax
8059803: 89 c2 mov %eax,%edx
8059805: 8b 45 08 mov 0x8(%ebp),%eax
8059808: 8b 40 0c mov 0xc(%eax),%eax
805980b: 01 d0 add %edx,%eax
805980d: 89 45 fc mov %eax,-0x4(%ebp)
8059810: 8b 45 0c mov 0xc(%ebp),%eax
8059813: 8b 10 mov (%eax),%edx
8059815: 8b 45 0c mov 0xc(%ebp),%eax
8059818: 8b 40 08 mov 0x8(%eax),%eax
805981b: 01 d0 add %edx,%eax
805981d: 89 45 f0 mov %eax,-0x10(%ebp)
8059820: 8b 45 0c mov 0xc(%ebp),%eax
8059823: 8b 50 04 mov 0x4(%eax),%edx
8059826: 8b 45 0c mov 0xc(%ebp),%eax
8059829: 8b 40 0c mov 0xc(%eax),%eax
805982c: 01 d0 add %edx,%eax
805982e: 89 45 ec mov %eax,-0x14(%ebp)
8059831: 8b 45 0c mov 0xc(%ebp),%eax
8059834: 8b 40 04 mov 0x4(%eax),%eax
8059837: 89 45 f8 mov %eax,-0x8(%ebp)
805983a: e9 90 00 00 00 jmp 80598cf <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0xe5>
805983f: 8b 45 0c mov 0xc(%ebp),%eax
8059842: 8b 00 mov (%eax),%eax
8059844: 89 45 f4 mov %eax,-0xc(%ebp)
8059847: eb 6d jmp 80598b6 <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0xcc>
8059849: 8b 45 10 mov 0x10(%ebp),%eax
805984c: 8b 40 08 mov 0x8(%eax),%eax
805984f: 0f af 45 f8 imul -0x8(%ebp),%eax
8059853: 89 c2 mov %eax,%edx
8059855: 8b 45 f4 mov -0xc(%ebp),%eax
8059858: 01 d0 add %edx,%eax
805985a: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
8059861: 8b 45 14 mov 0x14(%ebp),%eax
8059864: 01 d0 add %edx,%eax
8059866: 8b 00 mov (%eax),%eax
8059868: 89 45 e8 mov %eax,-0x18(%ebp)
805986b: 8b 55 f4 mov -0xc(%ebp),%edx
805986e: 89 d0 mov %edx,%eax
8059870: 01 c0 add %eax,%eax
8059872: 01 d0 add %edx,%eax
8059874: 89 c2 mov %eax,%edx
8059876: 8b 45 fc mov -0x4(%ebp),%eax
8059879: 01 d0 add %edx,%eax
805987b: 8b 55 e8 mov -0x18(%ebp),%edx
805987e: 88 10 mov %dl,(%eax)
8059880: 8b 55 f4 mov -0xc(%ebp),%edx
8059883: 89 d0 mov %edx,%eax
8059885: 01 c0 add %eax,%eax
8059887: 01 d0 add %edx,%eax
8059889: 8d 50 01 lea 0x1(%eax),%edx
805988c: 8b 45 fc mov -0x4(%ebp),%eax
805988f: 01 d0 add %edx,%eax
8059891: 8b 55 e8 mov -0x18(%ebp),%edx
8059894: c1 ea 08 shr $0x8,%edx
8059897: 88 10 mov %dl,(%eax)
8059899: 8b 55 f4 mov -0xc(%ebp),%edx
805989c: 89 d0 mov %edx,%eax
805989e: 01 c0 add %eax,%eax
80598a0: 01 d0 add %edx,%eax
80598a2: 8d 50 02 lea 0x2(%eax),%edx
80598a5: 8b 45 fc mov -0x4(%ebp),%eax
80598a8: 01 d0 add %edx,%eax
80598aa: 8b 55 e8 mov -0x18(%ebp),%edx
80598ad: c1 ea 10 shr $0x10,%edx
80598b0: 88 10 mov %dl,(%eax)
80598b2: 83 45 f4 01 addl $0x1,-0xc(%ebp)
80598b6: 8b 45 f4 mov -0xc(%ebp),%eax
80598b9: 3b 45 f0 cmp -0x10(%ebp),%eax
80598bc: 72 8b jb 8059849 <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0x5f>
80598be: 8b 45 08 mov 0x8(%ebp),%eax
80598c1: 0f b7 40 0a movzwl 0xa(%eax),%eax
80598c5: 0f b7 c0 movzwl %ax,%eax
80598c8: 01 45 fc add %eax,-0x4(%ebp)
80598cb: 83 45 f8 01 addl $0x1,-0x8(%ebp)
80598cf: 8b 45 f8 mov -0x8(%ebp),%eax
80598d2: 3b 45 ec cmp -0x14(%ebp),%eax
80598d5: 0f 82 64 ff ff ff jb 805983f <vbe_video_output_t::blit(g_rectangle, g_rectangle, unsigned int*)+0x55>
80598db: c9 leave
80598dc: c3 ret
80598dd: 90 nop
@gerryg400 nice ideas. For the first point, I already blit everything to a "screen buffer", of which only the portions that changed are blitted out to the video output. I'll implement point two and see how it impacts performance, I think that could make a big difference.
Thanks for your suggestions!
Greets