summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/lex.c
AgeCommit message (Collapse)Author
18 hoursoasm: Add encoding for MRO type instructionsIan Moffett
This commit introduces encoding logic for 4 additional instructions: - MROB (Mask Register Over [byte]) - MROW (Mask Register Over [word]) - MROD (Mask Register Over [dword]) - MROQ (Mask Register Over [qword]) This instruction is used to fill a register with a specific length of zeros or ones. For example, to fill a register (e.g., x2) with 16-bits of 1s: -- !! !! Clear bits x2[7:0]... Mrrp,, !! mrow!! !! mrow x2, #1 -- Similarly, an operand of zero sets it to zero. For example, to clear an entire 64-bit register with zeros. Something like this can be done: -- mroq x1, #0 -- Signed-off-by: Ian Moffett <ian@osmora.org>
27 hoursoasm: Add initial support for labelsIan Moffett
A label is like a pin on a map with a number attached to it. OASM keeps track of a number referred to as the psuedo instruction pointer (PIP). This value is initially zero by default and is incremented every instruction. The purpose of this value is to pin a location in the code and mark it to be at a specific address so that further references to that label would be translated to the previous PIP value at the time of encountering the label. Signed-off-by: Ian Moffett <ian@osmora.org>
2 daysoasm: Add support for '!' commentsIan Moffett
Introduce comments, example usage: -- !! !! Double the X5 register by using the !! MUL instruction. !! mul x5, 2 !! wow -- Signed-off-by: Ian Moffett <ian@osmora.org>
2 daysoasm: Add encoding for BR instructionIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
3 daysoasm: Introduce encoding for MUL instructionIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
4 daysoasm: Parse and encode the "HLT" instructionIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
4 daysoasm: lex: Convert and store <imm> to uint16_tIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
4 daysoasm: lex: Free tokenstr on errorIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
5 daysusr: oasm: Free pointers on error pathsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
5 daysusr: oasm: Lex registers and operandsIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
5 daysusr: oasm: Store last token and line numberIan Moffett
Keep track of the last token type (for parser) and keep track of the current line number for debugging. Signed-off-by: Ian Moffett <ian@osmora.org>
5 daysusr: oasm: Add quotes around token nameIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>
5 daysusr: Add initial "oasm" assembler workIan Moffett
Signed-off-by: Ian Moffett <ian@osmora.org>