Lesson H2 - Hello World on the ZX Spectrum

Posts relating to ZX Spectrum (and clones)... also Spectrum NEXT
Post Reply
User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Lesson H2 - Hello World on the ZX Spectrum

Post by akuyou » Sun Sep 01, 2019 9:35 pm



http://www.chibiakumas.com/z80/helloworld.php#LessonH2

The ZX Spectrum is one of the most popular Z80 machines around, and it's well emulated too!

Unfortunately, making usable Disk or Tape images can be a bit tricky, but we can get around it with some work!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

_dw
Posts: 4
Joined: Thu Dec 07, 2023 3:46 am

Re: Lesson H2 - Hello World on the ZX Spectrum

Post by _dw » Thu Dec 07, 2023 8:06 pm

For comparison

Forth (hello.fth)

Code: Select all

." Hello Word!"
M4 FORTH (use ../fth2m4.sh hello.fth > hello.m4)

Code: Select all

include(`../M4/FIRST.M4')dnl
  ifdef __ORG
    org __ORG
  else
    org 32768
  endif
  INIT(60000)
PRINT({"Hello World!"})
  STOP
ZX Spectrum asm (use ../compile.sh hello 32768)

Code: Select all

  ifdef __ORG
    org __ORG
  else
    org 32768
  endif
  

  

;   ===  b e g i n  ===
    ld  [Stop+1], SP    ; 4:20      init   storing the original SP value when the "bye" word is used
    ld    L, 0x1A       ; 2:7       init   Upper screen
    call 0x1605         ; 3:17      init   Open channel
    ld   HL, 0xEA60     ; 3:10      init   Return address stack = 60000
    exx                 ; 1:4       init
    push DE             ; 1:11      print     "Hello World!"
    ld   BC, size101    ; 3:10      print     Length of string101
    ld   DE, string101  ; 3:10      print     Address of string101
    call 0x203C         ; 3:17      print     Print our string with ZX 48K ROM
    pop  DE             ; 1:10      print
Stop:                   ;           stop
    ld   SP, 0x0000     ; 3:10      stop   restoring the original SP value when the "bye" word is used
    ld   HL, 0x2758     ; 3:10      stop
    exx                 ; 1:4       stop
    ret                 ; 1:10      stop
;   =====  e n d  =====

STRING_SECTION:
string101:
    db "Hello World!"
size101              EQU $ - string101
A hello.tap containing both the binary program and the basic loader (with the program duration calculated for testing) will also be created automatically. The tap file is immediately launched in fuse after compilation.
Z80 Forth compiler (ZX Spectrum 48kb): https://codeberg.org/DW0RKiN/M4_FORTH

Post Reply

Return to “ZX Spectrum Assembly Programming”