org &1000 main: ld hl,XML_Header ld de,XMLRam call strcpy ld hl,XML_Root push hl call AddXMLNode ld hl,XML_Element push hl call AddXMLNode ld hl,XML_Entry call strcpy pop hl ;ld hl,XML_Element call CloseXMLNode pop hl ;ld hl,XML_Root call CloseXMLNode ld hl,XMLRam jp PrintString ;and then return to basic. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; AddXMLNode: ;hl = pointer to desired node name ;de = destination ram ;carry flag; set = , clear = push af ld a,'<' ld (de),a inc de call strcpy pop af jr nc,skip_AddXMLNode ld a,'/' ld (de),a inc de skip_AddXMLNode: ld a,'>' ld (de),a inc de xor a ld (de),a ;don't inc de afterwards, since we may want to add more ret CloseXMLNode: ld a,'<' ld (de),a inc de ld a,'/' ld (de),a inc de call strcpy ld a,'>' ld (de),a inc de xor a ld (de),a ret PrintString: ld a,(hl) or a ret z call &BB5A inc hl jr PrintString strcpy: ;HL = string source ;DE = destination ;copies 1 byte at a time until a null terminator is copied, then exits. ld a,(hl) ld (de),a or a ret z inc hl inc de jp strcpy org &1200 XML_Header: byte "",0 XML_Root: byte "root",0 XML_Element: byte "element",0 XML_Entry: byte "some text here",0 org &1300 XMLRam: ;this is where the output is stored.