flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Basic debugging macros to display values

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20302
Location: In your JS exploiting you and your system
revolution 15 Aug 2005, 14:47
Here are some basic debugging macros to help solve those difficult assembly time problems.

"display_hex??" should be self explanatory.
"display_decimal" is for signed 64 bit numbers.
"display_unsigned" is for (you guessed it) unsigned 64 bit numbers.
Code:
macro display_hex1 value {
        local nibble
        nibble=(value) and 0fh + '0'
        if nibble > '9'
           nibble=nibble+7
        end if
        display nibble
}
macro display_hex2 value {
        display_hex1 (value) shr 4
        display_hex1 value
}
macro display_hex4 value {
        display_hex2 (value) shr 8
        display_hex2 value
}
macro display_hex8 value {
        display_hex4 (value) shr 16
        display_hex4 value
}
macro display_hex16 value {
        display_hex8 (value) shr 32
        display_hex8 value
}
macro display_decimal value*,put_zeros {
    local leading_zero,digit,divisor,number
    number=value
    if number=1 shl 63
        display '-9223372036854775808'
    else
        if number<0
            number=-number
            display '-'
        end if
        leading_zero=put_zeros+0
        divisor=1000000000000000000
        while divisor>0
            digit=number/divisor
            leading_zero=leading_zero+digit
            if leading_zero | (divisor=1)
                display digit+'0'
                number=number-digit*divisor
            end if
            divisor=divisor/10
        end while
    end if
}
macro display_unsigned value* {
    local number
    number=value
    if number<0
        number=number-10000000000000000000
        if number<0
            number=number+1000000000000000000
            display '9'
            display_decimal number
        else
            display '1'
            display_decimal number,1
        end if
    else
        display_decimal number
    end if
}    
Post 15 Aug 2005, 14:47
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.