Re: amd64 missing addressing modes

Bernd Paysan <[email protected]> Wed, 26 Aug 2020 15:42:52 +0200
Newsgroups gmane.comp.lang.forth.gforth
Message-ID <1827637.pK3u5BB3Y6@liubei>
Am Mittwoch, 26. August 2020, 15:35:45 CEST schrieb anthony:
> I try to use amd64 assembly with addressing mode base with displacement,
> scaled index and scaled index with displacement gforth i.e.
> 
> mov (%rdx,%rcx,1),%rax
> mov (%rdx,%rcx,4),%rax
> mov 40(%rdx,%rcx,4),%rax
> 
> I installed gforth from git version 0.7.9_20200820 on linux opensuse
> 15.1 64 bit.
> I included this code to test:
> 
> ABI-CODE A  ( -- )
>      500  #  AX  MOV    \ AX := 500
>      DX  AX  MOV    \ AX := DX
>       200  AX  MOV    \ AX := (200)
>       DX  )  AX  MOV    \ AX := (DX)
>       40  DX  D)  AX  MOV    \ AX := (DX + 40)
> \  DX  CX  I)  AX MOV    \ AX := (DX + CX)
> \  DX  CX  *4  I)  AX  MOV    \ AX := (DX + CX * 4)    *1/2/4/8
> \  40  DX  CX  *4  DI)  AX  MOV    \ AX := (DX + CX * 4 + 40)
> 
>      DI  AX  MOV
>      RET
> END-CODE
> 
> Compiling any of the now commented three lines results in an "invalid
> memory address" error.
> Maybe I am using an invalid syntax? Thought this was the correct syntax
> after reading asm.fs
> 
> Every help is very much appreciated.
> Anthony

This here works:

abi-code test  ok 1
ax cx *4 i) dx mov  ok 1
3 ax cx *8 di) dx mov  ok 1
ret   ok 1
end-code  
see test 
ABI-Code test  
7F38B25582B0:   mov     rdx,[rax][rcx*4]
7F38B25582B4:   mov     rdx,$03[rax][rcx*8]
7F38B25582B9:   ret
end-code

Your example doesn't work, though.  Looks like some storage is not cleaned 
after finishing with one instruction.  Your syntax is ok.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o id: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
https://net2o.de/
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEERJ1NDqPQRwYnwBjr9y2Uk5MtoGcFAl9GZt0ACgkQ9y2Uk5Mt
oGeHdxAAkeXNNGZuvgnkV5tNZp9fsaEmAJCCoFqzCGJA4g/fPZ7x5ilPOHeX62cT
pGhojXhHwvHaATfq9FUaKBzueESvGEEigRWHv/YrNSHE9Z31pPR7wVFXbOSyMF/V
2ixYirw1YDqGlMn8/Up1G8P6IjViaLzLB5AfuoOf2JR1ryqLc2KORjGy9wc67nx1
LAEUPSrAYfhEjTiSB0r1AmAF3YZ8yekbDpx+Ng1kTIf8/4+DYvY8HpG9Z/VczaMO
/qbBaPVgADH2RzpyMGEeg3qZoBnoDsuxjH+kdkomEKQeAfM+O0lj5Dh16dZ8rxD0
7mdyLITGP25QIYajum3+ukqwd/rFXZNGTzu7XwwYLt2KFgU71iEmDWuyAUery0bW
AChJC2VzPT0tqeXJBRs130wzWO+b3rQWQrXmv2ODRsO0tsyqdAgExRZhyTNRvv3k
J5A4xKAao7Ii1LY8Jrn3B/D9Sjn09l6lWg8A+lWIgrPR63if7IpHolArkUd3PT1I
8L1W2QYlSGsiherk8pVwvpTPWxyCThb43uWOVG8lCHlwpPjgYqTm3vBycqUIGKgN
qNEDQKbbK7Zw+YNq8wOZkNpVqjQsu6r9pJ1EB55iBlM7lGDRbWb8vjaY5Ed9S19C
ttpwQSPAlJHvxmx0wHH0DOiCV9J8IIZyUduZN/EJbkE0GXsfPiQ=
=mUZQ
-----END PGP SIGNATURE-----