UASM icon indicating copy to clipboard operation
UASM copied to clipboard

64-bit procedure prologue/epilogue ("SUB RSP,8 / ADD RSP,8") corrupts the listing

Open luchezarg opened this issue 3 years ago • 1 comments

The simple source file below

.code
testprc proc
        XOR     RAX,RAX         ; RAX = 0
        XOR     RDX,RDX         ; RDX = 0
        RET
testprc endp
end

when compiled using the command line below uasm -elf64 -q -mf -Fl -Sa -zcw -Zd test.s results in the listing file below

UASM v2.55, Mar 30 2022, Masm-compatible assembler.

test.s
                            *   .model FLAT
00000000                    *   _TEXT segment PARA FLAT PUBLIC 'CODE'
                            *   _TEXT ends
00000000                    *   _DATA segment PARA FLAT PUBLIC 'DATA'
                            *   _DATA ends
                            *   assume cs:flat,ds:flat,ss:flat,es:flat,fs:ERROR,gs:NOTHING
                                .code
00000000                    *   _TEXT segment
                            *   assume cs:FLAT
00000000                        testprc proc
00000000  4883EC08                      XOR     RAX,RA00000004  48300000007  4833D2                     XOR     RDX,RDX         ; RDX = 0
0000000A                                RET
0000000A  4883C408          *   RETn
0000000F                          stprc endp
                                end
0000000F                    *   _TEXT ends

(Macros are omitted for brevity.) As a comparison, JWASM using the same source file and command line produces the following listing file:

JWasm v2.11a, Apr  8 2015
test.s
                            *   .model FLAT
00000000                    *   _TEXT segment PARA FLAT PUBLIC 'CODE'
                            *   _TEXT ends
00000000                    *   _DATA segment PARA FLAT PUBLIC 'DATA'
                            *   _DATA ends
                            *   assume cs:flat,ds:flat,ss:flat,es:flat,fs:ERROR,gs:ERROR
                                .code
00000000                    *   _TEXT segment
                            *   assume cs:FLAT
00000000                        testprc proc
00000000  4833C0                        XOR     RAX,RAX         ; RAX = 0
00000003  4833D2                        XOR     RDX,RDX         ; RDX = 0
00000006                                RET
00000006  C3                *   RETn
00000007                        testprc endp
                                end
00000007                    *   _TEXT ends

As far as I understand, what corrupts the listing is the generated prologue/epilogie code ("SUB RSP,8 / ADD RSP,8") in the beginning and in the end (before the RET) of the procedure.

luchezarg avatar Jul 27 '22 07:07 luchezarg

Fixed in 2.56, corruption is no longer present and the listings show the generated prologue/epilogue code. Tested under both elf64 and win64.

john-terraspace avatar Oct 03 '22 20:10 john-terraspace