Hi,
This is incomplete but works. It's a function with two qword parameters,
the first must be a number that can be represented in 2 bits (0-3) or a
-1, and the second must be a variable (see calling function below) that
contains some arbitrary number. If the first parameter is a -1, it acts
as a do nothing flag, otherwise the first parameter number is placed in
the highest 2 bits of the second parameter's high dword.
Some examples:
Input:
1st param = -1
2nd param = 256
Output: 100 (hex) ;unchanged
Input:
1st param = 1
2nd param = 256
Output: 4000000000000100
Input:
1st param = 2
2nd param = 256
Output: 8000000000000100
Input:
1st param = 3
2nd param = 256
Output: C000000000000100
The function will eventually have four parameters,
any of the first three capable of being flagged
with a -1, or having a value which will be inserted
into a reserved field in the final parameter.
Be aware that Fortran, unlike C, passes the addresses
of all function arguments.
My question:
A -1 is 0xFFFFFFFFFFFFFFFF. Since I must test for
it two more times, is there a nicer way to do it?
Michael
================================
global setdir_
section .text ;
setdir_:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov edx, [ebp+12]
pop ebp
cmp dword [eax], 0xffffffff ;if both [eax] & [eax+4] are all 1s goto chngid
jne .chngid
cmp dword [eax+4], 0xffffffff
je .done
.chngid:
and dword [edx+4], 0x3fffffff ;
mov ecx, [eax]
shl ecx, 30
or [edx+4], ecx
.done:
ret
Fortran calling program:
integer m
m = 256
call setdir(3,m)
print 5, m
5 format(z20)
end