flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Distinguish between 8, 16, and 32 bit registers

Author
Thread Post new topic Reply to topic
rCX



Joined: 29 Jul 2007
Posts: 172
Location: Maryland, USA
rCX 13 Jul 2021, 01:48
Is there a way to distinguish between registers of different sizes? For example the following code

Code:
macro type A
{
    if A eqtype al
        display "8-bit",13,10
    end if

    if A eqtype ax
        display "16-bit",13,10
    end if
}

type ax    


Results in

Code:
8-bit
16-bit    
Post 13 Jul 2021, 01:48
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 13 Jul 2021, 04:37
Code:
macro type A {
    if A eqtype al
        virtual
            mov A,0
            i = 0
            while 1
                load C byte from $ - i - 1
                if C <> 0
                    break
                end if
                i = i + 1
            end while
        end virtual

        if i = 1
            display "8-bit",13,10
        else if i = 2
            display "16-bit",13,10
        else if i = 4
            display "32-bit",13,10
        end if
    end if
}    

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 13 Jul 2021, 04:37
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20448
Location: In your JS exploiting you and your system
revolution 13 Jul 2021, 07:59
Perhaps it is more typing, but it is also more explicit, so I think I would be more inclined to use in.
Code:
use64
if A in <al,bl,cl,dl,sil,dil,r8b,...>
  display '8-bit',13,10
else if A in <ax,bx,cx,...>
  ...
end if    
Post 13 Jul 2021, 07:59
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 13 Jul 2021, 12:08
In the 64-bit case it is more correct to use in.
(fasmg no have in, but there are other tricks.)

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 13 Jul 2021, 12:08
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.