Shop OBEX P1 Docs P2 Docs Learn Events
First Assembly Program — Parallax Forums

First Assembly Program

Jay KickliterJay Kickliter Posts: 446
edited 2009-01-27 01:53 in Propeller 1
I've never done any type of assembly programming before, but I decided to tackle it this weekend. One thing I did, that I've never seen suggested before, was type in a simple assembly example, then translate it to binary. It really helped me to conceptualize what the processor is looking at in the instructions. If anyone else is scare to learn assembly like I've been, I highly suggested it. Here's the program I basically copied from page 38 of Doug Dingus' "Assembly Language Primer for the Absolute Beginner". Once I was sure it was working, I looked up the instructions in the Propeller Manual and translated them into their binary counterparts. The original code is in the comments to the right of the binary code.

PUB start
    cognew(@Toggle, 0)

DAT
                   ORG 0 'Begin at Cog RAM addr 0
Toggle             long %101000_0010_1111_111110110_000000110    'mov dira, pin 'Set Pin to output
                   long %101000_0010_1111_000001000_111110001    'mov Time, cnt 'Calculate delay time
                   long %100000_0011_1111_000001000_000010000    'add Time, #$f 'Set initial delay here
:loop              long %111110_0010_1111_000001000_000000111    'waitcnt Time, Delay 'Wait
                   long %011011_0010_1111_111110100_000000110    'xor outa, Pin 'Toggle Pin
                   long %010111_0001_1111_000000000_000000011    'jmp #:loop 'Loop endlessly

Pin                long %0000_0000_0000_0000_0000_0000_0000_0001 'pin 0
Delay              long %0000_0000_0001_1110_1000_0100_1000_0000 '2_000_000 'Clock cycles to delay
Time               res 1 'System Counter Workspace
                   FIT 496

Comments

  • LeonLeon Posts: 7,620
    edited 2009-01-25 20:29
    Hand-assembly like that is a good way to learn. My first system was a Motorola D2 kit; all programs for that had to be hand-assembled.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-01-25 21:15
    Once upon a time at the University of Wisconsin I took a course in which we had to program like that, using a set of paddle switches to enter each command in its binary version. We also had to use a second set of switches to enter the binary version of the memory address in which the command was to be placed. There was no terminal or even punchcard reader available. I'd guess there are several old-timers here who programmed in that era.

    I'd love to be able to say I mastered it, but in fact I never came anywhere near having a program that ran. I did learn to drink a lot of coffee, though.

    Edit: It looks as though the machine I worked on may still exist:

    webpages.charter.net/thecomputercollection/pdp11/index.htm

    There's a pretty good chance it was one of those.

    Post Edited (sylvie369) : 1/26/2009 3:12:39 AM GMT
  • shanghai_foolshanghai_fool Posts: 149
    edited 2009-01-26 01:33
    I'm sure most of you are too young but the original Altair had only front panel switches and LED's for I/O. Even after building a homemade serial 20ma driver for the paper tape punch/reader (spelled teletype machine), the bootloader had to be input with front panel switches. At the time it was difficult to program eproms.
  • kwinnkwinn Posts: 8,697
    edited 2009-01-26 15:00
    Congratulations Jay. Understanding code at that level is very advantageous.

    Long ago in a gal...er my early work experience was with mini's where the bootstrap loader was entered on front panel switches and all the programming was done in machine language. If you were lucky the machine had an assembler program, if not you did the conversion by hand. I envied those lucky people who had hard drives, terminals, and Fortran, Cobol, or C ccompilers. Ah the good old days. Thank goodness they are past.

    Post Edited (kwinn) : 1/26/2009 3:36:20 PM GMT
  • BaggersBaggers Posts: 3,019
    edited 2009-01-26 16:10
    Don't forget anyone wanting to do any that way, that label addresses change when you add any instructions or remove any!

    PUB start
        cognew(@Toggle, 0)
    
    DAT
                       ORG 0 'Begin at Cog RAM addr 0
    'Long #0 is this next line
    Toggle             long %101000_0010_1111_111110110_000000110    'mov dira, pin 'Set Pin to output     ' the trailing _000000110 ( which = 6 ) will change as this points to Long #6 which is where Pin is located.
    'Long #1 is this next line
                       long %101000_0010_1111_000001000_111110001    'mov Time, cnt 'Calculate delay time  ' the second to last section _000001000_ ( which = 8 ) is pointing to Long #8 which is Time
    'Long #2 is this next line
                       long %100000_0011_1111_000001000_000010000    'add Time, #$f 'Set initial delay here ' the second to last section _000001000_ again for Time
    'Long #3 is this next line
    :loop              long %111110_0010_1111_000001000_000000111    'waitcnt Time, Delay 'Wait            ' and again for Time, and the trailing section _000000111 ( which = 7 ) is points to Long #7 where Delay is.
    'Long #4 is this next line
                       long %011011_0010_1111_111110100_000000110    'xor outa, Pin 'Toggle Pin            ' another trailing section for Pin
    'Long #5 is this next line
                       long %010111_0001_1111_000000000_000000011    'jmp #:loop 'Loop endlessly           ' trailing section _000000011 ( which = 3 ) is pointing to long #3 which is where :loop is
    
    'Long #6 is this next line
    Pin                long %0000_0000_0000_0000_0000_0000_0000_0001 'pin 0
    'Long #7 is this next line
    Delay              long %0000_0000_0001_1110_1000_0100_1000_0000 '2_000_000 'Clock cycles to delay
    'Long #8 is this next line
    Time               res 1 'System Counter Workspace
                       FIT 496
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • hover1hover1 Posts: 1,929
    edited 2009-01-27 01:53
    shanghai_fool said...
    I'm sure most of you are too young but the original Altair had only front panel switches and LED's for I/O. Even after building a homemade serial 20ma driver for the paper tape punch/reader (spelled teletype machine), the bootloader had to be input with front panel switches. At the time it was difficult to program eproms.
    Recieved my 8800 May 7,1975. Still have the invoice. Teletype ASR33 for the first year, then a GE Terminet 300. A blazing 300 baud!! and no earplugs needed!

    Sold Altair on Ebay for $3500 a few years back. What a mistake. Miss it.

    Jim
Sign In or Register to comment.