Can Of Code

Hello World in Spectrum assembly

Comments

  • Colin says:

    Hi,

    I had one of these machines at the time of the 80’s microcomputer boom in the UK. At the time, most American microcomputer systems were too expensive for many British families. The ZX Spectrum was released in March1982; two years before, Sinclair Research released the ZX80, the first mass market computer for less than 100 UKPounds. A year later, they released the ZX81. This had an improved display with floating point BASIC and was cheaper at 70UKP.

    Single-key command entry came about because the keyboards on the ZX80/81 were flat touchpad membranes, like the ones on some ATMs. In that context, it saved keystrokes and eased program entry. As you probably found, newbies ended up typing “PRINT RINT” the first few times until they got used to it.

    Single-key entry made less sense when the ZX Spectrum was released. It had a chicklet keyboard and many more keywords.

    Regarding reliability, mine failed in the first 12 months. I got a warranty swap; the replacement was a later issue PCB and was a reliable workhorse, it eventually received a proper keyboard and I had it for a few years afterwards.

    If you play with the emulator again, try it in 128K mode. The 128K Spectrum uses a fullscreen editor with normal command entry (ie, not single-key).

    Cheers,

    Colin.

    • josh says:

      Thanks for the info and the tip Colin, will be sure to give the 128k mode a go and hopefully make something more complicated

  • Damiano says:

    This emulator was actually very promising. Unfortunately, all its versions were buggy, including the supposedly stable 0.666, it had some weird audio issue. The one you are using (which is 0.7s experimental version) has an interruption bug. Not everyone can notice it, but if you run a game with background music and listen to it for a minute you will hear that it keeps disrupting a bit every now and then. Other versions didn’t have it, but they had their own bugs. So basically, none of them were perfect and it’s a shame authors of this could-be-awesome app just abandoned the project.

  • Peter Jones says:

    Hi,

    Any chance of scanning this book as it does not seem to be in the World of Spectrum collection. Only the cover shot.

    Thanks

  • Sondar says:

    My previous comment was just an assembly language listing. How do we get that into your Spectrum to run it? See my next comment… ;)

    For playing round with Spectrum basic and machine code under Windows, I also generally use the BASin program (originally linked from the World of Spectrum archive, but I’ve found an updated version here: http://arda.kisafilm.org/blog/?page_id=848&lang=en)

    Download the program and familiarise yourself with how it works, and the display, so you can run the next example. BasinC also has a basic disassembler and debugger, so you can single step through the assembly language program.

  • Sondar says:

    THIS should now be the BASIC loader. Copy and paste it directly into the BasinC window, press Enter to move the cursor to a clear line, and enter RUN…

    10 DEF FN h(a$)=(CODE (a$)-48)-7*(a$>=”A”): REM Convert single hex digit
    20 DEF FN d(a$)=FN h(a$(1))*16+FN h(a$(2)): REM Convert 2 hex digits…
    30 RESTORE 4000
    40 LET addr=23296
    50 LET offset=0
    60 LET linenum=0
    70 READ h$
    80 IF LEN (h$)=0 THEN GO TO 3000
    90 LET l=LEN h$
    100 CLS
    110 PRINT “Line: “;4000+(linenum*10)
    120 PRINT
    130 FOR i=1 TO l STEP 2
    140 LET s$=h$(i TO i+1)
    150 LET dec=FN d(s$)
    160 LET d$=STR$ dec
    170 IF LEN d$<3 THEN LET d$=" "+d$
    180 IF LEN d$<3 THEN LET d$=" "+d$
    190 PRINT s$;" ";d$
    200 POKE addr+offset,dec: LET offset=offset+1
    210 NEXT i
    220 LET linenum=linenum+1
    230 GO TO 70

    3000 PRINT '"Finished loading data – press ENTER to call routine"
    3010 PAUSE 0: CLS
    3020 PRINT USR addr

    4000 DATA "21105B"
    4010 DATA "7E"
    4020 DATA "FE00"
    4030 DATA "2804"
    4040 DATA "D7"
    4050 DATA "23"
    4060 DATA "18F7"
    4070 DATA "012A00"
    4080 DATA "C9"
    4090 DATA "48656C6C6F2C20": REM "Hello, "
    4100 DATA "576F726C6421": REM "World!"
    4110 DATA "0D00"
    4120 DATA ""

  • Sondar says:

    As the spaces were messsed up, here’s the straight basic listing, without comments, addresses and numeric opcodes:

    ORG $5B00
    LD HL, message
    loop:
    LD A, (HL)
    CP 0
    JR Z, end
    RST 0x10
    INC HL
    JR loop
    end:
    LD BC,42
    RET
    message:
    DEFM ‘Hello, World!
    DEFB 13
    DEFB 0

  • Sondar says:

    I’m clearly having trouble with these replies!

    Here’s just the assembly language program; only opcodes. I’ll try post another reply with the full assembly listing (incl remarks) after this one…

    ORG $5B00

    LD HL, message
    loop:
    LD A, (HL)
    CP 0
    JR Z, end
    RST 0x10
    INC HL
    JR loop
    end:
    LD BC,42 ; Lo
    RET
    message:
    DEFM ‘Hello, World!’
    DEFB 13
    DEFB 0

  • tobo says:

    Can I just second that request to have this book scanned please?

    Failing that, sold perhaps?

    (worth a go, eh?)

    • josh says:

      The cover is not in best of condition but I would happy to scan this. I would also consider donating this to the community if I could find the right home for it.

  • Paul Land says:

    Is the book still available? I could Scan and or buy it so that everyone will be if it too.

    • josh says:

      Hi Paul,

      I have sent off the book to someone else to be scanned. I shall update this post as soon as that is available.

Leave a Reply

Your email address will not be published. Required fields are marked *