Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Jednodeskova vyzva 1
.ORG 0
.ENGINE mac
SERIALCTRL = 00h
SERIALDATA = 01h
DI
IM 1
LD sp,ramtop
JR cold
;rst 8
JP printa
COLD:
; serial init
LD a,15h
OUT (serialctrl),a
OUT (0x40),a
; begin message
WARM:
LD hl,hello
MAINSTR:
CALL printhl
LP1:
IN a,(0x80)
OUT (0x40),a
IN a,(0x90)
OUT (0x41),a
IN a,(0xA0)
OUT (0x42),a
IN a,(0xB0)
OUT (0x43),a
;djnz $
JR lp1
MAIN:
CALL geta
JR z,main ;no char, no fun
CP 'M'
JR z,cMem
CP 'G'
JR z,cGo
; ...
LD hl,what
JR mainstr
CMEM:
CALL getaddr
CMEM1:
LD a,0dh
RST 8
LD a,0ah
RST 8
CALL printaddr
LD a,' '
RST 8
LD a,(hl)
CALL printhex
LD a,' '
RST 8
LD c,(hl)
CALL getbyte
LD (hl),c
INC hl
LD a,b
CP 0dh
JR z,cMem1
JP warm
CGO:
CALL getaddr
JP (hl)
COK:
JR main
; Service routines
GETADDR:
LD hl,addr
CALL printhl
LD hl,0
GETADDR1:
CALL geta
JR z,getaddr1
RST 8
CALL ishex
RET c
CALL atohex
ADD hl,hl
ADD hl,hl
ADD hl,hl
ADD hl,hl
ADD a,l
LD l,a
JR getaddr1
GETBYTE:
LD b,0
GETB1:
CALL geta
JR z,getb1
RST 8
CALL ishex
LD b,a
RET c
CALL atohex
SLA c
SLA c
SLA c
SLA c
ADD a,c
LD c,a
JR getb1
ISHEX:
CP 'F'+1
JR nc,nothex
CP '0'
RET
NOTHEX:
SCF
RET
ATOHEX:
SUB '0'
CP 0ah
RET c
SUB 'A'-'9'-1
RET
PRINTHL: LD a,(hl)
AND 7fh
RST 8
LD a,(hl)
AND 0x80
RET nz
INC hl
JR printhl
PRINTADDR:
LD a,h
CALL printhex
LD a,l
PRINTHEX:
PUSH af
RRA
RRA
RRA
RRA
AND 0fh
ADD a,'0'
CP '9'+1
JR c,printhex1
ADD a,7
PRINTHEX1:
RST 8
POP af
AND 0fh
ADD a,'0'
CP '9'+1
JR c,printa
ADD a,7
PRINTA:
PUSH af
SERDY:
IN a,serialctrl
AND 02
JR z,serdy
POP af
OUT serialdata,a
RET
GETA:
IN a,serialctrl
AND 01h
RET z
IN a,serialdata
OR a
RET
HELLO:
.ISTR "JESS01 ready",0x0d,0x0a
WHAT:
.ISTR '?',0dh,0ah
ADDR:
.ISTR 'Addr:'
ROMEND:
.ORG 1000h
RAM:
.ORG 1400h - 3
RAMTOP EQU $
LASTKEY: DS 1
BUFA: DS 2
RAMEND EQU $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment