Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

NASM: little-endian WORD constant

I want to make WORD variable in little endian without manually converting it, for example:

SECTION .data
    variable1: dw 2  ; <-- How to make 2 little-endian without manually writing db 0x02, 0x00?

Maybe NASM has builtin macro or you can suggest your one?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Something along these lines should work (link shows another approach)

MACRO M_swap16 operand
 LOCAL result
 result = (((operand and 0FFh) shl 8) or ((operand and 0FF00h) shr 8))
 exitm %result
ENDM

Does TASM allow a macro to be used as an operand

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading