Kaptam egy Samsung DTIM nevű kb. 1991-ban gyártott PCB-t. Zilog Z80-as processzor van rajta, eredetileg 32 KiB EPROM-mal és 8 KiB SRAM-mal felszerelve. Az EPROM-ot AM29F040 flash memóriára cseréltem és egy egyszerű assembly programot égettem bele. Az eredmény:
(Mottó: Minden beágyazott CPU/MCU villogó LED vezérlésként kezdi pályafutását.)Az EPROM/flash a 0..0x7FFF címeken érhető el, az SRAM a 0x8000..0x9FFF tartományban van. A 0xC portot írva pedig egy 74HCT374 IC-be kerül az adat. Ennek az IC-nek a Q0 és Q1 kimenetére kötöttem a két zöld LED-et.
A program forrása (sdasz80 -al fordítható):
.module test
.area _HEADER (ABS);; Reset vector
.org 0
;; Stack at the top of memory.
ld sp,#0x9fff
loop:ld c, #0x0C
ld b, #0xAA
out (c), b
call delay
ld c, #0x0C
ld b, #0x55
out (c), b
call delay
jp loop delay:ld bc, #0x10 ;Loads BC with hex 10
delay_outer:
ld de, #0x1000 ;Loads DE with hex 1000
delay_inner:
dec de ;Decrements DE
ld a, d ;Copies D into A
or e ;Bitwise OR of E with A (now, A = D | E)
jp nz, delay_inner ;Jumps back to Inner: label if A is not zero
dec bc ;Decrements BC
ld a, b ;Copies B into A
or c ;Bitwise OR of C with A (now, A = B | C)
jp nz, delay_outer ;Jumps back to Outer: label if A is not zero
ret ;Return from call to this subroutine
1\$:halt
jr 1\$
;; Ordering of segments for the linker..area _HOME
.area _CODE
.area _GSINIT
.area _GSFINAL
.area _DATA.area _BSEG
.area _BSS
.area _HEAP
.area _CODE