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

Nibble Adder

Expand Messages
  • Dave
    Thought I d share a little demo I wrote for Lee Hart s membership card kit. This just adds the high and low nibbles on the toggle switches and displays the
    Message 1 of 2 , Mar 5, 2011
    • 0 Attachment
      Thought I'd share a little demo I wrote for Lee Hart's membership card
      kit. This just adds the high and low nibbles on the toggle switches and
      displays the results on the LEDs. The operator that combines the two
      nibbles is near the beginning of the program (address 0002) so it's easy
      to change to OR, XOR, AND, etc. Change the input and output port to suit
      your machine. The program needs to write to location 00FF, so be sure to
      run it with the memory protect switch off.
      0000 30 12 BR init 0002 F4 loop:
      ADD0003 52 STR 20004 64 OUT
      40005 22 DEC 2 0006 6C start:
      INP 4 ; put byte in D and at m(X)0007 AF
      PLO F ; value is in D, m(X), and RF.00008 F6
      SHR0009 F6 SHR000A F6 SHR000B
      F6 SHR ; high nibble in D000C 52
      STR 2 ; high nibble at m(X)000D 8F GLO F
      ; restore original value to D000E FA 0F ANI 0F
      ; low nibble in D0010 30 02 BR loop
      0012 90 init: GHI 00013 B2 PHI 20014
      F8 FF LDI FF0016 A2 PLO 20017 E2
      SEX 20018 30 06 BR start
      Enjoy!
      Dave


      [Non-text portions of this message have been removed]
    • Dave
      Goodness, did *that* ever get butchered. One more try: 0000 30 12 BR init 0002 F4 loop: ADD 0003 52
      Message 2 of 2 , Mar 5, 2011
      • 0 Attachment
        Goodness, did *that* ever get butchered. One more try:

        <code>
        0000 30 12 BR init
        0002 F4 loop: ADD
        0003 52 STR 2
        0004 64 OUT 4 ; change to suit your machine
        0005 22 DEC 2

        0006 6C start: INP 4 ; put byte in D and at m(X)
        0007 AF PLO F ; value is in D, m(X), and RF.0
        0008 F6 SHR
        0009 F6 SHR
        000A F6 SHR
        000B F6 SHR ; high nibble in D
        000C 52 STR 2 ; high nibble at m(X)
        000D 8F GLO F ; restore original value to D
        000E FA 0F ANI 0F ; low nibble in D
        0010 30 02 BR loop

        0012 90 init: GHI 0
        0013 B2 PHI 2
        0014 F8 FF LDI FF
        0016 A2 PLO 2
        0017 E2 SEX 2
        0018 30 06 BR start
        </code>
      Your message has been successfully submitted and would be delivered to recipients shortly.