-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleproc.asm
76 lines (70 loc) · 1.6 KB
/
simpleproc.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
;====================================
;Minimalistic PowerShell to
;Machinecode (Assembler) Compiler
;Andreas Nick 2019
;====================================
format PE Console
entry start
Include '%include%\win32a.inc'
;=======================================
section '.code' code readable executable
;=======================================
start:
;= variable =
mov eax, 1
mov [i], eax
;= variable =
mov eax, 0
mov [j], eax
;= variable =
mov eax, 10
mov [k], eax
;= while =
.LABEL9:
mov eax, [k]
CMP EAX, 0
JBE .LABEL10
ccall [printf], D617, [i]
mov eax, [i]
mov ecx, eax
mov eax, [j]
add eax, ecx
mov [i], eax
mov eax, [i]
mov ecx, eax
mov eax, [j]
neg eax
add eax, ecx
mov [j], eax
mov eax, [k]
mov ecx, eax
mov eax, 1
neg eax
add eax, ecx
mov [k], eax
JMP .LABEL9
.LABEL10:
stdcall [ExitProcess],0
;====================================
section '.bss' readable writeable
;====================================
i dd ?
j dd ?
k dd ?
;============ Constants ===============
section '.data' data readable writeable
;======================================
printfempty db 10,0
printfint db "%lu",10,0
D617 db "fibu %lu", 10, 0
;====================================
section '.idata' import data readable
;====================================
library kernel,'kernel32.dll',\
msvcrt,'msvcrt.dll'
import kernel,\
ExitProcess,'ExitProcess',\
AllocConsole,'AllocConsole'
import msvcrt,\
printf,'printf',\
getchar,'_fgetchar'