ASSEMBLY LANGUAGE X86 VISUAL STUDIOS WAP a program that calculates how much memo
ID: 3916945 • Letter: A
Question
ASSEMBLY LANGUAGE X86 VISUAL STUDIOS
WAP a program that calculates how much memory(in BYTES) is being used by the variables that we’ve initialize in the following data section.
.data
myVar BYTE 10h
myVar1 QWORD 1000000011
myarr1 WORD 1,2, 66 Dup(0)
myString BYTE ‘onetwothreefourfivesix’
myCounter DWORD 100
then WRITE a program that does the same task every 15 minutes. Assume that you have a function CURTIME already prepared for you. If you call CURTIME it will load the current time as HH:MM:SS in BL:DH:DL register
Explanation / Answer
Answer:
Each Byte= 1 Byte
Each Qword= 8 Byte
Each Word= 2 Byte
Each Dword= 4 Byte
In order to find and print the value of the bytes allocated to each variable we can use the following codes
section.text
global_start
_start:
mov edx,length
mov ecx,var
mov ebx,1
mov eax,4
int 0x80
section.data
var db 'onetwothreefourfivesix'
length equ $ -var
In the above we have shown how to find the memory(in bytes) allocated for a string. We can define any variable type in the data section to find the memory bytes allocated to it.Here we use
length equ $ -var
The logic is that $ denotes current address and $ -var denotes the next address where the machine language code will be executed. Hence length equ $ -var calculates the number of memory location in bytes between the definition of length and the label var.
The code snippet defined above should be within a procedure and the procedure should be called every 15 minutes.
We can use the current time function to define a one minute delay counter. Each time a one minute delay is registered the counter cx will be incremented by 1. In this fashion each time the counter value is increased to 15(ie 15 mins) then the procedure to calculate the byte sizes will be called.
L 2 Xor cx,cx
L1 nop
Call ONEMINUTE_DELAY
Inc cx
cmp cx,15
jle L1
CALL PROCEDURE
Loop L2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.