flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > HJA430 --- is there RTL for the MSP430 anywhere?

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Hugh-Aguilar



Joined: 26 May 2020
Posts: 55
Hugh-Aguilar 24 Mar 2024, 02:48
Hugh-Aguilar wrote:

Well, I wrote my assembler/simulator for my processor. Smile

I had planned on working with Russia on this PAZ processor (they do the hardware, I do the software). The idea of making this a Russian/American joint project fell through when we hit Moscow with a drone strike. Russia is not talking to me anymore, which is not really fair because I didn't have anything to do with bombing Moscow and I would have advised against it in the unlikely case that anybody had asked my opinion. In the Vietnam War, Russia provided weapons to Uncle Ho, but Russia did not take the next step up which would be to bomb America. In this Ukraine War, America provides weapons to Zylensky, but we also took the next step up which was to bomb Moscow --- so, we crossed a line in this war that Russia did not cross in the Vietnam War --- the last I heard from the Russians, they were talking about allying with some Mexican drug cartels to launch drone strikes on America from Mexico, then all discussion ended.
Are any of you still in contact with anybody in Russia?
I know that Germany is supporting Zylensky. Is Poland taking sides?

At a gun show I talked to a guy "Mark" who says he has been to Ukraine multiple times, although he won't say what his business there is. He is really a Nazi. He talks up the idea of "White Power" and how the White race could totally crush the other races if we could only get organized (this will never happen because most White people including myself want peace and won't support a race war). Mark said that he has seen training camps in Ukraine where Nazis obtain weapons and training that they take back to Europe for use in this upcoming race war --- primarily in Germany and Poland.
Are any of you aware of Nazis in Europe trying to rise again? For the Ukraine War to spill over into Europe would be the worst possible outcome! Sad
Poland has a gigantic border with eastern Ukraine, so if weapons are being brought into Europe, it would be across this border. Is there anything similar to the Azov Battalion in Poland?

My PAZ processor was intended to be joint Russian/American. If people in the two countries are working together, they will be peaceful toward each other (note that "paz" is the Spanish word for peace). This isn't really the way that the world works though. I read in the newspaper that MicroChip (maker of the PIC18, PIC24, PIC32, etc.) has received a $162 million subsidy to make America more competitive in the microchip market. It would be very difficult for my PAZ design to compete against such a heavily funded opponent! Economic-stimulus subsidies distort the market and stifle innovation. Imagine if Motorola had received a multimillion dollar subsidy in the early 1990s --- we would still be using the 68K processor today --- the 68K would still be a bad design though...
Everybody would be scrambling to prove that they are 68K experts so they can get some of that mega-dollar subsidy. All of these 68K experts would praise the 68K as the greatest processor design of all time. Nobody would stand up to say: "The emperor has no clothes!"

I'm thinking of posting my HJA430 assembler code. I wouldn't mind having users --- I just don't want followers who aspire to become leaders --- if I give away the source-code though, then it will likely get stolen the way that Menuet got stolen.
I didn't put very much work into HJA430 though, whereas Menuet was a colossal work, so if HJA430 gets stolen, it gets stolen. I originally wrote HJA430 because I wanted to build an FPGA processor that was a super-set of the MSP-430 --- that is not a very good idea though --- I think my PAZ design is better, although it is not compatible with anything.

The PAZ design has these features:
* Each instruction is one clock cycle. This should simplify the Verilog.
* It runs on the inexpensive Lattice iCE40HX8K FPGA.
* It has support for running a byte-code VM in external memory. This allows the main-program to be written in Forth (or any other high-level language) with some speed-critical application-specific code written in assembly-language as primitives, and the ISRs written in assembly-language too.

I no longer think that a CISC processor such as the MSP430 is a good choice for an FPGA. The PAZ is very much a RISC.

In the HJA430 manual I said:
Quote:
The three primary virtues of HJA430 are:
* Multiple instructions can be put on the same line. We don't have the bizarre restriction of traditional assemblers of only one instruction per line.
* We have code-blocks that can be nested to any level. Control-flow can be done with code-blocks rather than labels. This allows for structured programming, rather than "spaghetti code."
* The macro facility is designed to be more powerful than any traditional macro-assembler.

I really don't understand why assemblers such as FASM allow only one instruction per line and also lack code-blocks. What is the point of these restrictions??? This is the reason why pretty much everybody, including myself, dislikes programming in mainstream assemblers --- that is some ugly code! --- getting rid of these restrictions is really not difficult; I've written multiple assemblers without these restrictions (I never even considered putting these restrictions in an assembler because there is nothing to be gained by doing so).

I would like to start a website similar to the FASM forum where I could post HJA430 and other code, such as the assembler/simulator for my PAZ processor design. I would also allow other people to have sub-forums supporting whatever they are doing. All of these topics would be fringe ideas that have little or no chance of becoming mainstream. My assemblers, for example, are very fringe. The mainstream assemblers for the various processors all lack the features I described above, and they all look pretty much the same as the assemblers that we had in the 1970s --- this is obviously what the world wants, although I don't know why. I would still like to see the FASM enthusiasts write an MSP430 assembler using FASM/G. I would give this a sub-forum --- I would be very interested in learning what advantage this has over my assembler.
What software is used for the FASM forum? Is it free?

_________________
When all else fails, write the source.
Post 24 Mar 2024, 02:48
View user's profile Send private message Reply with quote
Hugh-Aguilar



Joined: 26 May 2020
Posts: 55
Hugh-Aguilar 06 May 2024, 18:56
Hugh-Aguilar wrote:

I really don't understand why assemblers such as FASM allow only one instruction per line and also lack code-blocks. What is the point of these restrictions???

I really wish that somebody would answer this question. I have been wondering about this since the 80s. I had expected that this forum would have assembly language experts who could answer a question such as this, but apparently not --- in my experience, experts don't answer questions about why things are the way that they are --- the experts just explain how things are, which is useless because that is what the manual is for.

Having only one instruction per line is horrible! You get a tall vertical pillar of instructions so that very little code can be seen on the computer screen, requiring the reader to scroll up and down continuously. In the bad old days of MS-DOS, the screen had only 25 lines, although we get slightly more now. Each subroutine is many screens in length, although if there were multiple instructions per line the entire subroutine would fit on the screen along with a block of comments describing what it does.

Note that, although my assembler is single-pass, I do have labels that can be both forward and backward referenced. The labels need PREDEF ahead of time, which establishes them as unsettled. I also have UNSETTLE that unsettles a label that has been settled --- this is so labels can be reused.
I mostly provided labels because assembly-language programmers seem to expect them. In practice, I rarely use labels for anything other than subroutine start points --- I use code blocks inside of subroutines for control flow --- on rare occasions I will use labels inside of subroutines in order to avoid excessively deep nesting of code blocks that can be confusing.

I'm also still interested in finding out what is going on in Poland. That guy Mark represents Poland as being solid Nazi and heavily armed with weapons smuggled over the border from Ukraine. He may be a kook though --- I would like to get information from other sources in Poland for a better perspective on the country. Mark appears to be an ethnic Pole, although he must be an American citizen because he bought an AK-74 at the gun show and I don't think foreigners can legally buy guns in America. He was traveling to and from America and Poland with a passport, but illegally slipping over the border into Ukraine from Poland --- apparently the border is pretty porous and people can easily go back and forth without a passport.

_________________
When all else fails, write the source.
Post 06 May 2024, 18:56
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4075
Location: vpcmpistri
bitRAKE 06 May 2024, 20:47
Obviously, you have tried using fasmg. Put the whole program on one line if you want.

As a concrete example, the core of my XML parser:
Code:
retaincomments
isolatelines
calminstruction reader! &line&
        match =purge ?, line
        jyes process
        match <?=xml? any ?>, line
        jyes skip
        match <!-- any? -->, line
        jyes skip

        local head,tmp,tag
_line:
        match tag line?, line, <>
        jno skip
        match <tag/>, tag
        jyes complete
        match </tag>, tag
        jyes close
        match <tag>, tag
        jyes open
        arrange content, content tag
_tag:
        match , line
        jno _line
skip:   exit

open:   arrange tmp,
        match head tmp?, tag
        take attributes, tmp
        arrange tmp, =TAG_BEGIN.tag
        assemble tmp
        take scope, head
        jump _tag
complete:
        arrange tmp, =TAG_BEGIN.tag
        assemble tmp

        arrange tmp,
        match tag tmp?, tag
        take attributes, tmp
        arrange head, tag
        take scope, head

close:  take , scope
        arrange tmp, =TAG_END.tag attributes
        assemble tmp
        take , attributes
        jump _tag
process:
        assemble line
end calminstruction
include 'vk.xml',mvmacro ?,reader
purge ?
removecomments
combinelines    
... it processes several tags per line. Instead of tags, you'd just dispatch instructions. Wouldn't be too difficult to connect the existing x86 framework.

The multi-instruction "assemblers" I know of:

Randal Hyde, HLA
Betov, RosASM

uart777, Z - The Final Language
https://board.flatassembler.net/topic.php?p=163039#163039

Seems like it has been answered, or you'll need to be more specific. Some claim that HLA, and Z are not assembly language, but a layer on top of assembly. It's all a matter of perspective - through the years people have even shunned macro assemblers - "If it's not a 1:1 relationship with the ISA then how can one claim it's assembly?"

Eh, it's religion for nerds. I know what my preferences are - most it has to do with readability and that's a very personal bias. Some of it does relate to the 1:1 relationship - if I can't produce the instructions I want to use then the abstraction is in the way. Sometimes it's about the abstraction not fitting the problem trying to be solved.

So, this multi-line thing - what do you mean?

add eax, ecx ; mov [saved], eax ; ...

... because that's child's play. It's been done.

add eax, ecx mov [saved], eax ...

... much more difficult, but I think we are just making problems for ourselves at this point.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 06 May 2024, 20:47
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 07 May 2024, 02:00
There is a whole topic about one liners.
https://board.flatassembler.net/topic.php?t=5411
Post 07 May 2024, 02:00
View user's profile Send private message Visit poster's website Reply with quote
Hugh-Aguilar



Joined: 26 May 2020
Posts: 55
Hugh-Aguilar 07 May 2024, 04:26
bitRAKE wrote:
Obviously, you have tried using fasmg. Put the whole program on one line if you want.
I haven't tried FASMG. I normally just write my own assembler.
Since you like FASMG, write an MSP430 assembler in FASMG for comparison to mine.

The only assembler that I've written for money was MFX. That wouldn't get done in FASMG because it involves out-of-ordering the instructions. HJA430 and the PAZ assembler were both pretty easy compared to MFX. FASMG could be used for the MSP430. I doubt that FASMG could be used for the PAZ because the PAZ uses static variables for return-addresses and local-variable frames, so you have to keep track of what level each subroutine is (level-1 can call level-0, level-2 can call level-1 or level-0, etc.). The level of a subroutine is determined after it is written according to what level subroutines it called internally. Each level has its own local frame (including return-address) in static memory. Using static memory for the local frame makes PAZ fast because it doesn't have to do indexed addressing to access local variables or the return-address.

If you want to show off FASMG, start with the MSP430 that is realistic to be done in FASMG.
I don't think that FASMG could support the PAZ, but if somebody wants to take a shot at it, I can provide the description of the PAZ processor.
MFX was very different than anything that anybody has ever encountered. There were no operands at all. There were no jump instructions (the NXT instruction was the only way to modify control flow). Attempting something like this in FASMG would be crazy!

bitRAKE wrote:
The multi-instruction "assemblers" I know of:

Randal Hyde, HLA
Betov, RosASM

uart777, Z - The Final Language

I haven't looked at RosASM or Z, so I can't comment on those.

I am aware of HLA and played around with it. I was impressed!
I am also aware that Randal Hyde got banned from CLAX because of HLA.
I got banned from CLAX too:
https://groups.google.com/g/comp.lang.asm.x86/c/IVtSmnc2ddw/m/CH3O3IUjBAAJ

I prefer FASM to HLA because T.G. provided me with a macro that would allow me to selectively paragraph-align a function only if the whole function would be contained in fewer paragraphs if it was paragraph aligned. This can't be done in HLA (I didn't actually ask Randall Hyde though, so maybe he knows how to do it). T.G.'s macro was a huge benefit to me because it allows me to pack more functions in the 32KB cache.

I didn't need HLA's structured programming high-level aspects for my Forth system because it is just a collection of short functions, none of which are complicated. I think that HLA would be more useful for a full program written in HLA --- that seems to be what Randall Hyde intended --- HLA would be an alternative to C or Pascal.

bitRAKE wrote:
So, this multi-line thing - what do you mean?

add eax, ecx ; mov [saved], eax ; ...

... because that's child's play. It's been done.

add eax, ecx mov [saved], eax ...

... much more difficult, but I think we are just making problems for ourselves at this point.

I don't have semicolons or any other delimiter in my assembler. It wasn't a problem.

This brings us to the macro-language issue. In FASMG you have to write your own macro language. For example, the [saved] above has to be parsed and interpreted. If you want to calculate an address, that facility has to be provided by the macro language. In my assembler, all of this is free because Forth is the macro language --- anything that can be done in Forth can be done to calculate the address or the literal value or whatever operand you need.

_________________
When all else fails, write the source.
Post 07 May 2024, 04:26
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4075
Location: vpcmpistri
bitRAKE 07 May 2024, 16:21
"the macro-language issue" is a non-issue, lol. You like Forth and want every language you use to be Forth - cool. This is actually common with Forth zealots.

Ever use Wolfram Language? The multi-paradigm nature of the language is interesting to me. It makes the language not particularly best at anything; but it teaches one to shift perspectives to solve problems in modalities that better suit the problem.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup


Last edited by bitRAKE on 07 May 2024, 16:43; edited 1 time in total
Post 07 May 2024, 16:21
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 07 May 2024, 16:31
For fasm, if you want multiple instructions per line then I think the best separator is "#". It doesn't conflict with any other syntax unless you are in a macro where it can be escaped with backslash "\". It looks visually distinct; it has many pixels in the glyph for easier identification. You can still use comments.
Code:
mov ax, 0 # add cl, dl # jz @f ; if error # ret # @@: ud2    
But the syntax highlighter for this board colours it badly Sad
Post 07 May 2024, 16:31
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20454
Location: In your JS exploiting you and your system
revolution 08 May 2024, 19:29
Russia posts have been moved to another place.
https://board.flatassembler.net/topic.php?t=22439
Post 08 May 2024, 19:29
View user's profile Send private message Visit poster's website Reply with quote
Hugh-Aguilar



Joined: 26 May 2020
Posts: 55
Hugh-Aguilar 08 May 2024, 19:39
bitRAKE wrote:
"the macro-language issue" is a non-issue, lol. You like Forth and want every language you use to be Forth - cool. This is actually common with Forth zealots.

A lot of people think that Forth is an RPN version of C and that "Forth zealots" just like the funky syntax for reasons unknown. This isn't really true though. A major feature of Forth is that we can write code that executes at compile-time rather than run-time. C doesn't have that. In C the #DEFINE is just simple string-expansion done at compile-time but is not a language. This feature is the primary reason why Forth works well for writing assemblers.

bitRAKE wrote:
Ever use Wolfram Language? The multi-paradigm nature of the language is interesting to me. It makes the language not particularly best at anything; but it teaches one to shift perspectives to solve problems in modalities that better suit the problem.

I don't have any interest in "multi-paradigm" languages --- such high-level programming is not for me --- I like assembly-language, and I have always thought of Forth as being an overgrown macro assembler.

I don't really consider HJA430 to be "child's play" as you said. Also, HJA430 is the least challenging assembler that I have written. The PAZ processor is several times more complicated than the MSP430, and the MiniForth processor (for which I wrote MFX) was several times more complicated than the PAZ.

Primarily what is innovative about HJA430 is the support for code blocks. These are somewhat like the code blocks in C in so much as they have { } brackets. They are different from the C code blocks though because the conditional jump is inside of the code block rather than prior to it. Also, my code blocks support jumping to the start or end of parent or grandparent code blocks. This is like the CONTINUE and BREAK in C except a lot more robust.

_________________
When all else fails, write the source.
Post 08 May 2024, 19:39
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4075
Location: vpcmpistri
bitRAKE 08 May 2024, 20:50
Oh, I'm aware of what Forth is - that's why it was funny when you criticized macros and held up Forth as the "free" answer.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 08 May 2024, 20:50
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4075
Location: vpcmpistri
bitRAKE 09 May 2024, 15:32
Hugh-Aguilar wrote:
A major feature of Forth is that we can write code that executes at compile-time rather than run-time.
Any language has this capability with any sort of loopback mechanism at build time. For example, CMake uses it to determine compiler features. Integrating this at such a low level scares many people (not me). As far as being a "special sauce" it has limited utility as it adds dimensional complexity at design time. Most people that work with Forth realize this limitation. There are great Forth programmers though.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 09 May 2024, 15:32
View user's profile Send private message Visit poster's website Reply with quote
Hugh-Aguilar



Joined: 26 May 2020
Posts: 55
Hugh-Aguilar 13 May 2024, 02:20
bitRAKE wrote:
Oh, I'm aware of what Forth is - that's why it was funny when you criticized macros and held up Forth as the "free" answer.

I noticed a typo in my documentation of the macros. I had messed up the documentation of R@S and R@D --- this is presumably what bitRAKE considered to be "funny" about my macros.

Here is a fixed version:
Quote:

****** 4. ****** macros (the primary virtue of our assembler)


The addressing-modes fill a few global variables, and then the instruction uses this data to assemble itself.
I won't describe here what those global variables are. I will describe SRC? and DST? that are flags indicating
if we had a source and a destination operand.

Most of the instructions have a pointy-bracket version. This is the same as the instruction, but it doesn't
do PREP-INSTRUCTION afterward, so the source and destination remain.
For example, this is how RRC is defined:
: rrc, <rrc,> prep-instruction ;
We already had the pointy-bracket version that didn't do PREP-INSTRUCTION --- so RRC, is just <RRC,> with
PREP-INSTRUCTION afterward.

The pointy-bracket versions are useful in macros.
The word S<>D swaps the source and destination operands. For example, this is how <POP> is defined:
: <pop,> ( SP )+ s<>d <mov,> ;
We need to swap the source and destination so that our lone operand that was the source would be the destination,
and ( SP )+ would be our source. Of course, we still need this:
: pop, <pop,> prep-instruction ;

Here are some slightly more complicated examples of S<>D in action:
: <xchg,> <xor,> s<>d <xor,> s<>d <xor,> ; \ exchange source and destination
: <neg,> -1 # s<>d <xor,> <sub,> ; \ negate --- logical-not then add 1 (actually subtract -1)

We have S>R that pushes the source operand to the return-stack
We have D>R that pushes the destination operand to the return-stack.
We have R>S that pops the source operand from the return-stack and sets SRC? to TRUE.
We have R>D that pops the destination operand from the return-stack and sets DST? to TRUE.
We have R@S that copies the source operand from the return-stack and sets SRC? to TRUE.
We have R@D that copies the destination operand from the return-stack and sets DST? to TRUE.
These are useful if an operand needs to be reused more than once. For example:
: <rla,> s>r true src? ! r>d <add,> ; \ rotate-left arithmetic
Note that S>R sets SRC? to FALSE. Here we want to keep that same source operand, so we manually set it back to TRUE.

In summary, the HJA430 assembler macros are better than the macros in a traditional assembler because
I'm not just pasting strings together --- I'm working with the operands as data.

_________________
When all else fails, write the source.
Post 13 May 2024, 02:20
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.