Author Topic: more efficient coding suggestions  (Read 858 times)

0 Members and 1 Guest are viewing this topic.

Offline bgjnat56

  • New Member
  • Posts: 4
more efficient coding suggestions
« on: 2012-06-20 00:41:56 »
The program is NEARLY finished but i want to see if any of you can suggest methods of making it more efficient or maybe just alternate ways of doing the same thing. I dont care how. I just want to see what I can learn from your "tricks".

Finally was admitted to the site so this is my first post! But ive learned so much from this site, ive been stalking posts for some time :)

If you have any questions check the commenting. I was trying to be as clear and precise as possible, so i could explain to my understudied partner what i was doing.

Offline bgjnat56

  • New Member
  • Posts: 4
Re: more efficient coding suggestions
« Reply #1 on: 2012-06-20 16:38:22 »
here is the finalized code still not very efficient.

Offline Homer

  • ObjAsm32 Developer
  • Community Staff
  • ASM Fanatic
  • *****
  • Posts: 4617
  • Country: au
Re: more efficient coding suggestions
« Reply #2 on: 2012-06-21 05:50:27 »
When you decide to optimize some code, you have to decide if you want speed, or size, because you can't have both.... they are competing paradigms. You can choose opcodes with the smallest encodings for a smaller binary, or you can choose longer encodings which you know execute faster (on some particular hardware). Trying to get the best of both worlds is usually a bad idea that gains you nothing.
In C++, friends have access to your private members.
In ObjAsm, your members are exposed!

Offline bgjnat56

  • New Member
  • Posts: 4
Re: more efficient coding suggestions
« Reply #3 on: 2012-06-21 22:19:48 »
Aah the legendary Homer! Thanks for the input, I was aspiring for shorter code length. I think I have found a way to do this though. So I'm going to try and eliminate some length especially in the main function. (going to use register dx to store offsets in memory and load them into functions). Good idea? better idea?

well aren't macro's kind of best of both worlds? They are faster than proc's you save lines writing codes too..... But i am just starting out so i may be missing something.

Offline Scali

  • ASM Fanatic
  • ****
  • Posts: 1413
    • http://sourcevault.scali.eu.org
Re: more efficient coding suggestions
« Reply #4 on: 2012-06-22 14:23:22 »
The potential downside of macros is that the code is duplicated for every instance.
So a proc might result in considerably smaller code.

Offline bgjnat56

  • New Member
  • Posts: 4
Re: more efficient coding suggestions
« Reply #5 on: 2012-06-26 16:56:37 »
I see... thanks everyone for the input.

Offline MikDay

  • ASM Supporter
  • *
  • Posts: 24
Re: more efficient coding suggestions
« Reply #6 on: 2012-07-02 21:35:24 »
1. The instructions
xor ax,ax
xor dx,dx
at the begin of program are useful and may be deleted
2.
        mov ah, 07          ;PARAMETERS TO CLEAR SCREEN
        mov al, 0
may be replaced by "mov ax,700h"

3.
       mov dh, 24
        mov dl, 79
may be replaced by "mov dx,184Fh"

4. mov cx,0 => to xor cx,cx