ArkScript
A small, fast, functional and scripting language for video games
Word.hpp
Go to the documentation of this file.
1/**
2 * @file Word.hpp
3 * @author Alexandre Plateau ([email protected])
4 * @brief Describe an instruction and its immediate argument
5 * @version 0.5
6 * @date 2022-07-02
7 *
8 * @copyright Copyright (c) 2022-2024
9 *
10 */
11
12#ifndef ARK_COMPILER_WORD_HPP
13#define ARK_COMPILER_WORD_HPP
14
15namespace Ark::internal
16{
17 struct bytes_t
18 {
19 uint8_t second;
20 uint8_t first;
21 };
22
23 struct Word
24 {
25 uint8_t padding = 0; ///< Padding reserved for future use
26 uint8_t opcode = 0; ///< Instruction opcode
27 union {
28 uint16_t data = 0; ///< Immediate data, interpreted differently for different instructions
30 };
31
32 explicit Word(const uint8_t inst, const uint16_t arg = 0) :
33 opcode(inst), data(arg)
34 {}
35 };
36}
37
38#endif
uint8_t opcode
Instruction opcode.
Definition: Word.hpp:26
uint8_t padding
Padding reserved for future use.
Definition: Word.hpp:25
bytes_t bytes
Definition: Word.hpp:29
uint16_t data
Immediate data, interpreted differently for different instructions.
Definition: Word.hpp:28
Word(const uint8_t inst, const uint16_t arg=0)
Definition: Word.hpp:32