-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyASM_elif_task1.asm
executable file
·92 lines (74 loc) · 3.12 KB
/
myASM_elif_task1.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
; Build this with the "Project" menu using
; "Console Assemble and Link"
comment * «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
Malware Analysis
««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« *
.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include \masm32\include\windows.inc ; always first
include \masm32\macros\macros.asm ; MASM support macros
; -----------------------------------------------------------------
; include files that have MASM format prototypes for function calls
; -----------------------------------------------------------------
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\debug.inc
include \masm32\include\msvcrt.inc
; ------------------------------------------------
; Library files that have definitions for function
; exports and tested reliable prebuilt code.
; ------------------------------------------------
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\debug.lib
includelib \masm32\lib\msvcrt.lib
.data
txttitle db "Malware Analysis - Simple Addition using registers and assembly instructions", 0 ; an initialised string
txtmsg1 db "enter the first number: ", 0
txtmsg2 db "enter the second number: ", 0
txtmsg3 db "The total sum of the numbers is: ", 0
.data?
var1 dd ? ; unitialised single 32bit space (you must initialised first for it to work!)
var2 dd ?
var3 dd ?
str1 dd ?
.code ; Tell MASM where the code starts
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start: ; The CODE entry point to the program
print OFFSET txtmsg1 ;
mov str1, input() ;
mov var1, sval(str1) ;
print OFFSET txtmsg2 ;
mov str1, input() ;
mov var2, sval(str1) ;
print chr$(13, 10, 13, 10) ; print 2 new lines to the console
print OFFSET txtmsg3
mov eax, var1
mov ecx, var2
add eax, ecx
mov var3, eax
print str$(eax)
print chr$(13, 10)
cmp var3, 500
je equal
jg greater
jl lesser
equal:
print chr$("The number you entered is equal to 500", 13, 10)
jmp over
greater:
print chr$("The number you entered is greater than 500", 13, 10)
jmp over
lesser:
print chr$("The number you entered is less than 500", 13, 10)
jmp over
over:
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start ; Tell MASM where the program ends