flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
Serke 09 Jun 2025, 17:23
"struc" itself is not a labeled instruction but a built-in fasmg command that lets you define your own labeled instructions (i.e. it's what you define using "struc" becomes a labeled instruction):
Code: struc (lbl) assign? var* lbl = var end struc or Code: struc assign? var* . = var end struc The code above defines the labeled instruction "assign". Code: myvar assign 3 ; Here "myvar" is a label to the labeled instruction "assign" assert myvar = 3 |
|||
![]() |
|
Greg_M 09 Jun 2025, 19:03
Hi,
Serke wrote: "struc" itself is not a labeled instruction but a built-in fasmg Yes, I said that struc is a command. (I didn't say that struc is a labeled instruction.) Greg_M wrote: ..."struc" is categorized as a command... Serke wrote: ...lets you define your own labeled instructions... Yes, I said, based on the Section 9 example "struc some": Greg_M wrote: ...the instruction "some". Question #1: Greg_M wrote: So that means first identifier can be either in the instruction category or command category. Does fasmg allow other categories for first identifier? Question #2: In the term "labeled instruction" What does "labeled" mean? Based on your example, "assign", if you're saying that "struc" is not a label (I do understand that "struc" is a command), then I can understand that. So does the term "labeled instruction" mean an instruction that can be labeled? If so, then I suggest clarify that in the documentation, because the term "labeled instruction" is easily misinterpreted to mean that the label is specified as the instruction is defined. Question #3: What is the value/purpose of a "labeled instruction"? E.g. Does it allow it to placed in the code flow using the label as the symbol for the address? Question #4: Can a labeled instruction ever be used without a label? Question #5: Greg_M wrote: Do we have a reference list of predefined fasmg instructions and commands and any other identifier type that can be used as first identifier? Is this a reasonable approach to understanding what's involved in defining a labeled instruction? Thank You Last edited by Greg_M on 09 Jun 2025, 19:43; edited 1 time in total |
|||
![]() |
|
dosmancer 09 Jun 2025, 19:31
Greg_M wrote: Question #2: In assembly language you can normally do things like this: Code: lbl: db $FF but this form is often allowed too (without colon): Code: lbl db $FF So let's say one is implementing an instruction set for the Motorola 68000 where the db equivalent is named `dc.b` instead of `db` then you can implement it like this: Code: macro dc.b val* db val end macro struc dc.b val* .: db val end struc The reason for the 2nd one is because it allows: Code: some_label dc.b $FF That's probably where the name comes from as it often has to do with labels. What's nice with it is that you get the label as a paramameter in the instruction body so you can really do whatever you like with it. You don't have to use it to create a label. As shown by Serke they can be used to assign values too (a non-label case of a labeled macro instruction?). Quote: Question #4: Code: struc lbl_instr val* ; something end struc can never be used like this if that's what you mean Code: lbl_instr $FF A tip is to create a folder with a bunch of different small tests where you try stuff out. I found fasmg tricky to learn, especially namespaces and calminstructions for which I have many different test files. |
|||
![]() |
|
Serke 09 Jun 2025, 19:58
Greg_M wrote: Based on your example, "assign", if you're saying that "struc" is not a label (I do understand that "struc" is a command), then I can understand that. As I understand it, in fasmg terminology, an instruction refers to a symbol that belongs to an instruction class, while a command is a complete construct (a sentence, if you like) that fasmg recognizes and processes. A command is formed from an instruction symbol along with other components, such as labels (in the case of labeled instructions). For example, "struc" is a symbol of an instruction class while "struc some" is a command of which "struc" is part of. |
|||
![]() |
|
Greg_M 09 Jun 2025, 20:24
[quote="dosmancer"]
Code: macro dc.b val* db val end macro struc dc.b val* .: db val end struc The reason for the 2nd one is because it allows: Code: some_label dc.b $FF "2nd one"? As in two different means to support the dc.b ? So, can all user-defined instructions be labeled, and the term "labeled" is simply used to emphasize that aspect? (Macros cannot be labeled?) We seem to have multiple kinds of user-defined "instructions". I know about macro, and calminstruction. Is labeled instruction another kind? Conceptually, does the idea of supporting only one kind of user-defined instruction, have any value? I ask that, not so much to suggest it, but to gain insight. (Studying the rest of your response, Thanks!) |
|||
![]() |
|
Greg_M 09 Jun 2025, 22:01
Serke wrote: ...instruction refers to a symbol that belongs to an instruction class, while a command is a complete construct (a sentence,... fasmg Manual, Section 3 wrote: When a symbol is defined with a "=" command, ... fasmg Manual, Section 5 wrote: ...instruction...recognized only when it is the first identifier of the command... So, perhaps the term "command" may be used to refer to the token (e.g. '=') that is the basis of a complete command "sentence" as well as the complete command "sentence" itself. Further: fasmg Manual, Section 5 wrote: If we treat "=" as a special kind of identifier, it may serve as an example of labeled instruction. So '=' is said to be a command and also a "labeled instruction". Can '=' be an example of "labeled instruction" because it can be in a command sentence whose first identifier is a label? If so, is '=' more precisely classified as an "instruction" rather than a "command"? fasmg Manual, Section 5 wrote:
BTW to be helpful: Typographical error in manual Section 5 "...special kind of indentifer...", "indentifer" should be "indentifier". The manual also has two other cases of this.) In general, I think that the manual is quite thorough and explicit in one sense, but a broader vocabulary would probably help for discernment between some of the nuanced meanings. If I define my own terms for some of these nuances/overloads and if I think that they have potential value to FASM, I could post them here e.g. in a "terminology" thread (if OK with Mr. Grysztar). Last edited by Greg_M on 10 Jun 2025, 00:05; edited 3 times in total |
|||
![]() |
|
Greg_M 09 Jun 2025, 23:48
From reviewing the fasmg manual further, some instructions are also called "commands". E.g. "restore" is called a command and an instruction.
fasmg Manual, Section 9 wrote:
Question #1 What does "not an instruction" refer to? Would "struc" be considered "an instruction" in this context? I don't see "struc" referred to as an "instruction" anywhere in the fasmg manual. Is this simply a matter of the idea that "struc" is a command but commands are also part of the broader class of instructions? Question #2 With regards to "get some" and "my POINT" in the same manual section, Section 9: are "get" and "my" both considered labels? |
|||
![]() |
|
bitRAKE 10 Jun 2025, 00:28
Commands/Directives/Instructions are a process whereas labels and symbols are typically valued. Many instructions are the first word on a line, some instruction can work in a labeled form - as the second word of a line, and others operate in both capacities. The labeled form is invoked when the first word is not identified as an instruction.
A struc is a labeled macro. Code: macro try line& end macro struc try line& .: try line ; create the label, invoke the macro end struc |
|||
![]() |
|
Greg_M 10 Jun 2025, 00:52
I think that a flowchart for parsing the first identifier of a fasmg statement would be something like this:
Code: Is the symbol the argument of an expression? YES: Finished NO: Is the symbol a command/instruction? YES: Finished NO: The symbol is a label Then other logic could determine if the statement is valid fasmg syntax. E.g. Is the label followed by a labeled instruction? Note that a fasmg statement can have an expression involving '=' after a label, and the fasmg manual, Section 5, indicates that the labeled instruction concept applies to such a statement. This appears to be an aid to understanding the generality of the "labeled instruction" concept, using '=' as an example, rather than a focus on the '=' command per se. Last edited by Greg_M on 10 Jun 2025, 01:09; edited 2 times in total |
|||
![]() |
|
Greg_M 10 Jun 2025, 01:01
bitRAKE wrote: Commands/Directives/Instructions are a process whereas labels and symbols are typically valued. Many instructions are the first word on a line, some instruction can work in a labeled form - as the second word of a line, and others operate in both capacities. The labeled form is invoked when the first word is not identified as an instruction. bitRAKE wrote: The labeled form is invoked when the first word is not identified as an instruction. |
|||
![]() |
|
bitRAKE 10 Jun 2025, 01:33
Greg_M wrote: The first identifier is not a label if it's an argument to command, correct? E.g. as in "x = 1"? See my flowchart, for example. Identifier is a generic term - so is label. struc can do anything with the label: Code: struc pow?: n,e ; exponentiation, n^e repeat 1,dn:n,de:e if de > 0 local t t pow dn,de shr 1 if de and 1 . = t * t * dn else . = t * t end if else if de = 0 . = 1 else err end if end repeat end struc "x = 1" means something different if "x" is a macro. |
|||
![]() |
|
bitRAKE 10 Jun 2025, 02:22
Greg_M wrote: I think that a flowchart for parsing the first identifier of a fasmg statement would be something like this: |
|||
![]() |
|
Greg_M 10 Jun 2025, 02:46
RE Flowchart: I was simply using it as an aid to understanding. Any corrections to it improve my understanding.
bitRAKE wrote:
Also, what do you mean by executable? Directive/Command/Instruction ? What is "struc"? A command? An instruction? Both? Does instruction classification generally cover "executable" (based on your meaning of "executable"). |
|||
![]() |
|
bitRAKE 10 Jun 2025, 03:16
Any purpose that can be.
I thought we already established that they were a process (i.e. executable). struc is a built in instruction, but it can be redefined - the fine-grained distinction of command/instruction/directive helps us how? Either an instruction can be changed or it can't. We can't redefine '='. Arguments are text - which is typical for assembly macros. If the first identifier is an instruction it will get executed and '=' becomes the start of the first argument. So, if the '=' command is executing then we known the first identifier was not executable. Last edited by bitRAKE on 10 Jun 2025, 04:53; edited 1 time in total |
|||
![]() |
|
Greg_M 10 Jun 2025, 03:31
bitRAKE wrote: If the first identifier is an instruction... bitRAKE wrote: If the first identifier is an instruction it will get executed and '=' becames the start of the first argument. |
|||
![]() |
|
Serke 10 Jun 2025, 04:31
Greg_M wrote: '=' is not always a command? I think bitRAKE meant this: Code: macro look_at_this args& display "'look_at_this' is called with args: ", `args, 13 end macro look_at_this = 3 ; This is not an assignment but a macro call! 'look_at_this' gets called with '= 3' as an argument purge look_at_this look_at_this = 1 ; This is not a macro call but an assignment! |
|||
![]() |
|
Greg_M 10 Jun 2025, 04:50
Serke wrote:
Serke, that explains it, thank you! Thanks also to all on this thread. |
|||
![]() |
|
bitRAKE 10 Jun 2025, 05:09
Greg_M wrote:
(Rarely both - we can ignore that for now.) |
|||
![]() |
|
Greg_M 10 Jun 2025, 05:42
fsamg Manual Section 5 wrote: "=" may serve as an example of labeled instruction... |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.