dcpu16

Virtual Machine and Assembler for Notch's DCPU-16 Architecture
git clone http://frotz.net/git/dcpu16.git
Log | Files | Refs | README

example.s (578B)


      1 ; DCPU-16 Example from Specification
      2 ; Copyright 2012 Mojang
      3 
      4 ; Try some basic stuff
      5 	SET A, 0x30		; 7c01 0030
      6 	SET [0x1000], 0x20	; 7de1 1000 0020
      7 	SUB A, [0x1000]		; 7803 1000
      8 	IFN A, 0x10		; c00d 
      9 		SET PC, crash	; 7dc1 001a [*]
     10 
     11 ; Do a loopy thing
     12 	SET I, 10		; a861
     13 	SET A, 0x2000		; 7c01 2000
     14 :loop
     15 	SET [0x2000+I], [A]	; 2161 2000
     16 	SUB I, 1		; 8463
     17 	IFN I, 0		; 806d
     18 		SET PC, loop	; 7dc1 000d [*]
     19 
     20 ; Call a subroutine
     21 	SET X, 0x4		; 9031
     22 	JSR testsub		; 7c10 0018 [*]
     23 	SET PC, crash		; 7dc1 001a [*]
     24 
     25 :testsub
     26 	SHL X, 4		; 9037
     27 	SET PC, POP		; 61c1
     28 
     29 :crash
     30 	WORD 0xeee0