FizzBuzz in 6502 assembler

March 12th, 2007

FizzBuzz is an extremely basic competence test for programmers. So I thought I’d write a version extremely in BASIC. Here it is in BBC Basic’s embedded 6502 assembler. For added geek points I used a 6502 emulator written in Perl to develop it on.

Just don’t ask why.

   10 REM FizzBuzz in 6502 assembler
   20 DIM code% 1000
   30 OSWRCH = &FFEE
   40 OSNEWL = &FFE7
   50 work = &70
   60 DIM FizzM 4 : $FizzM = "zziF"
   70 DIM BuzzM 4 : $BuzzM = "zzuB"
   80 FOR pass% = 0 TO 3 STEP 3
   90 P%=code%
  100 [opt pass%
  110
  120 .FizzBuzz  LDA #1
  130            LDX #3
  140            LDY #5
  150 .FB1       SEC
  160            DEX
  170            BNE FB2
  180            JSR Fizz
  190            LDX #3
  200 .FB2       DEY
  210            BNE FB3
  220            JSR Buzz
  230            LDY #5
  240 .FB3       BCC FB4
  250            JSR PrDecimal
  260 .FB4       PHA
  270            JSR OSNEWL
  280            PLA
  290            CLC
  300            ADC #1
  310            CMP #101
  320            BCC FB1
  330            RTS
  340
  350 .Fizz      PHA
  360            LDX #3
  370 .Fizz1     LDA FizzM, X
  380            JSR OSWRCH
  390            DEX
  400            BPL Fizz1
  410            CLC
  420            PLA
  430            RTS
  440
  450 .Buzz      PHA
  460            LDY #3
  470 .Buzz1     LDA BuzzM, Y
  480            JSR OSWRCH
  490            DEY
  500            BPL Buzz1
  510            CLC
  520            PLA
  530            RTS
  540
  550 .PrDecimal STA work
  560            PHA
  570            TXA
  580            PHA
  590            LDA #0
  600            PHA
  610 .PrDec0    LDX #8
  620            LDA #0
  630 .PrDec1    ASL work
  640            ROL A
  650            CMP #10
  660            BCC PrDec2
  670            SBC #10
  680            INC work
  690 .PrDec2    DEX
  700            BNE PrDec1
  710            CLC
  720            ADC #ASC"0"
  730            PHA
  740            LDX work
  750            BNE PrDec0
  760 .PrDec3    PLA
  770            BEQ PrDec4
  780            JSR OSWRCH
  790            JMP PrDec3
  800 .PrDec4    PLA
  810            TAX
  820            PLA
  830            RTS
  840 ]
  850 NEXT

Visual Studio: Before / After

March 1st, 2007

Microsoft have a great ad for Visual Studio inside the front cover of Dr. Dobbs journal. Check out these pictures:

Before After
(click for larger version)
Before After

The first guy has a huge ugly laptop, a meaningless award on his desk. He clearly has no manners; in spite of the two women standing right next to him he’s wearing headphones and brandishing a tacky looking PDA / MP3 player / phone / whatever. His body language screams “I’m far too important to talk to mere girls”. He’s got an unhealthy BMW fetish going on too. Not only has he left his Beemer keyfob ostentatiously draped on his desk, he also has both a model of the car (his true love I fancy) and a picture of him standing next to the real thing. Just in case we miss the fact that he OWNS A BMW.

Anyway, then he discovers Visual Studio and experiences quite a transformation. He realises the award was just a crude attempt by his employer to make him work harder without paying him more. In its place is a paperclip parody of the award. Hah! His laptop is smaller and more tasteful. He now takes his headphones off in the presence of others. His keys are just a bunch of keys. He’s ditched the vacuous status car and replaced it with a mountain bike. Amazing. I almost like him now.

Microsoft must be furious though: the ad has been printed with the panels reversed so that it looks as if using Visual Studio turns you into a boorish, smug, self obsessed cock. Too bad.

Geo URI Safari Helper

February 27th, 2007

I’ve just knocked up a little geouri helper for Safari that launches geouris in Google Earth. You can download it here. You may need to use the More Internet preference pane to associate the geo: URI scheme with the GeoHelper application.

It’s rough and ready and writing it reminded me just what a comprehensively awful language Applescript is. Let me know if you improve it.

If you get it working here’s where I live.

Geo URI proposal

February 27th, 2007

A couple of years ago I floated the idea of a geo: URI scheme. You give each physical location on the planet an address and then leave it up to individual users to define what happens when they click on a geo: URI. One person might have their browser configured to open Google Earth at the appropriate spot while someone else might prefer to use whatever mapping is available from Open Streetmap.

True to form I didn’t do much with the idea but Alex Mayrhofer and Christian Spanring (who I’m certain came up with the idea absolutely independently) have written a draft specification for a geo: URI scheme and implemented a FireFox extension to handle geouris.

My original proposal involved a packed representation of latitude and longitude. My thinking was that if you could encode, say, someone’s home address as a reasonably short string then people might have a reasonable chance of remembering it. On reflection though Alex and Christian’s daring use of conventional latitude and longitude makes much more sense…

Let’s ban DRM: UK government responds

February 19th, 2007

Tony Blair has posted his response to the Let’s Ban DRM petition that’s been running on the Number 10 site. Here’s what he has to say (my italics):

Digital rights issues have been gaining increasing prominence as innovation accelerates, more and more digital media products and services come onto the market and the consumer wants to get access to digital content over different platforms. Many content providers have been embedding access and management tools to protect their rights and, for example, prevent illegal copying. We believe that they should be able to continue to protect their content in this way. However, DRM does not only act as a policeman through technical protection measures, it also enables content companies to offer the consumer unprecedented choice in terms of how they consume content, and the corresponding price they wish to pay.

Bullshit. I wonder, can the PM name even one instance when the use of DRM has benefited consumers? We’ve come to expect this doublespeak nonsense from the entertainment industry but it’s disappointing that the government swallows the industry’s line on DRM so uncritically.

Jobs on DRM

February 8th, 2007

Nick says:

I was wondering when you’re going to comment on Steve Jobs latest outporings on DRM.

Surely the only interoperable DRM is no DRM.

He’s an opportunistic hypocrite. DRM allowed Apple to create the iPod monopoly. Just a few months ago he was vocally pro-DRM. So what? The fact that he’s one of the most prominent rats leaving the sinking DRM ship doesn’t disguise the fact that it’s sinking.

You have to feel sorry for Microsoft. Vista is lumbered with an onerous cargo of DRM badness (See Vista’s suicide note). If, as seems likely, DRM falls out of favour during its lifetime that’s a hell of a lot of useless baggage to be carrying.

More on Jobs’ flip-flopping here:

techdirt: Steve Jobs Says Record Labels Should Ditch Their DRM
BoingBoing: Will Steve Jobs drop iTunes DRM in a heartbeat?
Scobleizer: Why not turn off DRM on Disney movies?
the INQUIRER: Jobs’ cry against DRM is a sham

Microsoft Innovate

February 1st, 2007

You just can’t keep a good company down, can you? I’m pretty sure that the inclusion of an analogue security hole in Vista is a first.

It just goes to show: all the DRM in the world can’t plug up the analogue hole.

Messages from the future

January 5th, 2007

Mark Jason Dominus is debunking an article he read about passwords a future self could use to prove they’re really you when communicating with you back in time.

Mark’s technique looks very secure but I don’t really understand the problem. I’d just ask my future self “what colour was the pencil and what was its significance?” and “where did you hide the curry?”. I’m pretty sure nobody knows the answer to those things apart from me. I guess I must be missing something though…

Where’d it go?

January 1st, 2007

This scary looking story has just popped up on the BBC News RSS feed:

US 'may probe' passenger details

By the time I checked the BBC News site the story had turned into this:

XX

Where did it go? Here’s the link I followed to the story:

http://news.bbc.co.uk/1/hi/uk/6223077.stm

Note that’s not the same result that you get if you follow a link to a non-existent story - in that case you get a normal 404.

So what happened to that scary sounding story and why?

Update: Link now returns a regular 404 Not Found.

Update: It seems the Telegraph are running the same story:

By using a credit card to book a flight, passengers face having other transactions on the card inspected by the American authorities. Providing an email address to an airline could also lead to scrutiny of other messages sent or received on that account.

In the words of ArsTechnica it’s “bollocks”. Obviously it’s bollocks that somebody at the BBC briefly made the mistake of believing.

That searching thing…

December 26th, 2006

Hmm, that was a little terse, wasn’t it? I should have said I’ve been playing with a Google CSE that searches Perl World - or at least as many Perl related sites as I could remember / find. I quite like it - to the extent that I’m currently using it instead of search.cpan.org most of the time. Anyway, see what you think, tell a friend, knock yourself out.

Search Perl World:


Add to Google


Copyright Andy Armstrong, 2005. Entries (RSS) and Comments (RSS).