1

I want to print a set of letters in one line in MARIE. I modified the code to print Hello World and came up with:

    ORG     0       / implemented using "do while" loop
WHILE,      LOAD        STR_BASE    / load str_base into ac
    ADD     ITR         / add index to str_base
    STORE       INDEX       / store (str_base + index) into ac
    CLEAR               / set ac to zero
    ADDI        INDEX       / get the value at ADDR
    SKIPCOND    400     / SKIP if ADDR = 0 (or null char)
    JUMP        DO      / jump to DO
    JUMP        PRINT       / JUMP to END

DO, STORE       TEMP                / output value at ADDR
    LOAD        ITR         / load iterator into ac
    ADD         ONE         / increment iterator by one
    STORE       ITR         / store ac in iterator
    JUMP        WHILE       / jump to while

PRINT,      SUBT    ONE
            SKIPCOND  000
            JUMP     PR
            HALT

PR,     OUTPUT
        JUMP WHILE

ONE,        DEC     1
ITR,        DEC     0
INDEX,      HEX     0
STR_BASE,   HEX     12      / memory location of str
STR,        HEX     48      / H
    HEX     65      / E
    HEX     6C      / L
    HEX     6C      / L
    HEX     6F      / O
    HEX     0       / carriage return
    HEX     57      / W
    HEX     6F      / O
    HEX     72      / R
    HEX     6C      / L
    HEX     64      / D
    HEX     0       / NULL char

My program ends up halting past two iterations. I can't seem to figure out how to print a set of characters in one line. Thanks.

Peeves
  • 19
  • 1
  • 3

1 Answers1

0

Your value of STR_BASE is almost certainly incorrect. Based on what is here I would say it needs to be 18 instead of 12. Also you would either want to remove current null char that is between "HELLO" and "WORLD" and replace it with a space or simply remove that line, depending on your intended output.

craigts
  • 2,857
  • 1
  • 25
  • 25