Java - Programación en Ensamblador (de Java): Hola Mundo, Parte 2

   
Vista:

Programación en Ensamblador (de Java): Hola Mundo, Parte 2

Publicado por AltComp126 (1 intervención) el 03/07/2012 00:54:07
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
;/*****************************************************************************
;EHLOWorldApp.java
;
; 2012-07-02
;
;
;Demostración inicial de un programa de Java escrito totalmente en ensamblador
;(ensamblador de Java, pero usando NASM para codificar los bytes).
;
;http://devel.no-ip.org/
;
;Este código es de dominio público (sin derechos de autor).
;Puedes hacer lo que desees con él.
;
;
;*****************************************************************************/
 
 
_CLASS_START:
 
_00000000__magic db 0xCA,0xFE,0xBA,0xBE
 
 
_00000004__minor_version dw 0x0000
 
 
_00000006__major_version db 0x00,0x33
 
 
_00000008__constant_pool_count db 0,29+1
 
    _0000000A__cp_info_0001:
                           db 0x0A    ;cp_info.tag: CONSTANT_Methodref
                           db 0,0x06  ;cp_info.info.class_index
                           db 0,0x0F  ;cp_info.info.name_and_type_index
 
    _0000000F__cp_info_00002:
                           db 0x09    ;cp_info.tag: CONSTANT_Fieldref
                           db 0,0x10  ;cp_info.info.class_index
                           db 0,0x11  ;cp_info.info.name_and_type_index
 
    _00000014__cp_info_0003:
                           db 0x08    ;cp_info.tag: CONSTANT_String
                           db 0,0x12  ;cp_info.info.string_index
 
    _00000017__cp_info_0004:
                           db 0x0A    ;cp_info.tag: CONSTANT_Methodref
                           db 0,0x13  ;cp_info.info.class_index
                           db 0,0x14  ;cp_info.info.name_and_type_index
 
    _0000001C__cp_info_0005:
                           db 0x07    ;cp_info.tag: CONSTANT_Class
                           db 0,0x15  ;cp_info.info.name_index
 
    _0000001F__cp_info_0006:
                           db 0x07    ;cp_info.tag: CONSTANT_Class
                           db 0,0x16  ;cp_info.info.name_index
 
    _00000022__cp_info_0007:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x06   ;cp_info.info.length
                           db "<init>" ;cp_info.info.bytes[length]
 
    _0000002B__cp_info_0008:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x03   ;cp_info.info.length
                           db "()V"    ;cp_info.info.bytes[length]
 
    _00000031__cp_info_0009:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x04   ;cp_info.info.length
                           db "Code"   ;cp_info.info.bytes[length]
 
    _00000038__cp_info_000A:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x0F   ;cp_info.info.length
                           db "LineNumberTable"   ;cp_info.info.bytes[length]
 
    _0000004A__cp_info_000B:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x04   ;cp_info.info.length
                           db "main"   ;cp_info.info.bytes[length]
 
    _00000051__cp_info_000C:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x16   ;cp_info.info.length
                           db "([Ljava/lang/String;)V"   ;cp_info.info.bytes[length]
 
    _0000006A__cp_info_000D:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x0A   ;cp_info.info.length
                           db "SourceFile"   ;cp_info.info.bytes[length]
 
    _00000077__cp_info_000E:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x11   ;cp_info.info.length
                           db "EHLOWorldApp.java"   ;cp_info.info.bytes[length]
 
    _0000008B__cp_info_000F:
                           db 0x0C     ;cp_info.tag: CONSTANT_NameAndType
                           db 0,0x07   ;cp_info.info.name_index
                           db 0,0x08   ;cp_info.info.descriptor_index
 
    _00000090__cp_info_0010:
                           db 0x07    ;cp_info.tag: CONSTANT_Class
                           db 0,0x17  ;cp_info.info.name_index
 
    _00000093__cp_info_0011:
                           db 0x0C     ;cp_info.tag: CONSTANT_NameAndType
                           db 0,0x18   ;cp_info.info.name_index
                           db 0,0x19   ;cp_info.info.descriptor_index
 
    _00000098__cp_info_0012:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x0C   ;cp_info.info.length
                           db "Hello World."   ;cp_info.info.bytes[length]
 
    _000000A6__cp_info_0013:
                           db 0x07    ;cp_info.tag: CONSTANT_Class
                           db 0,0x1A  ;cp_info.info.name_index
 
    _000000A9__cp_info_0014:
                           db 0x0C     ;cp_info.tag: CONSTANT_NameAndType
                           db 0,0x1B   ;cp_info.info.name_index
                           db 0,0x1C   ;cp_info.info.descriptor_index
 
    _000000AE__cp_info_0015:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x0C   ;cp_info.info.length
                           db "EHLOWorldApp"   ;cp_info.info.bytes[length]
 
    _000000BD__cp_info_0016:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x10   ;cp_info.info.length
                           db "java/lang/Object"   ;cp_info.info.bytes[length]
 
    _000000D0__cp_info_0017:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x10   ;cp_info.info.length
                           db "java/lang/System"   ;cp_info.info.bytes[length]
 
    _000000E3__cp_info_0018:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x03   ;cp_info.info.length
                           db "out"   ;cp_info.info.bytes[length]
 
    _000000E9__cp_info_0019:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x15   ;cp_info.info.length
                           db "Ljava/io/PrintStream;"   ;cp_info.info.bytes[length]
 
    _00000101__cp_info_001A:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x13   ;cp_info.info.length
                           db "java/io/PrintStream"   ;cp_info.info.bytes[length]
 
    _00000117__cp_info_001B:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x07   ;cp_info.info.length
                           db "println"   ;cp_info.info.bytes[length]
 
    _00000121__cp_info_001C:
                           db 0x01     ;cp_info.tag: CONSTANT_Utf8
                           db 0,0x15   ;cp_info.info.length
                           db "(Ljava/lang/String;)V"   ;cp_info.info.bytes[length]
 
                        __1D:
                           db 0x08    ;cp_info.tag: CONSTANT_String
                           db 0,0x12  ;cp_info.info.string_index
 
 
 
 
_00000139__access_flags:
                       db 0x00,0x20
 
 
_0000013B__this_class:
                       db 0x00,0x05
 
_0000013D__super_class:
                       db 0x00,0x06
 
_0000013F__interfaces_count:
                       db 0x00,0x00
 
;interfaces ------- no interfaces
 
 
_00000141__fields_count:
                       db 0x00,0x00
 
 
;field_info ------- no fields
 
 
_00000143__methods_count:
                       db 0x00,0x02
 
 
        _00000145__method_info_0001:
                               db 0x00,0x00     ;access_flags
                               db 0x00,0x07     ;name_index
                               db 0x00,0x08     ;descriptor_index
                               db 0x00,0x01     ;attributes_count
                                   db 0x00,0x09   ;code_attribute/attribute_info[0].attribute_name_index
                                   db 0x00,0x00,0x00,(0x1D)   ;code_attribute/attribute_info[0].attribute_length
 
                                   db 0X00,0X01       ;code_attribute.max_stack
                                   db 0X00,0X01       ;code_attribute.max_locals
                                   db 0X00,0X00,0X00,0X05   ;code_attribute.code_length
 
                                      ;INIT: Instructions
                                      ;INIT: Instructions
                                      ;INIT: Instructions
                                      ;INIT: Instructions
 
                                        db 0X2A         ;aload_0
 
                                        db 0XB7         ;invokespecial #1
                                        db 0X00
                                        db 0X01
 
                                        db 0XB1         ;return
 
                                      ;END: Instructions
                                      ;END: Instructions
                                      ;END: Instructions
                                      ;END: Instructions
 
 
 
                                   db 0X00,0X00    ;code_attribute.exception_table_length
 
 
                                   db 0X00,0x01    ;code_attribute.attributes_count       ;1
 
                                       db 0X00,0X0A             ;LineNumberTable_attribute/attribute_info.attribute_name_index
                                       db 0X00,0X00,0X00,0X06   ;LineNumberTable_attribute/attribute_info.attribute_length
                                           db 0X00,0X01       ;LineNumberTable_attribute.line_number_table_length
                                               db 0X00,0X00       ;line_number_table[0].start_pc
                                               db 0X00,0X05       ;line_number_table[0].line_number
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        _00000170__method_info_0002:
                               db 0x00,0x09     ;access_flags
                               db 0x00,0x0B     ;name_index
                               db 0x00,0x0C     ;descriptor_index
                               db 0x00,0x01     ;attributes_count
                                   db 0x00,0x09   ;code_atribute/attribute_info[0].attribute_name_index
                                   db 0x00,0x00,0x00,(0x25)   ;code_atribute/attribute_info[0].attribute_length
x17E:
                                   db 0x00,0x02      ;code_attribute.max_stack
                                   db 0x00,0x01      ;code_attribute.max_locals
                                   db 0x00,0x00,0x00,(0x09)  ;code_attribute.code_length
 
                                      ;INIT: Instructions
                                      ;INIT: Instructions
                                      ;INIT: Instructions
                                      ;INIT: Instructions
 
 
                                        db 0xB2      ;getstatic #2
                                        db 0x00
                                        db 0x02
 
                                        db 0x12      ;ldc #3
                                        db 0x1D
 
                                        db 0xB6      ;invokevirtual #4
                                        db 0x00
                                        db 0x04
 
                                        db 0xB1      ;return
 
                                      ;END: Instructions
                                      ;END: Instructions
                                      ;END: Instructions
                                      ;END: Instructions
 
                                   db 0x00,0x00      ;code_attribute.exception_table_length
 
 
                                   db 0x00,0x01      ;code_attribute.attributes_count    ;1
 
                                       db 0x00,0x0A              ;LineNumberTable_attribute/attrbute_info.attribute_name_index
                                       db 0x00,0x00,0x00,0x0A    ;LineNumberTable_attribute/attribute_info.attribute_length
                                             db 0x00,0x02       ;LineNumberTable_attribute.line_number_table_length
                                                 db 0x00,0x00       ;line_number_table[0].start_pc
                                                 db 0x00,0x07       ;line_number_table[0].line_number
 
                                                 db 0x00,0x08       ;line_number_table[1].start_pc
                                                 db 0x00,0x08       ;line_number_table[1].line_number
 
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f_000001A3__attributes_count db 0x00,0x01     ;attributes_count           ;1
                                db 0x00,0x0D   ;SourceFile_attribute/attribute_info[0].attribute_name_index
                                db 0x00,0x00,0x00,0x02   ;SourceFile_attribute/attribute_info[0].attribute_length
 
 
                                db 0x00,0x0E         ;SourceFile_attribute.sourcefile_index
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
información
Otras secciones de LWP con contenido de Java
- Código fuente de Java
- Cursos de Java
- Temas de Java
- Chat de Java
información
Códigos de Java
- Mostrar Imagenes
- Medir resistencias
- Gestor de libros