An Assembly Quiz

Appleassemblyline From October 1980 through June 1988, Bob Sander-Cederlof published a newsletter called Apple Assembly Line. This newsletter focussed on assembly language for the Apple ][, //e, //c, and //gs computers, all of them based on the 6502 processor and its derivatives. Bob was the author of the S-C Macro Assembler, which lived as long as the newsletter, i.e., until 1988.

Since a few months ago, there’s an Apple Assembly Line [online] Archive that includes all the AAL newsletters. It’s very fun, and instructive, to have a look at them, even if you don’t have an Apple ][. You can still pick some Steven Wozniak trick for your assembly programming, or learning how to add or substract one. If you know a bit of assembly, you’ll understand the code quickly (in fact, it looks a lot like Don Knuth’s MIXAL in TAOCP, and i’ve been able to run some code on my MIX simulator with minimal modifications).

If you’re thinking that you will learn little from a twenty years old newsletter, please try your hand at discovering what the DO.SOME.MAGIC subroutine below computes:

  1010 *--------------------------------
  1020 BYTE   .EQ 0
  1030 *--------------------------------
  1040 T      LDA #0
  1050        STA BYTE
  1060 .2     LDX #14
  1070 .1     CPX #7
  1080        BNE .4
  1090        LDA #$A0
  1100        JSR $FDED
  1110 .4     JSR DO.SOME.MAGIC
  1120        JSR $FDDA
  1130        INC BYTE
  1140        BEQ .3
  1150        DEX
  1160        BNE .1
  1170        JSR $FD8E
  1180        JMP .2
  1190 .3     RTS
  1200 *---------------------------
  1220        LDA BYTE
  1230        LSR
  1240        LSR
  1250        LSR
  1260        ADC BYTE
  1270        ROR
  1280        LSR
  1290        LSR
  1300        ADC BYTE
  1310        ROR
  1320        LSR
  1330        LSR
  1340        RTS
  1350 *--------------------------------

If there’s some mnemonic that you don’t understand, here you have a complete reference of the 66 instructions understood by the 6502. The solution is somewhere in the AAL archive, but you will have a far greater time if you try to solve this little riddle by yourself. And if you get all worked up and want to try more algorithms for howtobcome real, this page points to some 6502 emulators and assemblers. Have fun!

Tags: ,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: