rob.masm

mud++0.35/mudC/rob.masm · 1.6 KB

From the archive mud++0.35.tar.gz

Download the archive   « Back to the archive contents

# rob.masm
# MUD Assembler functions for VM

!constant string Some string~

!funstart sample_fun
!A PC pc
!A string str1
	pushc string You managed to call sample_fun.~
	pushl 0
	fcall echo_fun
	ret
!funend

!funstart echo_fun
!A PC pc
!A string str1
	pushl 1
	pushl 0
	icall out_string_P_pPC_s
	ret
!funend

!funstart makeobj
!A PC pc
!A string str1
!L Object obj
	pushl @str1
	icall getObjPrototype_P_s
	clone
	isnull e OBJ_NOT_FOUND
	icall copyObject_P_pObject
	popl @obj
	pushl 0
	icall inRoom_P_pThing
	pushl @obj
	icall toRoom_P_pObject_pRoom
	pushc string Done.~
	pushl @pc
	icall out_string_P_pPC_s
	ret
:OBJ_NOT_FOUND pop
	pushc string No such object~
	pushl @pc
	icall out_string_P_pPC_s
	ret
!funend

#This one is intentionally broken - it creates object and leaves it unassigned
!funstart makeobjfake
!A PC pc
!A string str1
!L Object obj
	pushl @str1
	icall getObjPrototype_P_s
	clone
	isnull e OBJ_NOT_FOUND
	icall copyObject_P_pObject
	popl @obj
	pushc string Done.~
	pushl @pc
	icall out_string_P_pPC_s
	ret
:OBJ_NOT_FOUND pop
	pushc string No such object~
	pushl @pc
	icall out_string_P_pPC_s
	ret
!funend




# This is fun -Fusion
!funstart say
!A PC pc
!A string str1
	pushl @str1
	pushl @pc
	icall say_P_pChar_s
	ret
!funend

# Try 'vmftest benchmark 100000' to see how
# fast the VM really is! -Fusion
!funstart benchmark
!A PC pc
!A string str1
	pushl @pc
	icall out_time_P_pPC
	pushl @str1
	stoint
	popl @str1
:DO_AGAIN decl @str1
	lieval g @str1 DO_AGAIN
	pushl @pc
	icall out_time_P_pPC
	ret
!funend

!end

Site Stats

Snippets: 1791
Codebases: 571