64 bit assembler > ASMC Development

Linux and LIBC

(1/1)

nidud:
I've added _LINUX and _WIN64 to switch -elf, -elf64, and -win64

-elf --> _LINUX = 1
-elf64 --> _LINUX = 2 + _WIN64 = 1
-win64 --> _WIN64 = 1

libc.inc use SYSCALL if elf is defined.

--- Code: ---ifdef _LINUX
_CType equ <syscall>
_CDecl equ <syscall>
__cdecl equ <syscall>

--- End code ---

This enables use of the include files for LIBC functions.

Test case used for 64-bit:

--- Code: ---include stdio.inc

    .code

main proc argc:SINT, argv:ptr

    .for r12d=argc, r13=argv, ebx=0: r12d: r12d--, ebx++, r13+=size_t
       
    printf("[%d]: %s\n", ebx, [r13])
    .endf
    xor eax,eax
    ret
main endp

    end

--- End code ---

Output:

--- Code: ---nidud@nidud-VB ~/asmc $ ./asmc -q -Iinclude -elf64 arg64.asm
nidud@nidud-VB ~/asmc $ gcc -o arg64 arg64.o
nidud@nidud-VB ~/asmc $ ./arg64 1 2 3
[0]: ./arg64
[1]: 1
[2]: 2
[3]: 3

--- End code ---

Test case used for 32-bit:

--- Code: ---include stdio.inc

    .code

main proc argc:SINT, argv:ptr

    .for ebx=argc, esi=argv, edi=0: ebx: ebx--, edi++, esi+=size_t

    printf("[%d]: %s\n", edi, [esi])
    .endf
    xor eax,eax
    ret
main endp

    end

--- End code ---

Output:

--- Code: ---nidud@nidud-VB ~ $ cd asmc
nidud@nidud-VB ~/asmc $ ./asmc -elf -Iinclude arg32.asm
Asmc Macro Assembler Version 2.24
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.

 Assembling: arg32.asm
nidud@nidud-VB ~/asmc $ gcc arg32.o -o arg32
nidud@nidud-VB ~/asmc $ ./arg32
[0]: ./arg32
nidud@nidud-VB ~/asmc $ ./arg32 1 2 3
[0]: ./arg32
[1]: 1
[2]: 2
[3]: 3

--- End code ---

I also changed the default size of indirect addressing using register in 64-bit. This was 4 but now 8. This effect :VARARG arguments using -elf64 and -win64.

--- Code: ---     printf("[%d]: %s\n", ebx, [r13])

--- End code ---

Navigation

[0] Message Index

Go to full version