URL
https://opencores.org/ocsvn/z80soc/z80soc/trunk
Subversion Repositories z80soc
[/] [z80soc/] [branches/] [RonivonCosta/] [ROM/] [SoC_PS2.z8a] - Rev 2
Go to most recent revision | Compare with Previous | Blame | View Log
ld sp,0FFFFh ; Put Stack on top of memory
inicio:
call clear
ld de,2033h
ld hl,Text
call printmsg
ld de,205Bh
ld hl,Text2
call printmsg
setDelay:
in a,(20h) ; Read SW(7-0)
ld (0E000h),a ; Stores delay multiplier
; to be used in Delay routine
; This value it is set only when
; Z80 is reset
setprint:
ld de,2000h
ld bc,1200
loopprint:
call read_kbd
cp 41h
jr z,go_on
OUT (11H),A
ld (de),a
inc de
dec bc
ld a,b
or c
jr z,setprint
jr loopprint
go_on:
ld hl,4000h ; RAM Address
ld a,0 ; Value to store in memory
loop1:
ld (hl),a ; Store A into Memory (HL)
inc hl ; Point to next memory location
inc a ; Add 1 to value to store in memory
jr nz,loop1 ; If A not equal 0 continue loop1
; When A=FFh, and we make A=A+1 ...
; A becomes 100h
; But, A is an 8 bits register, and
; can only store the two last hex digits,
; that is, 8 bits.
ld a,1
out (01h),a
call delay
call delay
call delay
call read_key0 ; Wait until KEY0 is pressed
call delay
call read_key0
;
ld hl,4000h ; Get back the start RAM address
loop2:
ld a,h
out (11h),a
ld a,l
out (10h),a
ld a,(hl) ; Read back the values stored in loop1
out (01h),a ; Send to Green Leds
call delay ; Call sub-routine to delay some time
inc hl ; Add 1 to the memory location
ld a,(hl) ; Read the value in the memory
cp FFh ; check if equal 255
jr nz,loop2 ; If not equal 255, continue loop2
; end of First execution
ld a,00h ;
out (01h),a ; Turn off leds
out (02h),a
call read_key0 ; Wait until KEY0 is pressed
jr inicio ; Restart program
read_key0:
loop3:
call delay
in a,(30h) ; Read KEYs (all 4 KEYs)
out (10h),a
cp 0Eh ; check if returns "00001110"
jr nz,loop3 ; KEY0 not pressed, continue checking
ret
iodelay:
ld a,(0E000h) ; Read the number of times to loop
loop4:
dec a ; Start counting backwards
jr nz,loop4 ; If A greather than 0, continue loop
ret ; return to calling program
delay:
ld a,(0E000h) ; Read the delay mulpitplier
loop5:
PUSH af
ld a,ffh ; Every delay has at least 255 loops
loop6:
dec a ; Start counting backwards
jr nz,loop6 ; If A greather than 0, continue loop
pop af ; Get multiplier back
dec a ;
jr nz,loop5
ret ; return to calling program
clear:
ld hl,2000h
ld de,1200
clean_loop:
ld a,20h
ld (hl),a
inc hl
dec de
ld a,d
or e
jr nz,clean_loop
ret
printmsg:
ploop:
ld a,(hl)
or a
ret z
ld (de),a
inc hl
inc de
;push hl
;push de
;call read_key0
;call delay
;pop de
;pop hl
jr ploop
read_kbd:
call delay
in a,(80h)
or a
jr z,read_kbd
ret
Text:
db "Z80 SYSTEM ON CHIP"
db 0
Text2:
db "RONIVON COSTA 2008"
db 0
Go to most recent revision | Compare with Previous | Blame | View Log