0
  LD   BC,(1900H)
  LD   B,8
  LD   DE,(1901H)
  LD   D,0
  LD   HL,0
  SRL  C 
  JR   NC,NOADD
  ADD  HL,DE
  SLA  E 
  RL   D
  DEC  B
  JP   NZ,MULT
  LD   (1902H),HL
  HALT
  .END

Error messages:

  1. invalid argument of the instruction. 'NOADD'
  2. Invalid argumenr of the instruction. 'MULT'
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
谢RenS
  • 21
  • 2

2 Answers2

3

You need to define labels for the addresses you want those instructions to branch to. Otherwise the assembler will have no idea what address to use.

supercat
  • 77,689
  • 9
  • 166
  • 211
  • Could you give an example to define addresses for these JR and JP code ? I'm still beginner for assembly – 谢RenS Oct 11 '20 at 05:53
  • 2
    Depending upon the assembler, placing NOADD, MULT, or whatever other symbol you want to branch to at the start of a line, followed by a colon, will indicate that the indicated jump should go to that line. – supercat Oct 11 '20 at 05:57
2

Here is an example of 16x16->16 for you:

; MUL16 - MULTIPLY TWO SIXTEEN BIT NUMBERS WITH A 16 BIT RESULT.
;         DE = MULTIPLICAND
;         BC = MULTIPLIER
;         HL = PRODUCT
;
;         DE*BC=HL
;
        EXPORT  MUL16
MUL16
        LD      A,C             ; MULTIPLIER LOW PLACED IN A
        LD      C,B             ; MULTIPLIER HIGH PLACED IN C
        LD      B,16D           ; COUNTER (16 BITS)
        LD      HL,0            ;
MULT
        SRL     C               ; RIGHT SHIFT MULTIPLIER HIGH
        RRA                     ; ROTATE RIGHT MULTIPLIER LOW
        JR      NC,NOADD        ; TEST CARRY
        ADD     HL,DE           ; ADD MULTIPLICAND TO RESULT
NOADD
        EX      DE,HL
        ADD     HL,HL           ; SHIFT MULTIPLICAND LEFT
        EX      DE,HL           ;
        DJNZ    MULT            ;
        RET

Note that your assembler (unknown to us) may require different syntax for labels and/or comments. The documentation to your assembler is the best place to find these details.

tum_
  • 632
  • 1
  • 7
  • 16