Question: Make a copy of this assignment in notepad. Fill the information as we discuss the material. Upload the completed file as submission. Do NOT use
Make a copy of this assignment in notepad. Fill the information as we discuss the material. Upload the completed file as submission.
Do NOT use Visual Studio to put the answers BUT to validate your understanding.
OFFSET Operator
returns the distance in bytes, of a label from the beginning of its enclosing segment
Protected mode: bits
Let's assume that the data segment begins at h:
data
bVal BYTE
wVal WORD
dVal DWORD
dVal DWORD
code
mov esi,OFFSET bVal ; ESI
mov esi,OFFSET wVal ; ESI
mov esi,OFFSET dVal ; ESI
mov esi,OFFSET dVal ; ESI
PTR Operator
Overrides the default type of a label variable Provides the flexibility to access part of a variable.
data
myDouble DWORD h
code
mov axmyDouble ;
mov axWORD PTR myDouble ; loads
mov WORD PTR myDouble,h ; saves
mov alBYTE PTR myDouble ; AL
mov alBYTE PTR myDouble ; AL
mov alBYTE PTR myDouble ; AL
mov axWORD PTR myDouble ; AX
mov axWORD PTR myDouble ; AX
data
myBytes BYTE hhhh
code
mov axWORD PTR myBytes ; AX
mov axWORD PTR myBytes ; AX
mov eax,DWORD PTR myBytes ; EAX
data
varB BYTE hhhh
varW WORD hh
varD DWORD h
code
mov ax WORD PTR varB ; a
mov bl BYTE PTR varD ; b
mov bl BYTE PTR varW ; c
mov ax WORD PTR varD ; d
mov eax, DWORD PTR varW ; e
TYPE Operator
The TYPE operator returns the size, in bytes, of a single element of a data declaration.
data
var BYTE
var WORD
var DWORD
var QWORD
code
mov eax,TYPE var ; EAX
mov eax,TYPE var ; EAX
mov eax,TYPE var ; EAX
mov eax,TYPE var ; EAX
LENGTHOF Operator
The LENGTHOF operator counts the number of elements in a single data declaration.
data LENGTHOF
byte BYTE ;
array WORD DUP ;
array WORD DUP DUP ;
array DWORD ;
digitStr BYTE ;
code
mov ecx, LENGTHOF array ; ecx
mov ecx, LENGTHOF array ; ecx
mov ecx, LENGTHOF array ; ecx
mov ecx, LENGTHOF digitStr ; ecx
SIZEOF Operator
The SIZEOF operator returns a value that is equivalent to multiplying LENGTHOF by TYPE.
data SIZEOF
byte BYTE ;
array WORD DUP ;
array WORD DUP DUP ;
array DWORD ;
digitStr BYTE ;
code
mov ecx, SIZEOF array ; ecx
mov ecx, SIZEOF array ; ecx
mov ecx, SIZEOF array ; ecx
mov ecx, SIZEOF digitStr ; ecx
data
array WORD
code
mov eax,LENGTHOF array ; EAX
mov ebx,SIZEOF array ; ebx
data
array WORD
WORD
WORD
code
mov eax,LENGTHOF array ; EAX
mov ebx,SIZEOF array ; ebx
Indirect operand
holds the address of a variable, usually an array or string. It can be dereferenced just like a pointer
data
val BYTE hhh
code
mov esi,OFFSET val
mov alesi ; dereference ESI, AL
inc esi
mov alesi ; AL
inc esi
mov alesi ; AL
If val was WORD, what would change.
If val was DWORD, what would change.
Use PTR to clarify the size attribute of a memory operand.
data
myCount WORD
code
mov esi, OFFSET myCount
inc esi ;
inc WORD PTR esi ;
add esi ;
JMP Instruction
JMP is an unconditional jump to a label that is usually within the same procedure.
Syntax: JMP target
Logic: EIP target
The LOOP instruction creates a counting loop
Syntax: LOOP target
Logic:
ECX ECX
if ECX
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
