No video

Z80 Computer - Part 6 The Stack & Subroutine Calls

  Рет қаралды 4,987

Steve Rayner Makes

Steve Rayner Makes

Күн бұрын

In this part, I look at the concept of the stack and subroutine calls. After a quick overview of the Z80 registers, I start by explaining what a stack is and how it works. I look at the push and pop instructions and then show a small program. I step through it line by line, watching some of the registers and the area of memory where the stack resides.
Next, I look at subroutine calls. I discuss the call and ret instructions and then look at another program.
Finally, I show a third program that makes use of subroutine calls and I demonstrate this running on the hardware.

Пікірлер: 26
@melkiorwiseman5234
@melkiorwiseman5234 Жыл бұрын
At some point, I hope you'll mention the undocumented instructions which, on all Z80 CPUs I've seen or tested so far, will allow you to treat the IX and IY registers as two 8-bit registers each. The IX and IY instructions all use a prefix followed by the number used for the same operation on the HL register pair. It turns out that if you put the prefix before one of the 8-bit instructions for dealing with H or L separately, you can access the high and low sections of the IX and IY registers separately. Edit to add: It may have been worthwhile during the explanation of the stack "growing downwards" to have started the stack pointer at 0000 hex in order to demonstrate how the memory effectively "wraps around" as far as addressing is concerned.
@PE4Doers
@PE4Doers Жыл бұрын
Again - Excellent series. Thanks You Sir 😊
@kdmq
@kdmq 5 ай бұрын
Just thinking outside the box, I would think "jr, FE" should technically function as a halt instruction, because it decrements the program counter by 2 and executes the same jr again. At least, that's how I understand it. The only difference is your red halt LED will not light up.
@boredfish80
@boredfish80 3 ай бұрын
I have a reasonable grasp of assembly so almost skipped over this one. Glad I didn’t; I wrote a Spectrum emulator and this made me check the stack handling logic. Turns out that I was decrementing the stack pointer AFTER each byte was added - which still works 99% of the time as my POP code matched, but now and again was clattering something when running larger programs. A quick change, one less bug to fix and at least two programs no longer freezing up!
@SteveRaynerMakes
@SteveRaynerMakes Ай бұрын
awesome.
@cygil1
@cygil1 Ай бұрын
Ah, rookie mistake. The most dangerous things are the things you think you know, that ain't so. Naturally the stack post decrements, that's only sensible. Except it doesn't.
@nand3kudasai
@nand3kudasai 8 ай бұрын
awesome video and explantion. it might be worth nothing that the 'register pushin/popping inside the called sub' is sometimes specified as a 'calling convention' on systems that have multiple programs interoperating. what you've described is pretty similar to how desktop does it afaik (with the exception that you're passing a parameter in a registry (clarion) instead of the stack). but there are other conventions that are worth checking, since its fairly arbitrary convention. i personally prefer the clarion/pascal one.
@Philip8888888
@Philip8888888 Жыл бұрын
Could you please also show the back of the board and describe how you make the connections?
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
No. Well... ok then. I'll show this in the next part. I use wire-wrap wire, and it looks a bit like a rats nest. There would most likely be issues if we were running the clock a high speed, but at these low speeds it working fine for now. I will eventually move to a printed circuit board.
@user-mn1ul2ut8i
@user-mn1ul2ut8i Жыл бұрын
there are many wires there :)
@Philip8888888
@Philip8888888 Жыл бұрын
@@SteveRaynerMakes you use wire wrap method or do some kind of point to point soldering?
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
@@Philip8888888 No I don't use the wire wrap technique, I just solder the wires.
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
@@Philip8888888 I have added a photograph on the Community tab of my channel page.
@abrahamjushua9491
@abrahamjushua9491 Жыл бұрын
It will be nice and very informative if you design some monitor program (just a primitive operating system) for this computer witch will make it more usable at some extent.
@ssalbach
@ssalbach Жыл бұрын
Which 7-Segement decoder Chip do you nuse? I bought old ones from ebay, because new ones don't have nice Symbols for A-F, but the Chips looks like newer ones than mine
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
I'm using the DM9368. I don't like it though because it uses a lot of current and I can't control the brightness of the LEDs. There might be a way of doing it, but I haven't figured it out yet. I think these chips.are pretty hard to get hold of.
@M0GLU
@M0GLU Жыл бұрын
@@SteveRaynerMakes Decreasing the LED display current, option one: add a serial resistor to each segment line option two adds one common resistor between the GND (not proper because the segment brightness continuously changes, depends how many segments are active)
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
@@M0GLU neither would work because the DM9368 is a constant current source. If you add more resistance the chip will just increase the voltage to keep the current constant.
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
i suppose the voltage must max out at some point though, as it can't really go above the 5v supply voltage
@M0GLU
@M0GLU Жыл бұрын
@@SteveRaynerMakes Ohh yess. It's logical. Can you tell me the proto-board size?
@user-mn1ul2ut8i
@user-mn1ul2ut8i Жыл бұрын
Hey Steve you forgot to mention variables
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
There is no concept of variables in assembly language.
@user-mn1ul2ut8i
@user-mn1ul2ut8i Жыл бұрын
@@SteveRaynerMakes Yes it is.I wanted to say about "place in memory with names"
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
@@user-mn1ul2ut8i Ok. You are referring to the db (define byte) assembler directive. This isn't something that really exists in Z80 instruction set, but rather something the assembler adds to make life a little easier for the developer. Should we move on to the assembler in the next video? Then I can cover a few of the available directives.
@user-mn1ul2ut8i
@user-mn1ul2ut8i Жыл бұрын
@@SteveRaynerMakes i would like to see.Thank you
Z80 Computer - Part 7 Keyboard Layout
22:50
Steve Rayner Makes
Рет қаралды 3,4 М.
Pony80 - Z80 CPU Architecture - My Z80 homebrew computer!
26:37
а ты любишь париться?
00:41
KATYA KLON LIFE
Рет қаралды 3,2 МЛН
Little brothers couldn't stay calm when they noticed a bin lorry #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 19 МЛН
Вы чего бл….🤣🤣🙏🏽🙏🏽🙏🏽
00:18
managed to catch #tiktok
00:16
Анастасия Тарасова
Рет қаралды 43 МЛН
R2KW
4:52
Dimitris TL
Рет қаралды 3
Building the most controversial Z80 Computer ever
25:58
Ready? Z80
Рет қаралды 75 М.
Z80 Computer - Part 8 Testing Input
27:09
Steve Rayner Makes
Рет қаралды 3,2 М.
Minimalist Europe Card Bus (MECB) - 6309 PLCC packaged CPU Card
15:02
Top Fifteen Mistakes People Make When Designing Prototype PCBs
12:26
Cosplay Light and Sound
Рет қаралды 146 М.
Modern Z80 Computer RAM/ROM Options
15:29
Kenneth Finnegan
Рет қаралды 53 М.
Running Apple 1 software on a breadboard computer (Wozmon)
14:23
The CPUville Z80 Single Board Computer
16:28
Jeff Tranter
Рет қаралды 7 М.
Designing a Card Slot Modular Z80 Computer
14:29
Joshua Coleman Makes
Рет қаралды 43 М.
Z80 Computer - Part 1 The CPU, Clock & Reset
44:25
Steve Rayner Makes
Рет қаралды 31 М.
а ты любишь париться?
00:41
KATYA KLON LIFE
Рет қаралды 3,2 МЛН