Hi Grincheux,
Here is the 64-bit version :
.model flat,fastcall
option casemap:none
lstrlenA PROTO :QWORD
lstrlen EQU <lstrlenA>
.data
ltable db 0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.code
RightTrim PROC _str:DWORD PARMAREA=1*QWORD
LOCAL _rcx:QWORD
mov _rcx,rcx
invoke lstrlen,rcx
add rax,_rcx
mov r8,1
mov rcx,OFFSET ltable
@@:
sub rax,r8
movzx rdx,BYTE PTR [rax]
cmp BYTE PTR [rcx+rdx],r8b
je @b
@@:
add rax,r8
mov BYTE PTR [rax],0
mov rax,_rcx
ret
RightTrim ENDP
Testing the function :
.model flat,fastcall
option casemap:none
includelib kernel32.lib
includelib user32.lib
includelib msvcrt.lib
ExitProcess PROTO :QWORD
RightTrim PROTO :QWORD
printf PROTO :QWORD,:VARARG
lstrlenA PROTO :QWORD
lstrlen EQU <lstrlenA>
.data
teststr db 'This is a test. ',0
msg db 'Length of the string = %u',0
.code
start:
sub rsp,8+4*8
invoke RightTrim,ADDR teststr
invoke lstrlen,rax
invoke printf,ADDR msg,rax
invoke ExitProcess,0
END start