Follow

cpu% lc3/lc3 -f out.hex
hello world!
Program complete, exiting

I've still got a few things to implement in both the VM and the assembler before it's actually feature complete and then I've got a few things I want to add for shits and giggles but I'm pretty happy about that!

```
.ORIG x3000
NOP
ADD R2,R2,x6 ; we need 6 loops to get to 'h'
NOT R2,R2 ; we want to be able to subtract this number so we'll 2's complements it
ADD R2,R2,x1
LOOPH ADD R0,R0,xf
ADD R1,R1,x1
ADD R3,R1,R2 ; compare if we're at 6 loops yet
BRn LOOPH
ADD R0,R0,xe
OUT
E .FILL x65
L .FILL x6c
O .FILL x6f
LD R0,E
OUT
LD R0,L
OUT
OUT
LD R0,O
OUT
.BLKW x5
LEA R0,WRLD
PUTSP
HALT
WRLD .STRINGZ x20776f726c64210a
.END
```

For those who care

The "6 loops" stuff is because I wanted to test the functionality I'd already implemented in the assembler to print some stuff out but I'd not implemented any of the raw data directives (`.FILL`, `.BLKW` and `.STRINGZ`) yet, and the immediate mode for `ADD` only takes a maximum 5-bit signed integer meaning the maximum hex value I could increment by was 0xf, and `h` is 0x68.

So in the end I iteratively went through and added all the data directives and used them all in the final program :)

Sign in to participate in the conversation
Hellsite

Hellsite.site is a small mastodon instance focused on community, tech, hacking and leftist views as well as being fierce rivals with notbird.site. We run a custom fork of the mastodon code called Goatstodon that runs some slight improvements. Come for the shitposting, stay for the infinite polls!