First Assembly Program
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
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
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
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
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
·
Sold Altair on Ebay for $3500 a few years back. What a mistake. Miss it.
Jim