Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
19 June, 2013, 18:11:57 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1] 2 3 ... 9   Go Down
  Print  
Author Topic: Khavi: Java on the Prizm -  (Read 8865 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
z80man
Casio Traitor
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 10 June, 2013, 08:37:04
Date Registered: 26 December, 2010, 10:02:50
Location: City 17
Posts: 966


Topic starter
Total Post Ratings: +83

View Profile
« on: 04 April, 2011, 06:34:23 »
0

Many of you here have requested a java virtual machine for the Prizm. (most notably Ashbad  Wink) Well I have been studying my java bytecode and I believe that this is quite possible. If you did not know, java bytecode is a stack oriented language in which the Prizm excels at. Now I did not find any of the jazelle extensions that the arm has, but it doesn't mean that java is impossible. What can be done is code the proper functions for each of the instructions, some of which would only take 1 SH3 instruction. The other thing to do is remove all of those fancy, but unnecessary features of the JVM. Stuff like malicious code testing and maybe partial garbage collecting. So right now I'm kind of busy with about 4 other Prizm projects that I'm working on, but during the summer or maybe after the AP exams, I will have time to get started on this.


EDIT: Changed topic title to include the project name
« Last Edit: 11 May, 2011, 03:22:22 by Qwerty.55 » Logged


List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)
graphmastur
King Graphmastur
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 02 February, 2013, 08:34:45
Date Registered: 03 June, 2010, 21:15:55
Posts: 2262


Total Post Ratings: +60

View Profile
« Reply #1 on: 04 April, 2011, 13:18:15 »
0

It sounds interesting, but do you not need a VM to maintain the state of all the objects and run threads?
Logged

Munchor
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 13 June, 2013, 19:29:09
Date Registered: 16 October, 2010, 15:39:13
Location: Position
Posts: 6209


Total Post Ratings: +174

View Profile
« Reply #2 on: 04 April, 2011, 13:36:07 »
0

Many of you here have requested a java virtual machine for the Prizm. (most notably Ashbad  Wink) Well I have been studying my java bytecode and I believe that this is quite possible. If you did not know, java bytecode is a stack oriented language in which the Prizm excels at. Now I did not find any of the jazelle extensions that the arm has, but it doesn't mean that java is impossible. What can be done is code the proper functions for each of the instructions, some of which would only take 1 SH3 instruction. The other thing to do is remove all of those fancy, but unnecessary features of the JVM. Stuff like malicious code testing and maybe partial garbage collecting. So right now I'm kind of busy with about 4 other Prizm projects that I'm working on, but during the summer or maybe after the AP exams, I will have time to get started on this.

This looks like a great idea. There was once a topic about Java on the NSpire, so I hope this turns out right for the PRIZM Cheesy
Logged
Ashbad
Guest
« Reply #3 on: 04 April, 2011, 14:39:58 »
0

Smiley
Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 10:47:05
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50634


Total Post Ratings: +2639

View Profile WWW
« Reply #4 on: 05 April, 2011, 21:01:45 »
0

Java would be nice, assuming it's feasible. A bunch of people in the community already knows Java and maybe Builderboy could port some of his games to the Prizm. Tongue
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Munchor
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 13 June, 2013, 19:29:09
Date Registered: 16 October, 2010, 15:39:13
Location: Position
Posts: 6209


Total Post Ratings: +174

View Profile
« Reply #5 on: 05 April, 2011, 21:04:44 »
0

Java would be nice, assuming it's feasible. A bunch of people in the community already knows Java and maybe Builderboy could port some of his games to the Prizm. Tongue

The Silencer on the PRIZM? Crazy
Logged
t0xic_kitt3n
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 13 May, 2013, 01:56:35
Date Registered: 16 June, 2010, 20:46:00
Location: w,x,y,z
Posts: 1583


Total Post Ratings: +32

View Profile
« Reply #6 on: 08 April, 2011, 17:23:15 »
0

Java would be nice, assuming it's feasible. A bunch of people in the community already knows Java and maybe Builderboy could port some of his games to the Prizm. Tongue
We could have multi platform games!
Logged




██████  ██  ██  ███████           ████    ██    ██   ██ ███████
█ ██ █  ██  ██   ██   █          ██  ██  ████   ███ ███  ██   █
  ██    ██  ██   ██             ██   ██ ██  ██  ███████  ██    
  ██    ██  ██   ██  █         ██       ██  ██  ███████  ██  █
  ██    ██████   █████         ██       ██  ██  ██ █ ██  █████ 
  ██    ██  ██   ██  █         ██   ███ ██████  ██   ██  ██  █
  ██    ██  ██   ██             ██   ██ ██  ██  ██   ██  ██    
  ██    ██  ██   ██   █          ██  ██ ██  ██  ██   ██  ██   █
 ████   ██  ██  ███████           █████ ██  ██  ██   ██ ███████

AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 01:08:43
Date Registered: 15 August, 2010, 09:18:54
Posts: 3192


Total Post Ratings: +222

View Profile
« Reply #7 on: 11 April, 2011, 09:46:33 »
+2

Okay, I took the liberty of spending a few days exploring the JVM and how it works. It's surprisingly simple. I see absolutely no reason why would we couldn't get a JVM running on the Prizm.

I spent an hour tonight and wrote a routine to parse/validate about half of the .class file format (the rest should be fairly easy to parse). It could probably be used as initialization code for such a JVM.


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
General Parser form:

If R0 holds a pointer to the first byte of the .class file

STC.L SR,@–R15 // Store value to RET to.
MOV.L @R0+,R1
MOV.L (Magic),R2
XOR R1,R2 // If both values are the same, 0->R2
TST R2,R2
BT/S Parse
NOP
RET
(Magic) 0xCAFEBABE

ParseVer:
XOR R4,R4
MOV.L @R0+,R1
MOV.L (Min Major_Minor),R2
MOV.L (Max Major_Minor),R3
CMP/HS R2,R1 // If min version>version
ROTL R4
CMP/HS R1,R3 // If version>max version
ROTL R4
TST R4,R4 // If both false, 1->T
BT/S ParseConst
NOP
RET
(Min Major_Minor) 0x** ** ** ** // Upper two bytes are major version, lower two bytes are minor
(Max Major_Minor) 0x** ** ** ** // Same as before

ParseConst:
MOV.L R0,@R15- // Store pointer to Constant pool
MOV.W @R0+,R1
ROTL R1
CLRT
ROTR R1
MOV.L R1,R8
ADD R1,R0 // Skip over Constant pool

ParseFlags:
XOR R12,R12 //Clear flag register
MOV.W @R0+,R1
ROTL R1
CLRT
ROTR R1
<Other flag checking?>
OR R1,R12 // Add Access flags to lower 16 bits of flag register

ParseClasses:
CLRT
XOR R2,R2
XOR R4,R4
MOV.L @R0-,R1
MOV.B 0x10,R3

Loop1:
ADD 0xFF,R3
ROTR R3
BF/S Loop1
ROTL R2 // Move super_class index into R2

CMP/HS R1,R8
ROTL R4
CMP/HS R2,R8
ROTL R4
TST R8,R1
BT/S GetIndices1
NOP
RET
GetIndices1:
MOV.L @R15+,R7
MOV.L R7,@R15-
ADD R7,R1
MOV.W @R1,R1
<Handle this_class>
ADD R7,R2
MOV.W @R2,R2
<Handle super_class>
Parsefurther:
Etc...

Also, I have a full instruction list of the JVM, along with a few SH3 ASM routines I wrote that happen to perform those operations.

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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
During runtime, the following are assumed:

R12 is a 32 bit flag register.
R13 holds PC.
R14 points to the operand stack.
R15 is a stack for interpreter use.


aaload
0x32

aastore
0x53

aconst_null
0x01

aload
0x19
Also supports Wide format, which means the opcode is preceded by 0xC4

aload_<n>
aload_0 opcode = 0x2A
aload_1 opcode = 0x2B
aload_2 opcode = 0x2C
aload_3 opcode = 0x2D

anewarray
0xBD

areturn
0xB0

arraylength
0xBE

astore
0x3A
Also supports Wide format, which means the opcode is preceded by 0xC4

astore_<n>
astore_0 opcode = 0x4B
astore_1 opcode = 0x4C
astore_2 opcode = 0x4D
astore_3 opcode = 0x4E

athrow
0xBF

baload
0x33

bastore
0x54

bipush
0x10

breakpoint
0xCA
Reserved opcode. Should not appear in any .class file.

caload
0x34

castore
0x55

checkcast


d2f


d2i


d2l


dadd


daload


dastore


dcmpg


dcmpl


dconst_<d>


ddiv


dload


dload_<n>


dmul


dneg


drem


dreturn


dstore


dstore_<n>


dsub


dup


dup2


dup2_x1


dup2_x2


dup_x1


dup_x2


f2d


f2i


f2l


fadd
0x62

faload


fastore


fcmpg


fcmpl


fconst_<f>
fconst_0 opcode = 0x0B (11)
fconst_1 opcode = 0x0C (12)
fconst_2 opcode = 0x0D

fdiv
0x6E

fload


fload_<n>


fmul
0x6A

fneg
0x6A

frem


freturn


fstore


fstore_<n>


fsub


getfield


getstatic


goto


goto_w


i2b


i2c


i2d


i2f


i2l


i2s


iadd
0x60

iaload


iand
0x7E

iastore


iconst_<n>


iconst_m1


idiv
0x6C

if_acmpeq


if_acmpne


if_icmpeq


if_icmpge


if_icmpgt


if_icmple


if_icmplt


if_icmpne


ifeq


ifge


ifgt


ifle



iflt


ifne



ifnonnull


ifnull


iinc


iload


iload_<n>


impdep1


impdep2


imul


ineg


instanceof


invokeinterface


invokespecial


invokestatic


invokevirtual


ior
0x80
MOV.L @R14+,R1
MOV.L @R14+,R2
OR R2,R1
MOV.L R1

irem
0x70
MOV.L @R14+,R0
MOV.L @R14+,R2
MOV R2,R3
SUB R0,R3
MOV $20,R4
DIV0U R0,R1
Startdiv:
ADD $FF,R4
DIV1 R0,R1
TST R4,R4
BT/S Startdiv
ROTCL R2
DMULU.L R2,R3
STS MACL,R2
MOV.L R2,@-R14

ireturn


ishl


ishr


istore


istore_<n>


isub


iushr


ixor
0x82
MOV.L @R14+,R1
MOV.L @R14+,R2
XOR R2,R1
MOV.L R1

jsr
0xA8

jsr_w
0xC9

l2d


l2f


l2i


ladd
0x61

laload


land


lastore


lcmp


lconst_<l>


ldc


ldc_w


ldc2_w


ldiv


lload


lload_<n>


lmul


lneg


lookupswitch


lor


lrem


lreturn


lshl


lshr


lstore


lstore_<n>


lsub


lushr


lxor
0x83

monitorenter


monitorexit


multianewarray


new


newarray


nop
0x00

pop


pop2


putfield


putstatic


ret


return


saload


sastore


sipush


swap


tableswitch


wide

Opcodes and descriptions can be found here.

It sounds interesting, but do you not need a VM to maintain the state of all the objects and run threads?

That depends on what you mean by "Virtual machine." The JVM is essentially nothing more than an interpreter. It just happens to interpret the machine code for a virtual machine.
« Last Edit: 11 April, 2011, 09:58:59 by Qwerty.55 » Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Munchor
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 13 June, 2013, 19:29:09
Date Registered: 16 October, 2010, 15:39:13
Location: Position
Posts: 6209


Total Post Ratings: +174

View Profile
« Reply #8 on: 11 April, 2011, 11:24:23 »
0

Okay, I took the liberty of spending a few days exploring the JVM and how it works. It's surprisingly simple. I see absolutely no reason why would we couldn't get a JVM running on the Prizm.

I spent an hour tonight and wrote a routine to parse/validate about half of the .class file format (the rest should be fairly easy to parse). It could probably be used as initialization code for such a JVM.


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
General Parser form:

If R0 holds a pointer to the first byte of the .class file

STC.L SR,@–R15 // Store value to RET to.
MOV.L @R0+,R1
MOV.L (Magic),R2
XOR R1,R2 // If both values are the same, 0->R2
TST R2,R2
BT/S Parse
NOP
RET
(Magic) 0xCAFEBABE

ParseVer:
XOR R4,R4
MOV.L @R0+,R1
MOV.L (Min Major_Minor),R2
MOV.L (Max Major_Minor),R3
CMP/HS R2,R1 // If min version>version
ROTL R4
CMP/HS R1,R3 // If version>max version
ROTL R4
TST R4,R4 // If both false, 1->T
BT/S ParseConst
NOP
RET
(Min Major_Minor) 0x** ** ** ** // Upper two bytes are major version, lower two bytes are minor
(Max Major_Minor) 0x** ** ** ** // Same as before

ParseConst:
MOV.L R0,@R15- // Store pointer to Constant pool
MOV.W @R0+,R1
ROTL R1
CLRT
ROTR R1
MOV.L R1,R8
ADD R1,R0 // Skip over Constant pool

ParseFlags:
XOR R12,R12 //Clear flag register
MOV.W @R0+,R1
ROTL R1
CLRT
ROTR R1
<Other flag checking?>
OR R1,R12 // Add Access flags to lower 16 bits of flag register

ParseClasses:
CLRT
XOR R2,R2
XOR R4,R4
MOV.L @R0-,R1
MOV.B 0x10,R3

Loop1:
ADD 0xFF,R3
ROTR R3
BF/S Loop1
ROTL R2 // Move super_class index into R2

CMP/HS R1,R8
ROTL R4
CMP/HS R2,R8
ROTL R4
TST R8,R1
BT/S GetIndices1
NOP
RET
GetIndices1:
MOV.L @R15+,R7
MOV.L R7,@R15-
ADD R7,R1
MOV.W @R1,R1
<Handle this_class>
ADD R7,R2
MOV.W @R2,R2
<Handle super_class>
Parsefurther:
Etc...

Also, I have a full instruction list of the JVM, along with a few SH3 ASM routines I wrote that happen to perform those operations.

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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
During runtime, the following are assumed:

R12 is a 32 bit flag register.
R13 holds PC.
R14 points to the operand stack.
R15 is a stack for interpreter use.


aaload
0x32

aastore
0x53

aconst_null
0x01

aload
0x19
Also supports Wide format, which means the opcode is preceded by 0xC4

aload_<n>
aload_0 opcode = 0x2A
aload_1 opcode = 0x2B
aload_2 opcode = 0x2C
aload_3 opcode = 0x2D

anewarray
0xBD

areturn
0xB0

arraylength
0xBE

astore
0x3A
Also supports Wide format, which means the opcode is preceded by 0xC4

astore_<n>
astore_0 opcode = 0x4B
astore_1 opcode = 0x4C
astore_2 opcode = 0x4D
astore_3 opcode = 0x4E

athrow
0xBF

baload
0x33

bastore
0x54

bipush
0x10

breakpoint
0xCA
Reserved opcode. Should not appear in any .class file.

caload
0x34

castore
0x55

checkcast


d2f


d2i


d2l


dadd


daload


dastore


dcmpg


dcmpl


dconst_<d>


ddiv


dload


dload_<n>


dmul


dneg


drem


dreturn


dstore


dstore_<n>


dsub


dup


dup2


dup2_x1


dup2_x2


dup_x1


dup_x2


f2d


f2i


f2l


fadd
0x62

faload


fastore


fcmpg


fcmpl


fconst_<f>
fconst_0 opcode = 0x0B (11)
fconst_1 opcode = 0x0C (12)
fconst_2 opcode = 0x0D

fdiv
0x6E

fload


fload_<n>


fmul
0x6A

fneg
0x6A

frem


freturn


fstore


fstore_<n>


fsub


getfield


getstatic


goto


goto_w


i2b


i2c


i2d


i2f


i2l


i2s


iadd
0x60

iaload


iand
0x7E

iastore


iconst_<n>


iconst_m1


idiv
0x6C

if_acmpeq


if_acmpne


if_icmpeq


if_icmpge


if_icmpgt


if_icmple


if_icmplt


if_icmpne


ifeq


ifge


ifgt


ifle



iflt


ifne



ifnonnull


ifnull


iinc


iload


iload_<n>


impdep1


impdep2


imul


ineg


instanceof


invokeinterface


invokespecial


invokestatic


invokevirtual


ior
0x80
MOV.L @R14+,R1
MOV.L @R14+,R2
OR R2,R1
MOV.L R1

irem
0x70
MOV.L @R14+,R0
MOV.L @R14+,R2
MOV R2,R3
SUB R0,R3
MOV $20,R4
DIV0U R0,R1
Startdiv:
ADD $FF,R4
DIV1 R0,R1
TST R4,R4
BT/S Startdiv
ROTCL R2
DMULU.L R2,R3
STS MACL,R2
MOV.L R2,@-R14

ireturn


ishl


ishr


istore


istore_<n>


isub


iushr


ixor
0x82
MOV.L @R14+,R1
MOV.L @R14+,R2
XOR R2,R1
MOV.L R1

jsr
0xA8

jsr_w
0xC9

l2d


l2f


l2i


ladd
0x61

laload


land


lastore


lcmp


lconst_<l>


ldc


ldc_w


ldc2_w


ldiv


lload


lload_<n>


lmul


lneg


lookupswitch


lor


lrem


lreturn


lshl


lshr


lstore


lstore_<n>


lsub


lushr


lxor
0x83

monitorenter


monitorexit


multianewarray


new


newarray


nop
0x00

pop


pop2


putfield


putstatic


ret


return


saload


sastore


sipush


swap


tableswitch


wide

Opcodes and descriptions can be found here.

It sounds interesting, but do you not need a VM to maintain the state of all the objects and run threads?

That depends on what you mean by "Virtual machine." The JVM is essentially nothing more than an interpreter. It just happens to interpret the machine code for a virtual machine.

Qwerty: That looks awesome!

Do compiled programs need Java or some special app in the calculator to run? How fast is it?

Java on the Prizm, now I want a PRIZM even more.
Logged
z80man
Casio Traitor
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 10 June, 2013, 08:37:04
Date Registered: 26 December, 2010, 10:02:50
Location: City 17
Posts: 966


Topic starter
Total Post Ratings: +83

View Profile
« Reply #9 on: 11 April, 2011, 21:26:01 »
0

What will be needed is some sort of JVM to run .class files. There are two ways to do this:
1. The JVM is made like a shell that loads the program into ram and then executes it.
2. My other plan was in the asm shell I'm currently working on is to allow programs to register an extension

-hold on for more, bell just rang
Logged


List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)
AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 01:08:43
Date Registered: 15 August, 2010, 09:18:54
Posts: 3192


Total Post Ratings: +222

View Profile
« Reply #10 on: 11 April, 2011, 21:28:57 »
+1

I finished the routine to parse .class file headers right before you posted this...

EDIT:

The extensions are going to be stored in whatever file allocation table the Prizm uses, probably appended to the name of the file itself. That table would also contain a pointer to the file for easy access.

Also:


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
General Parser form:

If R0 holds pointer to the first byte of the .class file

STC.L SR,@–R15 // Store value to RET to.
MOV.L @R0+,R1
MOV.L (Magic),R2
XOR R1,R2 // If both values are the same, 0->R2
TST R2,R2
BT/S Parse
NOP
RET
(Magic) 0xCAFEBABE

ParseVer:
XOR R4,R4
MOV.L @R0+,R1
MOV.L (Min Major_Minor),R2
MOV.L (Max Major_Minor),R3
CMP/HS R2,R1 // If min version>version
ROTL R4
CMP/HS R1,R3 // If version>max version
ROTL R4
TST R4,R4 // If both false, 1->T
BT/S ParseConst
NOP
RET
(Min Major_Minor) 0x** ** ** ** // Upper two bytes are major version, lower two bytes are minor
(Max Major_Minor) 0x** ** ** ** // Same as before

ParseConst:
MOV.L R0,@R15- // Store pointer to Constant pool
MOV.W @R0+,R1
MOV.L R1,R8
ROTL R1
ADD R1,R0 // Skip over Constant pool

ParseFlags:
XOR R12,R12 //Clear flag register
MOV.W @R0+,R1
ROTL R1
CLRT
ROTR R1
<Other flag checking?>
OR R1,R12 // Add Access flags to lower 16 bits of flag register

ParseClasses:
XOR R2,R2
XOR R4,R4
MOV.L @R0-,R1
MOV.B 0x10,R3
CLRT
Loop1:
ADD 0xFF,R3
ROTR R3
TST R3,R3
BF/S Loop1
ROTL R2 // Move super_class index into R2

CMP/HS R1,R8
ROTL R4
CMP/HS R2,R8
ROTL R4
TST R4,R4
BT/S GetIndices1
NOP
RET

GetIndices1:
MOV.L @R15+,R7
MOV.L R7,@R15-
ADD R7,R1
MOV.W @R1,R1
<Handle this_class>
ADD R7,R2
MOV.W @R2,R2
<Handle super_class>

Parsefurther:
MOV.L R0,@15-
MOV.W @R0+,R1
MOV.W R1,R4
XOR R2.R2
Loop2:
ADD 0xFF,R1
MOV.W @R0+,R3
CMP/HS R3,R8 // R8 must be carried from the previous sections!
TST R1,R1
BF/S Loop1
ADD 0x01,R2
ADD 0xFF,R2
CMP/EQ R2,R4
BT/S FieldsMethods
NOP
RET
FieldsMethods:
MOV 0x01,R3
Loop3:
MOV.L R0,@R15-
MOV.W @R0+,R1
MOV 0x04,R2
MULU.W R1,R2
STS MACL,R1
ADD R1,R0
TST R3
BF/S Loop3
ADD 0xFF,R3

Parseattribs:
MOV.W @R0+,R1
MOV 0x07,R2
MULU.W R1,R2
STS MACL,R2
MOV.L R0,@R15-
ADD R2,R0
ParseInstruct:
Etc...

When it's reached the end of the header, the stack contains pointers to the Attributes table, the methods table, the fields table, the constant pool table, as well as a pointer to a the location to exit to. There might are a few bugs in this code that I still have to fix, but it's mostly functional.
« Last Edit: 11 April, 2011, 21:50:42 by Qwerty.55 » Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
z80man
Casio Traitor
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 10 June, 2013, 08:37:04
Date Registered: 26 December, 2010, 10:02:50
Location: City 17
Posts: 966


Topic starter
Total Post Ratings: +83

View Profile
« Reply #11 on: 12 April, 2011, 05:46:32 »
0

@Qwerty I see an optimization in there. When you use the MULU.L instruction do not follow it with the STS MACL. If you access the MAC following a multiply instruction, MULU will take 3 cycles, but if you put at least one other instruction in between the MULU and the STS, then MULU only takes 1 cycle Wink

And the idea with the extensions was for the asm shell. Just like Doors the shell doesn't have to be for asm programs only. Added features could be BASIC progs too. But my main idea was that the shell would have something like a registry found on windows systems. Because on windows for example Microsoft word will register the .doc file extension to itself. So whenever you select a .doc file, word will open that file. The same idea could apply to a .class file on the shell. When a .class file is selected then the JVM will be ran with a pointer to the file to run, passed as an argument.
Logged


List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)
AngelFish
This is my custom title
Administrator
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 01:08:43
Date Registered: 15 August, 2010, 09:18:54
Posts: 3192


Total Post Ratings: +222

View Profile
« Reply #12 on: 12 April, 2011, 05:51:22 »
0

Nice catch. I must have missed that.

However, I just noticed a simpler way of detecting .class files: use the "magic" number 0xCAFEBABE. It's present in all .class files, so it can identify them and my file format can easily allow that particular header to be invalid.
Logged

∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ
Munchor
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 13 June, 2013, 19:29:09
Date Registered: 16 October, 2010, 15:39:13
Location: Position
Posts: 6209


Total Post Ratings: +174

View Profile
« Reply #13 on: 12 April, 2011, 16:50:51 »
0

[A bit Offtopic]

Qwerty, I just noticed you're already writing SH3 (PRIZM) assembly very well, never expected you guys to dominate it so fast Smiley Nice job
Logged
z80man
Casio Traitor
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 10 June, 2013, 08:37:04
Date Registered: 26 December, 2010, 10:02:50
Location: City 17
Posts: 966


Topic starter
Total Post Ratings: +83

View Profile
« Reply #14 on: 12 April, 2011, 20:44:21 »
0

Nice catch. I must have missed that.

However, I just noticed a simpler way of detecting .class files: use the "magic" number 0xCAFEBABE. It's present in all .class files, so it can identify them and my file format can easily allow that particular header to be invalid.
Yes that is an easier way of detecting class files, but when it comes to a shell that is designed for any file format type, using something like 0xCAFEBABE is not universal. So it might be easier if the first time you run the java program it does a call to the libraries of the shell with "class"  and an icon as an argument. Then when viewing files in a screen similar to Doors, all class files will have a coffee cup icon and when you click on it java will be run with the class file as an arg
Logged


List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)
Pages: [1] 2 3 ... 9   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.491 seconds with 32 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.