Skip to content

Commit

Permalink
wip: hello world sample
Browse files Browse the repository at this point in the history
  • Loading branch information
fkokosinski committed Jun 3, 2024
1 parent 0d1fab9 commit ff2bc0d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
21 changes: 21 additions & 0 deletions asm-hello-world/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
APP_NAME ?= main
objects := $(patsubst %.S,%.o,$(wildcard *.S))

default: $(APP_NAME).rim

%.o: %.S
pdp1-elf-as $< -o $@

$(APP_NAME).bin: script.ld $(objects)
pdp1-elf-ld -o $@ -T $^

%.rim: %.bin
pdp1-elf-objcopy -O dec_rim $< $@

run: $(APP_NAME).rim
pdp1 startup.pdp1

clean:
rm -rf *.o *.bin *.rim

.PHONY: default run clean
44 changes: 44 additions & 0 deletions asm-hello-world/main.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* Simple asm program that prints out 'hello, world' on standard output */

.section .data
i:
.byte 0
ptr:
.byte str
len:
.byte end - str
str:
/* TOOD: use .ascii-derived FIODEC directive here */
.byte 070
.byte 065
.byte 043
.byte 043
.byte 046
.byte 033
.byte 000
.byte 026
.byte 046
.byte 051
.byte 043
.byte 064
.byte 056
end:

.section .text
.global _start
_start:
/* load IO register with *ptr and print it */
lio.i ptr
tyo

/* ptr++, i++ */
idx ptr
idx i

/* if (i == len) goto _start */
lac i
sas len
jmp _start

/* halt */
hlt
20 changes: 20 additions & 0 deletions asm-hello-world/script.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
OUTPUT_FORMAT("elf32-pdp1")
ENTRY(_start)

MEMORY
{
ram (rwx) : ORIGIN = 0x0, LENGTH = 64K
}

SECTIONS
{
.text :
{
*(.text)
} > ram

.data 0x400 :
{
*(.data)
} > ram
}
3 changes: 3 additions & 0 deletions asm-hello-world/startup.pdp1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
att ptr main.rim
boot ptr
q

0 comments on commit ff2bc0d

Please sign in to comment.