Loading ...
Sorry, an error occurred while loading the content.
 

cosmac elf software

Expand Messages
  • craigsherenow
    hello i wrote the group a few days ago and many thanks for all your help now i am wanting to see if some one can give me code to make the elf add numbers
    Message 1 of 2 , Dec 3, 2004
      hello i wrote the group a few days ago and many thanks for all your
      help now i am wanting to see if some one can give me code to make
      the elf add numbers
      thanks
      craig
    • rileym65
      Hello Craig, here is a sample program that will add numbers, this same program will also show you how to read the switches (or hexpad) and output onto the data
      Message 2 of 2 , Dec 4, 2004
        Hello Craig,
        here is a sample program that will add numbers, this same program
        will also show you how to read the switches (or hexpad) and output
        onto the data displays: After entering run mode, the computer will
        wait for you to put a number on the toggles (or hexpad) and press the
        IN button, it will store this number temporarily in R7, and then wait
        for you to again set the toggles and press IN. the 'inp 4'
        instruction will store the value read into both D and the memory
        pointed to by R(X), this is why when the 2nd input is done, i do not
        need to move it anywhere, it is already in memory ready for use by the
        following ADD instruction, which adds the value pointed to by R(X) to
        the value already in D. the result is placed back into memory for use
        by the OUT 4 instruction, which takes whatever is at the memory
        pointed to by R(X) and sends it to the displays.

        1 0000: org 0
        2 0000: f8 00 ldi 0 ; setup stack
        3 0002: b2 phi r2
        4 0003: f8 f0 ldi 0f0h
        5 0005: a2 plo r2
        6 0006: e2 sex r2 ; point X to stack
        7 0007: 3f 07 loop: bn4 $ ; wait here til
        IN is pressed
        8 0009: 37 09 b4 $ ; wait til IN is
        released
        9 000b: 6c inp 4 ; read the switches
        10 000c: a7 plo r7 ; save the number
        11 000d: 3f 0d bn4 $ ; wait here til
        IN is pressed again
        12 000f: 37 0f b4 $ ; wait til IN is
        released
        13 0011: 6c inp 4 ; read the switches
        14 0012: 87 glo r7 ; get first number
        15 0013: f4 add ; add 2 numbers
        together
        16 0014: 52 str r2 ; store for display
        17 0015: 64 out 4 ; output the answer
        18 0016: 22 dec r2 ; restore
        position of pointer
        19 0016: 30 07 br loop ; loop back for more





        --- In cosmacelf@yahoogroups.com, "craigsherenow" <craigsherenow@y...>
        wrote:
        >
        >
        > hello i wrote the group a few days ago and many thanks for all your
        > help now i am wanting to see if some one can give me code to make
        > the elf add numbers
        > thanks
        > craig
      Your message has been successfully submitted and would be delivered to recipients shortly.