cancel
Showing results for 
Search instead for 
Did you mean: 

I'm writing an STM8 assembler using your PM0044 document, but it has errors. For example, BTJF and BTJT are both listed as having an opcode of $72 $0x (the x is the bit mask). Most likely, one of those opcodes is supposed to be $92.

HughA
Associate

Most likely, the programmer who wrote your assemble used a text document provided by the engineers for his info on the STM8 instruction set. Later on, a technical writer converted that text document into a snazzy PDF for outsiders such as myself. Errors were introduced when the info was hand-copied, and nobody ever checked the accuracy of the PDF because nobody expected anybody to need accurate informatio.

It is a sad commentary on the skill-level of STM8 programmers, but none of them have ever written an assembler for the STM8 and so none of them found these errors that I found in my first few days of learning how the STM8 works.

I'm really not the kind of "programmer" who relies on having somebody smart write his assembler for him, then claims to be a super-duper expert on STM8 assembly-language.

Can I just be given the original text document from the engineers? I can do without the snazzy PDF that the technical writer provided. I can't write my assembler without being given accurate information on the STM8 assembly-language.

I suppose if necessary I could reverse-engineer your assembler to find out what opcodes it generates, but that is a waste of my time --- you should just provide this information in a straight-forward manner.

1 REPLY 1
HughA
Associate

I was wrong about this.

Bit-0 of the opcode determines if it is a jump on false or a jump on true.

I wrote an assembler for the MSP-430 last year. The MSP-430 is much more complicated than the STM8 because it has both a source and a destination operand. TI documents the ;bit fields in the opcode though, so writing an assembler is easy. I just fill in the bit fields, each one of which is short so it has only a few possible entries.

The STM8 may have bit fields in the opcodes, but this isn't documented in the PM0044 manual. All that it provides are the hex opcode values. I would have to convert the hex into binary, and then just eyeball the opcode values to look for patterns. If I do find patterns, I can't be guaranteed that these patterns will be consistent throughout --- there may be exceptions that have to be special-cased.

My impression is that ST is providing information on the STM8 in a purposefully awkward format to hamper people in any attempt at writing their own assemblers. I can work around this though. I can just brute-force the assembler, similar to what I did for the 65c02 way back in the old days

My impression is that ST wants everybody to use their C and C++ compilers. I will never become a C programmer though!