0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

z80のA0ピンでLEDを光らせる

0
Posted at

やりたいこと

z80を使ってLEDを光らせます。
z80にはP1ピンの様に直接ピンを使って外部機器を操作することが出来ません。
OUT命令を使うようですが、チップを追加してポート番号を変換する必要があるようです。
そこで今回は手始めにアドレスバスであるA0ピンを使います。

方法

以下のようにJP命令を2つ使います。
アドレスがするとアドレスバスが00000000と00000011の間を行き来します。
A0が交互に1と0に切り換わる為、ここにLEDを繋げると点滅すると仮説を立てました。

z80asm -o a0led.bin a0led.asm
a0led.asm
jp 0x0003
jp 0x0000

動作確認

截图 2026-10-01 23-50-17

※ メモリにa0led.binを読み込ませる

/opt/simulide-110sr0/simulide Z80.sim1
Z80.sim1
Z80.sim1
<circuit version="1.1.0-SR0" rev="1917" stepSize="1000000" stepsPS="1000000" NLsteps="100000" reaStep="1000000" animate="0" >

<item itemtype="Memory" CircId="Memory-1" mainComp="false" Show_id="false" Show_Val="false" Pos="392,-124" rotation="0" hflip="1" vflip="1" label="Memory-1" idLabPos="-16,-24" labelrot="0" valLabPos="-16,20" valLabRot="0" Address_Bits="8 _bits" Data_Bits="8 _bits" Persistent="true" Asynch="true" Input_High_V="2.5 V" Input_Low_V="2.5 V" Input_Imped="1000 MΩ" Out_High_V="5 V" Out_Low_V="0 V" Out_Imped="40 Ω" Inverted="false" Open_Collector="true" pd_n="1 _Gates" Tpd_ps="10 ns" Tr_ps="3 ns" Tf_ps="4 ns" Mem="0,3,0,-61," />

<item itemtype="MCU" CircId="Z80-2" mainComp="false" Show_id="true" Show_Val="false" Pos="220,-244" rotation="0" hflip="1" vflip="1" label="Z80-2" idLabPos="0,-20" labelrot="0" valLabPos="-16,20" valLabRot="0" Logic_Symbol="false" Producer="Zilog" CMOS="false" Single cycle I/O="false" Int_Vector="false" cpuRegs="Bus_HighZ,Bus_Op,TState_Int,TState" />

<item itemtype="Resistor" CircId="Resistor-3" mainComp="false" ShowProp="Resistance" Show_id="false" Show_Val="true" Pos="328,-12" rotation="0" hflip="1" vflip="1" label="Resistor-3" idLabPos="-16,-24" labelrot="0" valLabPos="-16,6" valLabRot="0" Resistance="10 kΩ" />

<item itemtype="Fixed Voltage" CircId="Fixed Voltage-4" mainComp="false" Show_id="false" Show_Val="false" Pos="372,-12" rotation="180" hflip="1" vflip="1" label="Fixed Voltage-4" idLabPos="-64,-24" labelrot="0" valLabPos="-16,8" valLabRot="0" Voltage="5 V" Out="true" />

<item itemtype="Led" CircId="Led-11" mainComp="false" Show_id="false" Show_Val="false" Pos="412,-232" rotation="0" hflip="1" vflip="1" label="Led-11" idLabPos="-16,-24" labelrot="0" valLabPos="-16,20" valLabRot="0" Color="Yellow" Grounded="false" Threshold="2.4 V" MaxCurrent="30 mA" Resistance="0.6 Ω" />

<item itemtype="Ground" CircId="Ground-12" mainComp="false" Show_id="false" Show_Val="false" Pos="440,-212" rotation="0" hflip="1" vflip="1" label="Ground-12" idLabPos="-16,8" labelrot="0" valLabPos="-16,20" valLabRot="0" />

<item itemtype="Resistor" CircId="Resistor-13" mainComp="false" ShowProp="Resistance" Show_id="false" Show_Val="true" Pos="372,-232" rotation="0" hflip="1" vflip="1" label="Resistor-13" idLabPos="-16,-24" labelrot="0" valLabPos="-16,6" valLabRot="0" Resistance="100 Ω" />

<item itemtype="Fixed Voltage" CircId="Fixed Voltage-15" mainComp="false" Show_id="false" Show_Val="false" Pos="660,-60" rotation="180" hflip="1" vflip="1" label="Fixed Voltage-15" idLabPos="-64,-24" labelrot="0" valLabPos="-16,8" valLabRot="0" Voltage="5 V" Out="true" />

<item itemtype="Ground" CircId="Ground-16" mainComp="false" Show_id="false" Show_Val="false" Pos="580,12" rotation="0" hflip="1" vflip="1" label="Ground-16" idLabPos="-16,8" labelrot="0" valLabPos="-16,20" valLabRot="0" />

<item itemtype="Resistor" CircId="Resistor-17" mainComp="false" ShowProp="Resistance" Show_id="false" Show_Val="true" Pos="612,-60" rotation="0" hflip="1" vflip="1" label="Resistor-17" idLabPos="-16,-24" labelrot="0" valLabPos="-16,6" valLabRot="0" Resistance="100 Ω" />

<item itemtype="Switch" CircId="Switch-18" mainComp="false" Show_id="false" Show_Val="false" Pos="580,-32" rotation="90" hflip="1" vflip="1" label="Switch-18" idLabPos="-16,-24" labelrot="0" valLabPos="-16,20" valLabRot="0" Norm_Close="false" DT="false" Poles="1" />

<item itemtype="Clock" CircId="Clock-21" mainComp="false" Show_id="false" Show_Val="false" Pos="188,-196" rotation="0" hflip="1" vflip="1" label="Clock-21" idLabPos="-64,-24" labelrot="0" valLabPos="-16,8" valLabRot="0" Out="true" Running="true" Voltage="5 V" Freq="1 kHz" Always_On="false" />

<item itemtype="Node" CircId="Node-5" mainComp="false" Pos="140,-108" />

<item itemtype="Node" CircId="Node-6" mainComp="false" Pos="304,-12" />

<item itemtype="Node" CircId="Node-7" mainComp="false" Pos="296,-12" />

<item itemtype="Node" CircId="Node-14" mainComp="false" Pos="340,-156" />

<item itemtype="Node" CircId="Node-20" mainComp="false" Pos="580,-60" />

<item itemtype="Connector" uid="Connector-1" startpinid="Resistor-3-rPin" endpinid="Fixed Voltage-4-outnod" pointList="344,-12,356,-12" />

<item itemtype="Connector" uid="Connector-5" startpinid="Z80-2-CPORT0NMI" endpinid="Node-5-1" pointList="212,-108,140,-108" />

<item itemtype="Connector" uid="Connector-6" startpinid="Z80-2-CPORT0INT" endpinid="Node-5-0" pointList="212,-116,140,-116,140,-108" />

<item itemtype="Connector" uid="Connector-8" startpinid="Z80-2-CPORT0WAIT" endpinid="Node-6-1" pointList="276,-108,304,-108,304,-12" />

<item itemtype="Connector" uid="Connector-10" startpinid="Node-6-2" endpinid="Resistor-3-lPin" pointList="304,-12,312,-12" />

<item itemtype="Connector" uid="Connector-11" startpinid="Z80-2-CPORT0BUSRQ" endpinid="Node-7-1" pointList="276,-116,296,-116,296,-12" />

<item itemtype="Connector" uid="Connector-12" startpinid="Node-5-2" endpinid="Node-7-0" pointList="140,-108,140,-12,296,-12" />

<item itemtype="Connector" uid="Connector-13" startpinid="Node-7-2" endpinid="Node-6-0" pointList="296,-12,304,-12" />

<item itemtype="Connector" uid="Connector-15" startpinid="Memory-1-in1" endpinid="Z80-2-PORTA1" pointList="368,-148,288,-148,288,-164,276,-164" />

<item itemtype="Connector" uid="Connector-16" startpinid="Memory-1-in2" endpinid="Z80-2-PORTA2" pointList="368,-140,296,-140,296,-172,276,-172" />

<item itemtype="Connector" uid="Connector-17" startpinid="Memory-1-in3" endpinid="Z80-2-PORTA3" pointList="368,-132,300,-132,300,-180,276,-180" />

<item itemtype="Connector" uid="Connector-18" startpinid="Memory-1-in4" endpinid="Z80-2-PORTA4" pointList="368,-124,304,-124,304,-188,276,-188" />

<item itemtype="Connector" uid="Connector-19" startpinid="Memory-1-in5" endpinid="Z80-2-PORTA5" pointList="368,-116,308,-116,308,-196,276,-196" />

<item itemtype="Connector" uid="Connector-20" startpinid="Memory-1-in6" endpinid="Z80-2-PORTA6" pointList="368,-108,312,-108,312,-204,276,-204" />

<item itemtype="Connector" uid="Connector-21" startpinid="Memory-1-in7" endpinid="Z80-2-PORTA7" pointList="368,-100,316,-100,316,-212,276,-212" />

<item itemtype="Connector" uid="Connector-22" startpinid="Memory-1-out0" endpinid="Z80-2-PORTD0" pointList="416,-156,512,-156,512,68,108,68,108,-132,212,-132" />

<item itemtype="Connector" uid="Connector-23" startpinid="Memory-1-out1" endpinid="Z80-2-PORTD1" pointList="416,-148,504,-148,504,64,116,64,116,-124,212,-124" />

<item itemtype="Connector" uid="Connector-38" startpinid="Memory-1-out2" endpinid="Z80-2-PORTD2" pointList="416,-140,500,-140,500,60,120,60,120,-148,212,-148" />

<item itemtype="Connector" uid="Connector-39" startpinid="Memory-1-out3" endpinid="Z80-2-PORTD3" pointList="416,-132,496,-132,496,56,128,56,128,-180,212,-180" />

<item itemtype="Connector" uid="Connector-40" startpinid="Memory-1-out4" endpinid="Z80-2-PORTD4" pointList="416,-124,492,-124,492,52,132,52,132,-188,212,-188" />

<item itemtype="Connector" uid="Connector-41" startpinid="Memory-1-out5" endpinid="Z80-2-PORTD5" pointList="416,-116,488,-116,488,-292,140,-292,140,-172,212,-172" />

<item itemtype="Connector" uid="Connector-42" startpinid="Memory-1-out6" endpinid="Z80-2-PORTD6" pointList="416,-108,484,-108,484,-288,144,-288,144,-164,212,-164" />

<item itemtype="Connector" uid="Connector-43" startpinid="Memory-1-out7" endpinid="Z80-2-PORTD7" pointList="416,-100,488,-100,488,44,148,44,148,-140,212,-140" />

<item itemtype="Connector" uid="Connector-44" startpinid="Z80-2-CPORT0MREQ" endpinid="Memory-1-Pin_Cs" pointList="212,-92,156,-92,156,-24,416,-24,416,-84" />

<item itemtype="Connector" uid="Connector-45" startpinid="Z80-2-CPORT0RD" endpinid="Memory-1-Pin_outEnable" pointList="276,-84,368,-84" />

<item itemtype="Connector" uid="Connector-46" startpinid="Z80-2-CPORT0WR" endpinid="Memory-1-Pin_We" pointList="276,-92,368,-92" />

<item itemtype="Connector" uid="Connector-47" startpinid="Led-11-rPin" endpinid="Ground-12-Gnd" pointList="428,-232,440,-232,440,-228" />

<item itemtype="Connector" uid="Connector-48" startpinid="Resistor-13-rPin" endpinid="Led-11-lPin" pointList="388,-232,396,-232" />

<item itemtype="Connector" uid="Connector-49" startpinid="Resistor-13-lPin" endpinid="Node-14-1" pointList="356,-232,340,-232,340,-156" />

<item itemtype="Connector" uid="Connector-50" startpinid="Memory-1-in0" endpinid="Node-14-0" pointList="368,-156,340,-156" />

<item itemtype="Connector" uid="Connector-51" startpinid="Node-14-2" endpinid="Z80-2-PORTA0" pointList="340,-156,276,-156" />

<item itemtype="Connector" uid="Connector-52" startpinid="Resistor-17-rPin" endpinid="Fixed Voltage-15-outnod" pointList="628,-60,644,-60" />

<item itemtype="Connector" uid="Connector-60" startpinid="Switch-18-switch0pinN" endpinid="Ground-16-Gnd" pointList="580,-16,580,-4" />

<item itemtype="Connector" uid="Connector-62" startpinid="Switch-18-pinP0" endpinid="Node-20-1" pointList="580,-48,580,-60" />

<item itemtype="Connector" uid="Connector-63" startpinid="Resistor-17-lPin" endpinid="Node-20-0" pointList="596,-60,580,-60" />

<item itemtype="Connector" uid="Connector-64" startpinid="Node-20-2" endpinid="Z80-2-CPORT0RESET" pointList="580,-60,288,-60,288,-124,276,-124" />

<item itemtype="Connector" uid="Connector-65" startpinid="Clock-21-outnod" endpinid="Z80-2-CPORT0CLK" pointList="204,-196,212,-196" />

</circuit>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?