Sorenson,
That was useful! By returning the pointer do you mean something like:
#include <stdio.h>
#include <string.h>
char *change (){
Type: Posts; User: wavering
Sorenson,
That was useful! By returning the pointer do you mean something like:
#include <stdio.h>
#include <string.h>
char *change (){
"ASM is not going to be faster than simple bit shifting. If it is, it's minutely so:"
I can only answer for my compiler ( MSVC++ ) and having done careful timings I find that if I need to do TWO...
There is a standard C function for powers, so for square root use:
answer = pow(number,(double)(1)/2);
For tenth root it would be:
answer = pow(number,(double)(1)/10);
Not sure if you...
"What is inline asm?"
Ah! Right. I sort of assumed it was obvious but very little is obvious until you know it.
Inline asm is a facility in the C language where you can incorporate Assembly...
The reason most widely quoted is: "If you learn C you can get a good job as a programer"
To me this is the worst reason to do anything. I love C because it has enormous flexibility and you can get...
Many thanks Bubba!
See you there! From a quick glance it looks just the job ...
Here is how VC++6 disassembles:
403: code[liner][1] >>= 13;
//Shift 13 "bits" to extreme right ..
004027C7 mov edx,dword ptr [ebp-0Ch]
004027CA and ...
I own over 30 books on C bought over many years - intending one day to read them! In total I guess they contain about twenty ( at the most ) pages on inline C. I guess it is not a very fashionable...
I realise that I bang on rather about inline asm but it is the only reason I have bothered to learn C. Or, to be more precise, I have learned C because some things are just too laborious to do in...
Nutshell
You can use asm in C very simply. To take an example from the program I am working on.
C Instruction:
liner++;
We all know this increases the value of liner by one. When I look...
I actually use a single short ( ie 16 bit ) integer to store six pieces of information in my program. To extract them I shift left then right rather than use a mask ( whether it is quicker I don't...
Thanks Shiro
I take your point but what I was trying to do was avoid a situation where I have to test for all sorts of possible conditions, thereby slowing my ( time critical ) program down. I...
This has solved a problem for me, many thanks. I need to carry on if my prog divides by zero and this works ... on MSVC++ compiler ( But I am writing in C - works on both C and C++)
#include...
Thanks everybody for your help.
I don't know how many people are interested in speed of execution and/or inline asm but for those who are, here is a part disassembly of the switch statement...
Thanks sayeh
>Use the 'register' keyword on your variables.
Yup - done that already
>Another thing is to make all your variables 32-bits (even if you only count from 1-10). This way the...
Unregistered,
Firstly, concerning the original code I posted I should have pointed out that each of the eight cases of the switch IS visited as j%8 ( ie j Mod 8 ) cycles between 0 to 7 and back...
Salem and Unregistered
Thanks for the replies. The code example is NOT part of a real program as it achieves absolutely nothing! It specifically featured "switch()" as this is a crucial element in...
Many thanks Salem - especially for pointing out my crass error in not setting j at zero. First part of code should read:
long j = 0;
My revised timings using QuickC 2.51 after correcting the...
Thanks Shiro. My question re XP was badly worded but was ( maybe ) clear from what went before. It should have read:
Q1. Why is there no speed increase when I run the program on a machine which...
Many thanks for the answers. Before re-writing for a 32 bit windows compiler I would be very grateful if people could compile the test program below and see how long it takes on various systems. I'm...
I am very new to C but have written a program in C with quite a lot of inline assembly code as speed is crucial. I am using QuickC version 2.51 which is a very old DOS based program but run in an...
Many thanks Sayeh,
Yes - I use 50 lines of asm because it is quicker not because I have nothing else to do!
I take your comments re the cache but I am just going on timings and what I have done...
Having derived great benefit from this board ( mostly via the search facility ) while I learn C I thought I would write something on inline asm. I started using C because I needed to rewite an...
Thanks Stoned_Coder. Am using DOS based ( QuickC 2.51 ) system. Have only just looked at your post and have meanwhile solved problem as below:
gotoxy(int x,int y) //Declare Function gotoxy
...
Thanks C_Coder but I am trying to write an ultra fast routine ( so anything looping is out ) which puts updates into various locations on the screen as things change.
I need to jump instantly to...