Abt. Adressierungsarten, praktisch ausprobiert
=============================
' Zugriffsarten-Demo April 2012 by P.Specht für Paule´s PC Forum
' Verwendung auf alleiniges Risiko des Anwenders
' Verwendet XPIA von Frank Abbing
$MAKE CL
Font 2:randomize:cls rnd(8^8):Declare eax&
AsmStart Zugriffsartentest(eax&)
.data
; Testfeld mit Zahlen 0 bis 255
dat db 00h,01h,02h,03h,04h,05h,06h,07h,08h,09h,0ah,0bh,0ch,0dh,0eh,0fh
db 10h,11h,12h,13h,14h,15h,16h,17h,18h,19h,1ah,1bh,1ch,1dh,1eh,1fh
db 20h,21h,22h,23h,24h,25h,26h,27h,28h,29h,2ah,2bh,2ch,2dh,2eh,2fh
db 30h,31h,32h,33h,34h,35h,36h,37h,38h,39h,3ah,3bh,3ch,3dh,3eh,3fh
db 40h,41h,42h,43h,44h,45h,46h,47h,48h,49h,4ah,4bh,4ch,4dh,4eh,4fh
db 50h,51h,52h,53h,54h,55h,56h,57h,58h,59h,5ah,5bh,5ch,5dh,5eh,5fh
db 60h,61h,62h,63h,64h,65h,66h,67h,68h,69h,6ah,6bh,6ch,6dh,6eh,6fh
db 70h,71h,72h,73h,74h,75h,76h,77h,78h,79h,7ah,7bh,7ch,7dh,7eh,7fh
db 80h,81h,82h,83h,84h,85h,86h,87h,88h,89h,8ah,8bh,8ch,8dh,8eh,8fh
db 90h,91h,92h,93h,94h,95h,96h,97h,98h,99h,9ah,9bh,9ch,9dh,9eh,9fh
db 0a0h,0a1h,0a2h,0a3h,0a4h,0a5h,0a6h,0a7h,0a8h,0a9h,0aah,0abh,0ach,0adh,0aeh,0afh
db 0b0h,0b1h,0b2h,0b3h,0b4h,0b5h,0b6h,0b7h,0b8h,0b9h,0bah,0bbh,0bch,0bdh,0beh,0bfh
db 0c0h,0c1h,0c2h,0c3h,0c4h,0c5h,0c6h,0c7h,0c8h,0c9h,0cah,0cbh,0cch,0cdh,0ceh,0cfh
db 0d0h,0d1h,0d2h,0d3h,0d4h,0d5h,0d6h,0d7h,0d8h,0d9h,0dah,0dbh,0dch,0ddh,0deh,0dfh
db 0e0h,0e1h,0e2h,0e3h,0e4h,0e5h,0e6h,0e7h,0e8h,0e9h,0eah,0ebh,0ech,0edh,0eeh,0efh
db 0f0h,0f1h,0f2h,0f3h,0f4h,0f5h,0f6h,0f7h,0f8h,0f9h,0fah,0fbh,0fch,0fdh,0feh,0ffh
.code
xor eax,eax ;Register löschen
mov ebx,eax
mov ecx,eax
mov edx,eax
; Basiswert in EAX/EBX/ECX/EDX/ESI/EDI/(EBP)/(ESP)
; +Indexwert in EAX/EBX/ECX/EDX/ESI/EDI/(EBP)) mal Skalenfaktor 1/2/4/8
; + Versatz [0 oder 8bit-/16bit-/32bit-Wert
mov ebx, 1h
mov ecx, 2h
mov edx, 5h ; falls edx überhaupt benötigt wird
; mov al, dat ; Lade ab Speicherstelle dat
; mov al, [dat] ; Effekt wie oben.
; mov al, [dat + ebx]
; mov al, dat + [ebx + ecx] ; Korrekt laden, sonst Access violation
; lea ebx,dat
; mov al, ebx + [ecx*4] ; invalid use of register: IMMER in [] !
; mov al, [ebx + ecx*4] ; so klappt das!
; lea ebx,dat
; mov al, [ebx + ecx + edx] ; klappt nicht, es werden ebx und ecx berücksichtigt
; mov al, [ebx + ecx*2 + edx] ; klappt NICHT, edx wird ignoriert!
; Merksatz: Es werden maximal 2 Register berücksichtigt!
; mov al, dat + [ecx*8 + ebx] ; register müssen in [] stehen!
; mov al, [dat + ecx*8 + ebx]
; mov al, dat + 2 + [ebx*4 + edx] ; 2 wird berücksichtigt
; mov al, [ebx*4 + edx] + dat ; klappt auch wenn hinten angereiht
; mov al, [ebx + edx*2] + dat ; klappt.
; mov al, [ebx*2 + edx*2] + dat ; illegal, greift auf 0.Element zu!
xchg eax,edx ;klappt
AsmEnd(eax&)
Print eax&
WaitInput
End
Alles anzeigen