Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

50%
+0 −0
Challenges "Hello, World!"

Z80 Assembler, 50 bytes org 256 ld de,m ld c,9 jp 5 m:db"Hello, world!\r$" With assembler there's usually the problem which machine or operating system the program is for. I've chosen CP/M ...

posted 2y ago by __blackjack__‭

Answer
#1: Initial revision by user avatar __blackjack__‭ · 2022-09-19T16:08:14Z (over 2 years ago)
# Z80 Assembler, 50 bytes

```z80asm
org 256
ld de,m
ld c,9
jp 5
m:db"Hello, world!\r$"
```

With assembler there's usually the problem which machine or operating system the program is for. I've chosen CP/M here as it runs on a variety of different machines with a Z80 processor.

CP/M programs start at address 0x100, but the decimal representation 256 is shorter.

The program loads the address of the $-terminated string into the D & E register pair, then the number of the print text subroutine (9) into the C register, and jumps to the BDOS entry.  It uses the `RET`urn of that routine to end itself, instead of `CALL`ing the BDOS and needing an own `RET` instruction in the program.