Page 1 of 1

x86 Portable (ASM Source), version 2017-04-14

Posted: Sat Apr 15, 2017 9:12 am
by ~
This is the second version of x86 Portable, a NASM/YASM source-only project which allows writing x86 assembly source code that can be directly and easily ported to 16, 32 and 64-bit modes with little to no changes, thanks mainly to the added capability to select CPU register and stack push/pop sizes automatically and manually.

What's New
I have added the keyword "_CALL_STACK_ADDR_SZ_", which allows calculating the address of the on-stack function parameters after/above the on-stack return address of a function call. It will allow us to use a portable value to skip a 2, 4 or 8-byte return address automatically without modifying the stack frame code of the function in any other way.

I have also added an "align 16" directive near the end of the source file. In this way we can include this file at any point of the program without the need to write a jump label because it already includes one to avoid accidentally executing the code inside "00000000__x86_Portable.asm".


Source Code File:
http://www.archefire.org/_PROJECTS_/x86_Portable/v2017-04-14/src/00000000__x86_Portable.asm

Text Recording (to see how the file has been typed/developed over time):
http:///www.archefire.org/_PROJECTS_/x86_Portable/v2017-04-14/SourceDoc/src/00000000__x86_Portable.asm.html



Current Keywords:

Code: Select all

Automatic size selection for data/variables:
-------------------------------------------------------------------------
wideword    -- Automatic size selection, 2, 4 or 8 bytes.
ww          -- Automatic size selection, define wideword, 2, 4 or 8 bytes.
wideword_SZ -- Automatic size selection, 2, 4 or 8.




Automatic size selection for any on-stack call return addresses:
-------------------------------------------------------------------------
_CALL_STACK_ADDR_SZ_ -- 2, 4 or 8.




Automatic size selection for CPU registers:
-------------------------------------------------------------------------
wideax -- 2, 4 or 8 bytes.
widebx -- 2, 4 or 8 bytes.
widecx -- 2, 4 or 8 bytes.
widedx -- 2, 4 or 8 bytes.
widesi -- 2, 4 or 8 bytes.
widedi -- 2, 4 or 8 bytes.
widesp -- 2, 4 or 8 bytes.
widebp -- 2, 4 or 8 bytes.




Automatic size selection for "Address" and "Operand" prefixes:
-------------------------------------------------------------------------
awide -- a16, a32 or nothing.
owide -- a16, a32 or nothing.




Automatic size selection for CPU instructions:
-------------------------------------------------------------------------
 cmpswide -- 2, 4 or 8 bytes.
 lodswide -- 2, 4 or 8 bytes.
 stoswide -- 2, 4 or 8 bytes.
 movswide -- 2, 4 or 8 bytes.
 inswide  -- 2 or 4 bytes.
 outswide -- 2 or 4 bytes.




Automatic variable or register selection for 64-bit CPU r8-r9 registers:
-------------------------------------------------------------------------
_r8  -- 2, 4 or 8 bytes.
_r9  -- 2, 4 or 8 bytes.
_r10 -- 2, 4 or 8 bytes.
_r11 -- 2, 4 or 8 bytes.
_r12 -- 2, 4 or 8 bytes.
_r13 -- 2, 4 or 8 bytes.
_r14 -- 2, 4 or 8 bytes.
_r15 -- 2, 4 or 8 bytes.