diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-30 18:11:22 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-30 18:11:22 +0000 |
commit | c5ba5065cbf2b43101f4c311f56d55a0ff99bad6 (patch) | |
tree | 9474382abd0ef37493aeab7fc9026ae797105bb6 /misc/sims/z80sim/example | |
parent | 041fcd3ad11b63569c9fa41946787bf9eb0d4276 (diff) | |
download | nuttx-c5ba5065cbf2b43101f4c311f56d55a0ff99bad6.tar.gz nuttx-c5ba5065cbf2b43101f4c311f56d55a0ff99bad6.tar.bz2 nuttx-c5ba5065cbf2b43101f4c311f56d55a0ff99bad6.zip |
Z80 simulator
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@462 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'misc/sims/z80sim/example')
-rw-r--r-- | misc/sims/z80sim/example/Makefile | 44 | ||||
-rw-r--r-- | misc/sims/z80sim/example/example.asm | 84 |
2 files changed, 128 insertions, 0 deletions
diff --git a/misc/sims/z80sim/example/Makefile b/misc/sims/z80sim/example/Makefile new file mode 100644 index 000000000..1b12d3d75 --- /dev/null +++ b/misc/sims/z80sim/example/Makefile @@ -0,0 +1,44 @@ +AS = /usr/local/bin/as-z80 +ASFLAGS = -xlosp + +CPP = /usr/local/bin/sdcpp +CPPFLAGS = -D__ASSEMBLY__ + +CC = /usr/local/bin/sdcc +CFLAGS = -mz80 --stack-auto --int-long-reent --float-reent + +LD = /usr/local/bin/link-z80 +LDFLAGS = + +ASMEXT = .asm +OBJEXT = .rel +LIBEXT = .lib +EXEEXT = .hex + +ASRCS = example.asm +AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT)) + +CSRCS = +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(SSRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +BIN = example$(EXEEXT) + +all: $(BIN) +default: $(BIN) + +$(AOBJS): $(ASRCS) + $(AS) $(ASFLAGS) $@ $< + +$(COBJS) $(TESTOBJS): %$(OBJEXT): %.c + $(CC) -c $(CFLAGS) $< -o $@ + +$(BIN): $(OBJS) + $(CC) $(LDFLAGS) $< -o $@ + +clean: + @rm -f $(BIN) *.o *.rel *.lst *.sym *.adb *.ihx *.map *.mem *.rst *.lnk *~ + +distclean: clean diff --git a/misc/sims/z80sim/example/example.asm b/misc/sims/z80sim/example/example.asm new file mode 100644 index 000000000..ae0fc4f41 --- /dev/null +++ b/misc/sims/z80sim/example/example.asm @@ -0,0 +1,84 @@ +;************************************************************************
+; example.s
+;************************************************************************
+
+ .title z80sim Test
+ .module example
+
+;************************************************************************
+; Constants
+;************************************************************************
+
+ STACKBASE == 0xFFFF
+
+;************************************************************************
+; Data
+;************************************************************************
+
+ .area DATA (ABS,OVR)
+ .org 0x8000
+hello:
+ .ascii "Hello, World!\n\0"
+
+;************************************************************************
+; Reset entry point
+;************************************************************************
+
+ .area TEXT (ABS,OVR)
+ .org 0x0000
+ di ; Disable interrupts
+ ld SP, #STACKBASE ; Set stack pointer
+ im 1 ; Set interrupt mode 1
+ jp start ; jump to start of program
+
+;************************************************************************
+; Interrupt handler
+;************************************************************************
+
+ .org 0x0038 ; Int mode 1
+ reti ; return from interrupt
+
+;************************************************************************
+; NMI interrupt handler
+;************************************************************************
+
+ .org 0x0066
+ retn
+
+;************************************************************************
+; Start of program
+;************************************************************************
+
+ .org 0x0100
+start:
+ ;ei ; Enable interrrupts
+ ld hl, #hello ; Say hello
+ call print
+
+forever: ; Then stop execution
+ jp forever
+
+;******************************************************************
+; print *
+; Funktion....: Sen tekst and data with serielport *
+; Input.......: hl points at text start adr *
+; Output......: Text to serielport *
+; uses........: a,hl*
+; call........: TX_BUSY tst 28-4-1994 *
+;******************************************************************
+
+print:
+ push af
+loop:
+ ld a, (hl) ; Get character to print
+ cp #0 ; Null terminates the string
+ jp z, done
+
+ out (0xbe), a ; Send character
+ inc hl ; Increment to next character
+ jp loop ; Loop til done
+done:
+ pop af
+ ret
+
+
|