kompiler 0.1.2 → 0.2.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kompiler/architectures/armv8a/instructions.rb +95 -86
- data/lib/kompiler/mc_builder.rb +10 -0
- data/lib/kompiler/parsers.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69b1e8272e45a6c9ce0b8bb60dbfb89b0d65d0f8f615cbd744726857ecf1d94f
|
4
|
+
data.tar.gz: eba0c518a787b345d191a2cf41e76ecb52ca25dac10f14f17b72d5cbbcb2f201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a325a47eff59b3766cead44c9e81063773af594e224d96aa667b7015a7a469d10be65e0ecdb68b36db88645472ae320309e92872ba568c3ed32f8da4525b113e
|
7
|
+
data.tar.gz: 31881ac3bba3ac3e3afa0a1c87366ea1680c32189d07cbdcd62e7eee33b19712fb85c0198b91b2315377e1f16ad0a973c95083810ef0a125c4a385ea84774101
|
@@ -275,33 +275,28 @@ end
|
|
275
275
|
],
|
276
276
|
bitsize: 32
|
277
277
|
},
|
278
|
+
|
278
279
|
{
|
279
280
|
keyword: "ldr",
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
284
|
-
["get_bits", 0, 0, 12], # Immediate offset zero
|
285
|
-
["bits", 1,0, 1,0, 0, 1,1,1, 1,1],
|
286
|
-
],
|
287
|
-
bitsize: 32
|
288
|
-
},
|
289
|
-
{
|
290
|
-
keyword: "ldr",
|
291
|
-
operands: [{type: "register", restrictions: {reg_size: 32}}, {type: "register", restrictions: {reg_size: 64}}],
|
281
|
+
name: "Load Register",
|
282
|
+
description: "Loads 4 or 8 bytes from memory at the address in the second register, and writes it to the destination register",
|
283
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Destination"}, {type: "register", restrictions: {reg_type: "gpr", reg_size: 64}, name: "Source address"}],
|
292
284
|
mc_constructor: [
|
293
285
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
294
286
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
295
287
|
["get_bits", 0, 0, 12], # Immediate offset zero
|
296
|
-
["bits", 1,0, 1,0, 0, 1,1,1
|
288
|
+
["bits", 1,0, 1,0, 0, 1,1,1],
|
289
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []],
|
290
|
+
["bits", 1],
|
297
291
|
],
|
298
292
|
bitsize: 32
|
299
293
|
},
|
294
|
+
|
300
295
|
{
|
301
296
|
keyword: "ldrb",
|
302
297
|
name: "Load Register Byte",
|
303
298
|
description: "Loads a byte from memory and writes the result to the destination register.",
|
304
|
-
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Destination"}, {type: "register", restrictions: {reg_size: 64, reg_type: "gpr"}, name: "Source address"}],
|
299
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr", reg_size: 32}, name: "Destination"}, {type: "register", restrictions: {reg_size: 64, reg_type: "gpr"}, name: "Source address"}],
|
305
300
|
mc_constructor: [
|
306
301
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
307
302
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
@@ -321,41 +316,19 @@ end
|
|
321
316
|
],
|
322
317
|
bitsize: 32
|
323
318
|
},
|
324
|
-
{
|
325
|
-
keyword: "str",
|
326
|
-
description: "Stores the contents of a 32 bit register at the address specified by the second register",
|
327
|
-
operands: [{type: "register", restrictions: {reg_size: 32}, name: "Content"}, {type: "register", restrictions: {reg_size: 64}, name: "Address"}],
|
328
|
-
mc_constructor: [
|
329
|
-
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
330
|
-
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
331
|
-
["get_bits", 0, 0, 12], # Immediate offset zero
|
332
|
-
["bits", 0,0, 1,0, 0, 1,1,1, 0,1],
|
333
|
-
],
|
334
|
-
bitsize: 32
|
335
|
-
},
|
336
|
-
{
|
337
|
-
keyword: "str",
|
338
|
-
description: "Stores the contents of a 64 bit register at the address specified by the second register",
|
339
|
-
operands: [{type: "register", restrictions: {reg_size: 64}, name: "Content"}, {type: "register", restrictions: {reg_size: 64}, name: "Address"}],
|
340
|
-
mc_constructor: [
|
341
|
-
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
342
|
-
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
343
|
-
["get_bits", 0, 0, 12], # Immediate offset zero
|
344
|
-
["bits", 0,0, 1,0, 0, 1,1,1, 1,1],
|
345
|
-
],
|
346
|
-
bitsize: 32
|
347
|
-
},
|
348
319
|
|
349
320
|
{
|
350
|
-
keyword: "
|
351
|
-
name: "
|
352
|
-
description: "Stores the contents of a
|
353
|
-
operands: [{type: "register", restrictions: {
|
321
|
+
keyword: "str",
|
322
|
+
name: "Store",
|
323
|
+
description: "Stores the contents of a 64 bit register at the address specified by the second register.",
|
324
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Content"}, {type: "register", restrictions: {reg_type: "gpr", reg_size: 64}, name: "Address"}],
|
354
325
|
mc_constructor: [
|
355
326
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
356
327
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
357
|
-
["get_bits",
|
358
|
-
["bits", 0,0, 1,0, 0, 1,1,1
|
328
|
+
["get_bits", 0, 0, 12],
|
329
|
+
["bits", 0,0, 1,0, 0, 1,1,1],
|
330
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []],
|
331
|
+
["bits", 1] # size second bit always 1
|
359
332
|
],
|
360
333
|
bitsize: 32
|
361
334
|
},
|
@@ -364,42 +337,60 @@ end
|
|
364
337
|
keyword: "str_unsigned",
|
365
338
|
name: "STR (immediate), unsigned offset",
|
366
339
|
description: "Stores the contents of a 64 bit register at the address specified by the second register with an unsigned immediate offset.",
|
367
|
-
operands: [{type: "register", restrictions: {
|
340
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Content"}, {type: "register", restrictions: {reg_type: "gpr", reg_size: 64}, name: "Address"}, {type: "immediate", name: "Address Offset"}],
|
368
341
|
mc_constructor: [
|
342
|
+
["case", ["get_key", ["get_operand", 0], :reg_size],
|
343
|
+
64, ["if_eq_else", ["modulo", ["get_operand", 2], 8], 0, [], ["raise_error", "str_unsigned Error: Unsigned offset must be divisible by 8 for 64-bit registers."]],
|
344
|
+
32, ["if_eq_else", ["modulo", ["get_operand", 2], 4], 0, [], ["raise_error", "str_unsigned Error: Unsigned offset must be divisible by 4 for 32-bit registers."]],
|
345
|
+
[]
|
346
|
+
],
|
369
347
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
370
348
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
371
|
-
["get_bits",
|
372
|
-
|
349
|
+
["get_bits",
|
350
|
+
["case", ["get_key", ["get_operand", 0], :reg_size],
|
351
|
+
64, ["divide", ["get_operand", 2], 8],
|
352
|
+
32, ["divide", ["get_operand", 2], 4],
|
353
|
+
["get_operand", 2]
|
354
|
+
],
|
355
|
+
0, 12],
|
356
|
+
["bits", 0,0, 1,0, 0, 1,1,1],
|
357
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []],
|
358
|
+
["bits", 1] # size second bit always 1
|
373
359
|
],
|
374
360
|
bitsize: 32
|
375
361
|
},
|
376
362
|
|
363
|
+
|
377
364
|
{
|
378
365
|
keyword: "str_pre_index",
|
379
366
|
name: "STR (immediate), signed offset, pre-index",
|
380
|
-
description: "Stores the contents of a
|
381
|
-
operands: [{type: "register", restrictions: {
|
367
|
+
description: "Stores the contents of a general purpose register at the address specified by the second register with an immediate offset added before writing.",
|
368
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Content"}, {type: "register", restrictions: {reg_type: "gpr", reg_size: 64}, name: "Address"}, {type: "immediate", name: "Address Offset"}],
|
382
369
|
mc_constructor: [
|
383
370
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
384
371
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
385
372
|
["bits", 1, 1],
|
386
373
|
["get_bits", ["get_operand", 2], 0, 9],
|
387
|
-
["bits", 0, 0,0, 0,0, 0, 1,1,1
|
374
|
+
["bits", 0, 0,0, 0,0, 0, 1,1,1],
|
375
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []],
|
376
|
+
["bits", 1] # size second bit always 1
|
388
377
|
],
|
389
378
|
bitsize: 32
|
390
379
|
},
|
391
380
|
|
392
381
|
{
|
393
|
-
keyword: "
|
394
|
-
name: "STR (immediate), signed offset,
|
395
|
-
description: "Stores the contents of a
|
396
|
-
operands: [{type: "register", restrictions: {
|
382
|
+
keyword: "str_post_index",
|
383
|
+
name: "STR (immediate), signed offset, post-index",
|
384
|
+
description: "Stores the contents of a general purpose register at the address specified by the second register, with an immediate offset added after writing.",
|
385
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Content"}, {type: "register", restrictions: {reg_type: "gpr", reg_size: 64}, name: "Address"}, {type: "immediate", name: "Address Offset"}],
|
397
386
|
mc_constructor: [
|
398
387
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
399
388
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
400
|
-
["bits", 1,
|
389
|
+
["bits", 1, 0],
|
401
390
|
["get_bits", ["get_operand", 2], 0, 9],
|
402
|
-
["bits", 0, 0,0, 0,0, 0, 1,1,1
|
391
|
+
["bits", 0, 0,0, 0,0, 0, 1,1,1],
|
392
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []],
|
393
|
+
["bits", 1] # size second bit always 1
|
403
394
|
],
|
404
395
|
bitsize: 32
|
405
396
|
},
|
@@ -407,69 +398,64 @@ end
|
|
407
398
|
|
408
399
|
{
|
409
400
|
keyword: "cmp",
|
410
|
-
|
401
|
+
name: "Compare (immediate)",
|
402
|
+
description: "Subtracts an immediate value from a register value, and updates the condition flags based on the result.",
|
403
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}}, {type: "immediate"}],
|
411
404
|
mc_constructor: [
|
412
405
|
["bits", 1,1,1,1,1],
|
413
406
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
414
|
-
["get_bits", ["get_operand", 1], 0, 12], # Immediate
|
415
|
-
["bits", 0, 0,1,0,0,0,1, 1, 1
|
407
|
+
["get_bits", ["get_operand", 1], 0, 12], # Immediate value
|
408
|
+
["bits", 0, 0,1,0,0,0,1, 1, 1],
|
409
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []], # sf
|
416
410
|
],
|
417
411
|
bitsize: 32
|
418
412
|
},
|
419
413
|
|
420
414
|
{
|
421
415
|
keyword: "cmp",
|
422
|
-
name: "
|
423
|
-
description: "
|
424
|
-
operands: [{type: "register", restrictions: {
|
416
|
+
name: "Compare (registers)",
|
417
|
+
description: "Subtracts the second register value from the first register value, and updates the condition flags based on the result.",
|
418
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Register 1"}, {type: "register", restrictions: {reg_type: "gpr"}, name: "Register 2"}],
|
425
419
|
mc_constructor: [
|
420
|
+
["if_eq_else", ["get_key", ["get_operand", 0], :reg_size], ["get_key", ["get_operand", 1], :reg_size], [], ["raise_error", "cmp Error: Register sizes are not the same"]],
|
426
421
|
["bits", 1,1,1,1,1], # Rd
|
427
|
-
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
422
|
+
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5], # Rn
|
428
423
|
["get_bits", 0, 0, 6], # Immediate offset zero (shift amount)
|
429
424
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5], # Rm
|
430
425
|
["bits", 0],
|
431
426
|
["bits", 0, 0], # Shift type
|
432
|
-
["bits", 1,1,0,1,0,1,1
|
433
|
-
|
434
|
-
bitsize: 32
|
435
|
-
},
|
436
|
-
|
437
|
-
{
|
438
|
-
keyword: "cmp",
|
439
|
-
name: "CMP (two registers)",
|
440
|
-
description: "Compares two 32-bit registers and updates condition flags based on the result.",
|
441
|
-
operands: [{type: "register", restrictions: {reg_size: 32}, name: "Register 1"}, {type: "register", restrictions: {reg_size: 32}, name: "Register 2"}],
|
442
|
-
mc_constructor: [
|
443
|
-
["bits", 1,1,1,1,1], # Rd
|
444
|
-
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
445
|
-
["get_bits", 0, 0, 6], # Immediate offset zero (shift amount)
|
446
|
-
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5], # Rm
|
447
|
-
["bits", 0],
|
448
|
-
["bits", 0, 0], # Shift type
|
449
|
-
["bits", 1,1,0,1,0,1,1,0],
|
427
|
+
["bits", 1,1,0,1,0,1,1],
|
428
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []], # sf
|
450
429
|
],
|
451
430
|
bitsize: 32
|
452
431
|
},
|
432
|
+
|
453
433
|
|
454
434
|
{
|
455
435
|
keyword: "sub",
|
456
|
-
|
436
|
+
name: "Subtract (immediate)",
|
437
|
+
description: "Subtract an immediate value from a register value, and store the result in the destination register",
|
438
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Destination"}, {type: "register", restrictions: {reg_type: "gpr"}, name: "Source"}, {type: "immediate", name: "Immediate"}],
|
457
439
|
mc_constructor: [
|
440
|
+
["if_eq_else", ["get_key", ["get_operand", 0], :reg_size], ["get_key", ["get_operand", 1], :reg_size], [], ["raise_error", "sub Error: Register sizes are not the same"]],
|
458
441
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
|
459
442
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
|
460
443
|
["get_bits", ["get_operand", 2], 0, 12], # Immediate offset zero
|
461
444
|
["bits", 0], # Shift
|
462
|
-
["bits", 0,1,0,0,0,1,0,1
|
445
|
+
["bits", 0,1,0,0,0,1,0,1],
|
446
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []], # sf
|
463
447
|
],
|
464
448
|
bitsize: 32
|
465
449
|
},
|
466
450
|
|
467
451
|
{
|
468
452
|
keyword: "mul",
|
469
|
-
name: "
|
470
|
-
description: "Multiply the contents of two registers and store the output in the destination register.",
|
471
|
-
operands: [{type: "register", restrictions: {reg_type: "gpr"}}, {type: "register", restrictions: {reg_type: "gpr"}}, {type: "register", restrictions: {reg_type: "gpr"}}],
|
453
|
+
name: "Multiply",
|
454
|
+
description: "Multiply the contents of two registers, and store the output in the destination register.",
|
455
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Destination"}, {type: "register", restrictions: {reg_type: "gpr"}, name: "Register 1"}, {type: "register", restrictions: {reg_type: "gpr"}, name: "Register 2"}],
|
472
456
|
mc_constructor: [
|
457
|
+
["if_eq_else", ["get_key", ["get_operand", 0], :reg_size], ["get_key", ["get_operand", 1], :reg_size], [], ["raise_error", "mul Error: Register sizes are not the same"]],
|
458
|
+
["if_eq_else", ["get_key", ["get_operand", 1], :reg_size], ["get_key", ["get_operand", 2], :reg_size], [], ["raise_error", "mul Error: Register sizes are not the same"]],
|
473
459
|
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5], # Rd
|
474
460
|
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5], # Rn
|
475
461
|
["bits", 1,1,1,1,1, 0], # Ra o0
|
@@ -482,6 +468,29 @@ end
|
|
482
468
|
},
|
483
469
|
|
484
470
|
|
471
|
+
{
|
472
|
+
keyword: "madd",
|
473
|
+
name: "Multiply-Add",
|
474
|
+
description: "Multiplies two register values, adds a third register value, and writes the result to the destination register.",
|
475
|
+
operands: [{type: "register", restrictions: {reg_type: "gpr"}, name: "Destination"}, {type: "register", restrictions: {reg_type: "gpr"}, name: "Register 1 (to multiply)"}, {type: "register", restrictions: {reg_type: "gpr"}, name: "Register 2 (to multiply)"}, {type: "register", restrictions: {reg_type: "gpr"}, name: "Register 3 (to add)"}],
|
476
|
+
mc_constructor: [
|
477
|
+
# Checks for register sizes being the same
|
478
|
+
["if_eq_else", ["get_key", ["get_operand", 0], :reg_size], ["get_key", ["get_operand", 1], :reg_size], [], ["raise_error", "madd Error: Register sizes are not the same"]],
|
479
|
+
["if_eq_else", ["get_key", ["get_operand", 1], :reg_size], ["get_key", ["get_operand", 2], :reg_size], [], ["raise_error", "madd Error: Register sizes are not the same"]],
|
480
|
+
["if_eq_else", ["get_key", ["get_operand", 2], :reg_size], ["get_key", ["get_operand", 3], :reg_size], [], ["raise_error", "madd Error: Register sizes are not the same"]],
|
481
|
+
|
482
|
+
["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5], # Rd
|
483
|
+
["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5], # Rn
|
484
|
+
["get_bits", ["encode_gp_register", ["get_operand", 3]], 0, 5], #Ra
|
485
|
+
["bits", 0], # o0
|
486
|
+
["get_bits", ["encode_gp_register", ["get_operand", 2]], 0, 5], # Rm
|
487
|
+
["bits", 0,0,0, 1,1,0,1,1, 0,0],
|
488
|
+
["case", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], 32, ["bits", 0], []], # sf
|
489
|
+
],
|
490
|
+
bitsize: 32,
|
491
|
+
},
|
492
|
+
|
493
|
+
|
485
494
|
#
|
486
495
|
# B.cond instructions
|
487
496
|
#
|
data/lib/kompiler/mc_builder.rb
CHANGED
@@ -28,6 +28,16 @@ MC_AST_NODES = [
|
|
28
28
|
{name: "get_label_address", n_args: 1, func: lambda {|args, state| state[:labels].include?(args[0]) ? state[:labels][args[0]] : raise("Label \"#{args[0]}\" not found: Program build not possible") } },
|
29
29
|
{name: "bits", n_args: "any", func: lambda {|args, state| args } },
|
30
30
|
{name: "if_eq_else", n_args: 4, eval_args: false, func: lambda {|args, state| (eval_mc_node_arg(args[0], state) == eval_mc_node_arg(args[1], state)) ? eval_mc_node_arg(args[2], state) : eval_mc_node_arg(args[3], state) }},
|
31
|
+
{name: "case", n_args: "any", eval_args: false, func: lambda do |args, state|
|
32
|
+
value = eval_mc_node_arg(args[0], state)
|
33
|
+
raise "Incorrect use of the \"case\" MC Constructor: incorrect number of arguments. This is likely a problem with the architecture, not the program being compiled." if (args.size - 2) % 2 != 0
|
34
|
+
args[1...-1].each_slice(2) do |check_value, block|
|
35
|
+
if value == check_value
|
36
|
+
return eval_mc_node_arg(block, state)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
eval_mc_node_arg(args.last, state)
|
40
|
+
end},
|
31
41
|
{name: "raise_error", n_args: 1, func: lambda {|args, state| raise args[0] } },
|
32
42
|
{name: "get_key", n_args: 2, func: lambda {|args, state| args[0][args[1]] }},
|
33
43
|
]
|
data/lib/kompiler/parsers.rb
CHANGED
@@ -22,6 +22,8 @@ def self.parse_str(code)
|
|
22
22
|
str_content << "\r"
|
23
23
|
elsif code[i] == "\\"
|
24
24
|
str_content << "\\"
|
25
|
+
elsif code[i] == "0"
|
26
|
+
str_content << "\0"
|
25
27
|
else
|
26
28
|
str_content << "\\"
|
27
29
|
str_content << code[i]
|
@@ -145,6 +147,29 @@ def self.check_decimal_operand(str)
|
|
145
147
|
end
|
146
148
|
|
147
149
|
|
150
|
+
def self.check_char_operand(str)
|
151
|
+
|
152
|
+
# If doesn't start with ' or doesn't end with ', return false
|
153
|
+
if (str[0] != "'") || (str[-1] != "'")
|
154
|
+
return [false, nil]
|
155
|
+
end
|
156
|
+
|
157
|
+
# Use existing logic to parse the contents
|
158
|
+
to_parse = str.dup
|
159
|
+
to_parse[0] = '"'
|
160
|
+
to_parse[-1] = '"'
|
161
|
+
content, parse_i = parse_str(to_parse)
|
162
|
+
|
163
|
+
# If more than one character, return false
|
164
|
+
if content.size != 1
|
165
|
+
return [false, nil]
|
166
|
+
end
|
167
|
+
|
168
|
+
return [true, content.encode("ascii").bytes[0]]
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
|
148
173
|
def self.check_immediate_operand(operand_str)
|
149
174
|
|
150
175
|
is_bin, bin_value = check_binary_operand(operand_str)
|
@@ -156,6 +181,9 @@ def self.check_immediate_operand(operand_str)
|
|
156
181
|
is_hex, hex_value = check_hex_operand(operand_str)
|
157
182
|
return [true, {type: "immediate", value: hex_value, def_type: "hex"}] if is_hex
|
158
183
|
|
184
|
+
is_char, char_value = check_char_operand(operand_str)
|
185
|
+
return [true, {type: "immediate", value: char_value, def_type: "char"}] if is_char
|
186
|
+
|
159
187
|
return [false, nil]
|
160
188
|
end
|
161
189
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kompiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyryl Shyshko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Kompiler is a low-level, modular and extendable compiler for any architecture.
|
14
14
|
By default Kompiler supports ARMv8-a, but other architecture extensions can be downloaded
|