0

I have written this code in Pep/9 Assembly language:

         BR      main
num1:    .BLOCK  2
num2:    .BLOCK  2
adder:   .EQUATE 25
stopper: .EQUATE 0
tester:  .EQUATE 75
message: .ASCII "higher\n"
         ;
main:    DECI    num1,d
         LDWA    num1,d
         CPBA    stopper,i
         BREQ    finish
         ADDA    adder,i
         STWA    num2,d
         CPBA    tester,i
         BRLE    lower
         STRO    message,d 
         BR      main
lower:   DECO    num2,d
         LDBA    '\n',i
         STBA    0xFC16,d
         BR      main
finish:  STOP
         .END

Numbers are inputted through a decimal trap, stored to num1 block, first tested if they are equal to the stopper (0), if so the program terminates. Then they have the adder (25) added to them and that is stored to the num2 block. If that number is larger than 75, the word "higher" will print. If not, num2 will.

However, when testing my code, every time a number triggers "higher" to be printed, the number 1 is printed right after. Not sure where it comes from. Please help.

  • 1
    What value did you enter into `num1`? I'm asking since you're mixing word and byte operations. Also, does `.ASCII` automatically add a NUL-character to terminate the string, or is there a separate directive for that? – Michael Apr 30 '21 at 10:16
  • As per Michael's suggestion, try adding `.BLOCK 2` after the `.ASCII` line. – Erik Eidt Apr 30 '21 at 11:10

0 Answers0