kompiler 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 022b76028fd6326e384fe0dd41aaee6308f7e1342ccf19f975be42d89bef9368
4
- data.tar.gz: feab74609dc0f512e9a03be164eb804ab94b4f698c9437dca48bdea2cf7381c3
3
+ metadata.gz: 358077245911280980e98b213394c395224c5ee04f4b81b449a073582567eb46
4
+ data.tar.gz: bdaae177e9ef79b9628eaae6e9e506c69d9951f89ff387c28532940fd67d2f90
5
5
  SHA512:
6
- metadata.gz: e64807ccfbd43ecc9a51436402e374ec5dcd270f38aaab48e320e7a1a956ae362f9e34dfea352d0d1003d5571118a047905c551572fda3d9bcd758935e824ca5
7
- data.tar.gz: 28a24f998d1f8fe7d789314ce3768c3399579b14dd7aca43da103f46148dcc9a21521360fc28b673c4b3585acdaaf5cd3e3f93431e6b8f17ba4f8304d3e08c1a
6
+ metadata.gz: c238947087f8d2032816abbe9882df8906b53de123e382ebc662aa3461e560ff69d5001e5ecdc8d28793bdd495a669ec36873d5d6792bfc0cc7396f423d96edd
7
+ data.tar.gz: 747cacbc92d042db6bf1ed5569bb7727ce29694c9c8f4cc6e24c625f26aee73532eb5ea6b93763f47c8e0f3819a43012919dd922b9155c035c43247e4fd0c9ec
data/bin/kompile CHANGED
@@ -18,8 +18,7 @@ require 'kompiler'
18
18
 
19
19
  # Print the help screen if requested
20
20
  if (ARGV.size == 1) && ["--help", "-h"].include?(ARGV[0])
21
- puts """
22
- Usage: kompile [options] | [<input_file> <output_file> [architecture]]
21
+ puts """Usage: kompile [options] | [<input_file> <output_file> [architecture]]
23
22
 
24
23
  Available options:
25
24
  --help, -h Prints this screen
@@ -297,6 +297,19 @@ end
297
297
  ],
298
298
  bitsize: 32
299
299
  },
300
+ {
301
+ keyword: "ldrb",
302
+ name: "Load Register Byte",
303
+ 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"}],
305
+ mc_constructor: [
306
+ ["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5],
307
+ ["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5],
308
+ ["get_bits", 0, 0, 12], # Immediate offset zero
309
+ ["bits", 1,0, 1,0, 0, 1,1,1, 0,0],
310
+ ],
311
+ bitsize: 32
312
+ },
300
313
  {
301
314
  keyword: "strh",
302
315
  operands: [{type: "register", restrictions: {reg_size: 32}}, {type: "register", restrictions: {reg_size: 64}}],
@@ -451,6 +464,22 @@ end
451
464
  bitsize: 32
452
465
  },
453
466
 
467
+ {
468
+ keyword: "mul",
469
+ name: "MUL",
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"}}],
472
+ mc_constructor: [
473
+ ["get_bits", ["encode_gp_register", ["get_operand", 0]], 0, 5], # Rd
474
+ ["get_bits", ["encode_gp_register", ["get_operand", 1]], 0, 5], # Rn
475
+ ["bits", 1,1,1,1,1, 0], # Ra o0
476
+ ["get_bits", ["encode_gp_register", ["get_operand", 2]], 0, 5], # Rm
477
+ ["bits", 0,0,0, 1,1,0,1,1, 0,0],
478
+ ["if_eq_else", ["get_key", ["get_operand", 0], :reg_size], 64, ["bits", 1], []], # SF = 1 if 64-bit
479
+ ["if_eq_else", ["get_key", ["get_operand", 0], :reg_size], 32, ["bits", 0], []], # SF = 0 if 32-bit
480
+ ],
481
+ bitsize: 32
482
+ },
454
483
 
455
484
 
456
485
  #
@@ -29,6 +29,7 @@ MC_AST_NODES = [
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
31
  {name: "raise_error", n_args: 1, func: lambda {|args, state| raise args[0] } },
32
+ {name: "get_key", n_args: 2, func: lambda {|args, state| args[0][args[1]] }},
32
33
  ]
33
34
 
34
35
  def self.is_ast_node(val)
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.1.0
4
+ version: 0.1.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-25 00:00:00.000000000 Z
11
+ date: 2024-11-27 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