Seems like I'm almost there. I'm asking for the 1st character CP(1) in "ABCDEFGH", and getting it (see I/O(CP(1)), 041h, but returning the high-order mask (which accurately matches the character retrieved), instead of what I expected in the low end, the result of
AND HGFE, 00000000h
which is 00000000h,
given that the the order of the characters in EAX and EDX is
EAX EDX
DCBA HGFE.
Masks are shown, in order, 1 to 8, in the fortran DATA statement, which matches the order of the characters in memory.
Ditto for the 2nd I/O(CP(4).
These outputs lack the right shifting, none for the 1st character, that would follow their retrieval.
Suggests welcome.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MAIN:
INTEGER CP(8),SQOUT
DATA CP /Z'00000000000000FF', Z'000000000000FF00',
1 Z'0000000000FF0000', Z'00000000FF000000',
2 Z'000000FF00000000', Z'0000FF0000000000',
3 Z'00FF000000000000', Z'FF00000000000000'/
100 FORMAT(A8)
110 FORMAT(Z16)
READ(*,100) IGET
IWORD=SQOUT(CP(1),IGET)
WRITE(*,110) IWORD
END
SQOUT:
global sqout_
section .text ;AND 64-bit 2nd arg source with 1st arg mask
global sqout_
sqout_:
push ebp
mov ebp, esp
mov eax, [ebp+8] ;eax <- addr of 1st arg, mask
mov ecx, [ebp+12] ;ecx <- addr of 2nd arg, source
pop ebp
mov edx, [eax+4]
and [ecx+4], edx
mov edx, [ecx+4]
mov edx, [eax]
and [ecx], edx
mov eax, [ecx]
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I/O(CP(1):
mrice@debian10-uni:~$ ./test
ABCDEFGH
FF00000041
mrice@debian10-uni:~$
I/O(CP(4):
mrice@debian10-uni:~$ ./test
ABCDEFGH
FF00000044000000
mrice@debian10-uni:~$