Optimizing multiple conditionals? (specifically modern CPUs)

You can talk about almost anything that you want to on this board.

Moderator: Moderators

calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Optimizing multiple conditionals? (specifically modern C

Post by calima »

POWER9 was released 2017 and POWER10 is coming next year. Someone forgot to tell it it's dead :P
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Optimizing multiple conditionals? (specifically modern C

Post by tepples »

Is "defunct in devices intended for home and small business use" more honest?
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Optimizing multiple conditionals? (specifically modern C

Post by calima »

My Blackbird begs to differ.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Optimizing multiple conditionals? (specifically modern C

Post by Drew Sebastino »

I finally found (or made, rather) a way to find the size of an argument in NASM:

Code: Select all

%macro find_argument_size 1
  %defstr argument %1
  
  %substr test argument 1,4
  %if test ==   'byte'
  %define size  'byte'
  %elif test == 'word'
  %define size  'word'
  %else
    %substr test argument 1,5
    %if test ==   'dword'
    %define size  'dword'
    %elif test == 'qword'
    %define size  'qword'
  
  
    %else
      %substr test argument 1,2
      %if test == 'si' || test == 'di' || test == 'bp' || test == 'sp'
        %substr test argument 3,1
        %if test ==  'l'
        %define size 'byte'
        %else
        %define size 'word'
        %endif
  
  
      %else
        %substr test argument 1,1
        %if test == 'a' || test == 'b' || test == 'c' || test == 'd'
          %substr test argument 2,1
          %if test ==  'x'
          %define size 'word'
          %else
          %define size 'byte'
          %endif
  
  
        %elif test == 'e'
        %define size  'dword'
  
  
        %elif test == 'r'
          %substr test argument 3,1
          %if test ==   'b'
          %define size  'byte'
          %elif test == 'w'
          %define size  'word'
          %elif test == 'd'
          %define size  'dword'
		  %else
            %substr test argument 4,1
            %if test == 'b'
            %define size  'byte'
            %elif test == 'w'
            %define size  'word'
            %elif test == 'd'
            %define size  'dword'
            %else
            %define size  'qword'
            %endif
          %endif
        %endif
      %endif
    %endif
  %endif
%endmacro
It's pretty ugly though... :lol: I didn't implement segment registers, but I really don't see that being a problem. However, it only works with lowercase; I don't know if there is some existing functionality to convert to uppercase or lowercase, but if there isn't, I can easily make a solution.

Does anyone know if there is a good website for posting code like this? (I'm not counting github; I think that's more geared toward projects and not code snippets, and it isn't x86 assembly oriented) I figure this could be useful for other assembly programmers. If not, as I now know, web hosting is cheap, lol.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Optimizing multiple conditionals? (specifically modern C

Post by tepples »

GitHub has a "Gist" service for single-file repositories.
Post Reply