8位和16位处理器如何通过两个寄存器访问更多RAM? [英] How do 8-bit and 16-bit processors access more RAM with two registers?
问题描述
让我一直感到困惑的是8位计算机如何访问超过256字节的RAM.我知道它必须使用两个寄存器,但是任何一个都可以给我展示一下汇编代码中的示例吗?
Something that has always confused me is how 8-bit computers access more than 256 bytes of RAM. I know that it must use two registers, but can any one show me an example of what this would look like in assembly code?
赞:
mov a, [x] ???
推荐答案
让我们假设我们在寄存器L和H中具有地址的LOWER和HIGHER 8bit一半.例如,我们要从地址32770读取字节dec = 8002 hex
Let's imagine we have LOWER and HIGHER 8bit half of the address in registers L and H. For example, we want to read byte from address 32770 dec = 8002 hex.
mov l, 02h ;lower byte of address
mov h, 80h ;higher byte of address
mov a, [hl] ;a <-- [h*256 + l]
CPU中存在许多寻址模式.因此,我们可以有一个不同的示例,例如只需一个寄存器和一个直接地址:
Many addressing modes exist in CPUs. So we can have a different example, e.g. with just a single register and an immediate address:
mov h, 80h
mov a, [2] ;a <-- [h*256 + immediate]
它始终取决于特定的CPU体系结构.例如,Zilog Z80被称为8位CPU,但它也包含许多16位指令.您可以像这样对它进行索引寻址:
It always depends on a particular CPU architecture. For example Zilog Z80 is called 8-bit CPU but it also contains many 16-bit instructions. You can do indexed addressing on it like this:
mov ix, 8002h ;base address of an array
mov a,[ix+20] ;a <-- [ix + 20] i.e. read a byte from an array like ix[20] in C
注意: 那些旧的8位CPU使用8位累加器,即它们只能在8位寄存器中计算数学和其他算术运算,因此它们在软件计算级别上为8位.它们的内存访问单元是8位的,即它一次只能读取或写入一个字节的内存,因此它们在硬件级别上也是8位的.这些16位指令很慢,实际上它们是连续执行一对8位运算的.
Note: Those old 8-bit CPU's use an 8-bit accumulator, i.e. they can compute math and other arithmetic stuff only in an 8-bit register, so they are 8-bit on a software computation level. And their memory accessing unit is 8-bit, i.e. it can read or write just a single byte of memory at a time, so they are 8-bit on hardware level too. Those 16-bit instructions are slow, they actually do a pair of 8-bit operations in succession.
这篇关于8位和16位处理器如何通过两个寄存器访问更多RAM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!