1

This is my code:

output "ejemplo1.bin"

db #fe
dw START
dw END

org #8500

START:
    ld a, [#8600]
    ld b, a
    ld a, [#8601]
    add a, b
    ld [#8602], a

    ret

END: And this is what I'm getting when trying to compile it:

C:\Users\Daniel\Programming\MSX\asm>sjasm ejemplo1.asm
Sjasm Z80 Assembler v0.42c - www.xl2s.tk
ejemplo1.asm(1) : Unrecognized instruction: "ejemplo1.
ejemplo1.asm(3) : Label not found: fe
ejemplo1.asm(4) : Unrecognized instruction: start
ejemplo1.asm(5) : Duplicate labelname: dw

Any idea what I'm doing wrong?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Daniel Tkach
  • 576
  • 2
  • 9
  • 18
  • 1
    Does the sjasm manual say that `dw` is supposed to work, or how to use `output`? Also, `#fe` appears to be getting interpreted as a symbol name. I don't know what Z80 assemblers normally use to indicate hex literal immediates, whether it's`#0xfe`, `#$fe`, or `#0feH`, but if the manual doesn't describe the syntax, that's what I'd try first. (But generally it's not a good idea to throw syntax at the wall and see what sticks, especially with assembly where "happens to work" doesn't always mean "correct".) – Peter Cordes Sep 15 '21 at 05:12

1 Answers1

4

It helps if you read the manual.

The main error: Only labels start in the first column, insert at least a space or tab before any instruction or pseudo instruction.

ejemplo1.asm(1) : Unrecognized instruction: "ejemplo1.

output is interpreted as label, and consequently the filename is tried as an instruction. The interesting detail is that the point "." is taken as a separator. BTW, the filename is not in quotation marks, according to the examples.

ejemplo1.asm(3) : Label not found: fe

db is interpreted as label, and perhaps #fe is interpreted as a structure field entry. # defines the length on a field, and therefore fe is not recognized as a number, but as a label. This interpretation looks like a bug in the assembler to me.

ejemplo1.asm(4) : Unrecognized instruction: start

dw is interpreted as label, and consequently start is tried as an instruction.

ejemplo1.asm(5) : Duplicate labelname: dw

dw is again interpreted as label, as the error message tells us that it is already defined (in the line before).

Note: If you correct your code and get new errors, feel free to post a new question. You might want to add this to this question, but don't remove the current contents, add it and mark it as addition.

the busybee
  • 10,755
  • 3
  • 13
  • 30