-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTEST_atomic_meta.bb
More file actions
159 lines (107 loc) · 4.34 KB
/
TEST_atomic_meta.bb
File metadata and controls
159 lines (107 loc) · 4.34 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
Include "HexTable.bb"
Include "Atomic32.bb"
Graphics 800,400,32,2
Global mstr$[10] ;; Create strings to store 'machine code' (represented by HEX chars)
Global MacCode[10] ;; Create room for Bank handles (into which machine code is poked).
;; ___Enter some x86 machine code___
mstr[0] = " 01D3F00FB10B0F94C131C000C8C3 " ;; <-- this is the machine code, in HEX form
;mem = CreateBank(40)
MacCode[0] = CreateBank(100) ;; You may (optionally) allocate your bank ahead of time...
MacCode[0] = HexToBank( MacCode[0], mstr[0] ) ;; Poke machine code into that bank...
mem = MacCode[0]
;expected = RevBytesI($90909090) ;; This is 4-byte source code represented as an integer
;newV = RevBytesI($909090c3)
;offset = 0
expected = RevBytesI($f00fb10b) ; $44000000 ;; This is 4-byte source code represented as an integer
newV = RevBytesI($909090c3) ; $55000000
offset = 2
;PokeInt mem,offset, $44000000
Print
Print" __BEFORE__ "
Print" mem = "+PeekInt(mem,offset)+" : "+Hex$(PeekInt(mem,offset))
;v= atomic_meta_v2(MacCode[0], mem, expected, newV, offset)
v= atomic_meta_v1(mem, expected, newV, offset)
Print
Print" __AFTER__ "
Print" mem = "+PeekInt(mem,offset)+" : "+Hex$(PeekInt(mem,offset))
Print" v = "+v+" : "+Hex$(v)
;v= atomic_meta_v2(MacCode[0], mem, expected, newV, offset)
v= atomic_meta_v1(mem, expected, newV, offset)
For z=1 To 100
v= atomic_meta_v1(mem, expected, newV, offset)
Next
Print
Print" __AFTER__ "
Print" mem = "+PeekInt(mem,offset)+" : "+Hex$(PeekInt(mem,offset))
Print" v = "+v+" : "+Hex$(v)
Print
Print" mem at offset "+offset+" shown as an integer = "+Hex$(PeekInt(mem,offset))
Print" mem at offset "+offset+" shown as byte sequence = "+Hex$(RevBytesI(PeekInt(mem,offset)))
;
Print" Offset = "+offset
we()
Print" v = "+v+" : "+Hex$(v)
Print" mem = "+PeekByte(MacCode[0],0)+" : "+Hex$(PeekByte(MacCode[0],0))
we()
End
;0: 01 d3 add ebx,edx
;2: f0 0f b1 0b lock cmpxchg DWORD PTR [ebx],ecx
;6: 0f 94 c1 sete cl
;9: 31 c0 Xor eax,eax
;b: 00 c8 add al,cl
;d: c3 ret
;0: 01 d3 add ebx,edx
;2: f0 0f b1 0b lock cmpxchg DWORD PTR [ebx],ecx
;6: c3 ret
;0: 01 d3 add ebx,edx
;2: f0 0f b1 0b lock cmpxchg DWORD PTR [ebx],ecx
;6: 0f 94 c1 sete cl
;9: 31 c0 Xor eax,eax
;b: 00 c8 add al,cl
;d: c3 ret
;0: 55 push ebp
;1: 89 e5 mov ebp,esp
;3: 1e push ds
;4: 8d 45 08 lea eax,[ebp+0x8]
;7: 8e d8 mov ds,eax
;9: 01 d3 add ebx,edx
;b: f0 0f b1 0b lock cmpxchg DWORD PTR [ebx],ecx
;f: 0f 94 c1 sete cl
;12: 31 c0 xor eax,eax
;14: 00 c8 add al,cl
;16: 1f pop ds
;17: 5d pop ebp
;18: c3 ret
;0: 8b 1b mov ebx,DWORD PTR [ebx]
;2: f0 0f b1 0b lock cmpxchg DWORD PTR [ebx],ecx
;6: 0f 94 c1 sete cl
;9: 31 c0 Xor eax,eax
;b: 00 c8 add al,cl
;d: c3 ret
;0: 55 push ebp
;1: 89 e5 mov ebp,esp
;3: 8b 5d 08 mov ebx,DWORD PTR [ebp+0x8]
;6: 8b 45 0c mov eax,DWORD PTR [ebp+0xc]
;9: 8b 4d 10 mov ecx,DWORD PTR [ebp+0x10]
;c: 8b 55 14 mov edx,DWORD PTR [ebp+0x14]
;f: 01 d3 add ebx,edx
;11: f0 0f b1 0b lock cmpxchg DWORD PTR [ebx],ecx
;15: 5d pop ebp
;16: c3 ret
Function we()
WaitKey() :End
End Function
Function Fibbi%(x)
If x<=1
Return 1
Else
Return Fibbi(x-1)+Fibbi(x-2)
End If
End Function
Function recurse(x)
If x=10
;Goto Abnormal_exit
Else
recurse(x+1)
End If
End Function