assembly - 初学者裸机pdp11控制台输出

标签 assembly emulation simulator bare-metal pdp-11

我正在尝试了解使用 pdp-11 的基本知识(在大学学习了指令集,想重温一下),想要将一些角色从 TTO/DL11 中射出作为第一个程序(除非这太复杂的第一个程序)。

在 simh 上运行。显示开发人员有

TTO, address=17777564-17777567, vector=64

阅读文档,tx 缓冲区位于偏移量 566 处。在 stackoverflow 和其他一些页面上查看其他代码时,上层地址空间中存在/可能存在一个 mmu,其中显示 177566(八进制)可能会将您带到那里,因为寄存器不是 16 位正如显示开发人员所暗示的 22 位。

mov $0x32,r1
movb r1, @$0177566
mov $0177566,r2
mov $0x30,r3
movb r3,(r2)
mov $0x31,r3
movb r3,(r2)
halt

什么也没出来。

load test.bin
go

可以使用 set console telnet=4444 并 telnet 到该位置,没有任何变化。毫无疑问,这是我不明白的关于 16 位以上寻址的问题,但不太确定到哪里去解决这个问题。

基本上我想,除非有很多代码(数千行asm)来从控制台中获取一些字符,否则我想从那里开始开始“看到”某些东西,然后在此基础上进行构建。因此,如果我很接近但不完全,或者如果这不是最好的外设,那么应该去哪里,它们都在较高的地址空间中。

我正在使用 gnu 工具

pdp11-aout-as --version
GNU assembler (GNU Binutils) 2.26.20160125
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `pdp11-aout'.

所以语法有点愚蠢/不标准。 pdp11 至少现在已经在 binutils 的几个版本中得到支持,我们也希望能够利用这一点。 simh 的二进制文件格式并不太难弄清楚,单步执行它与我想要的指令相匹配并提供 gnu 汇编程序。

尝试了 apt-got v3.8-1 版本的 simh pdp11 以及 github get 4.0 版本,结果相同。使用 pdp11 模拟器/可执行文件。

sim> show config
PDP-11 simulator configuration

CPU, 11/73, NOCIS, idle disabled, autoconfiguration enabled, 256KB
SYSTEM
RHA, address=17776700-17776753, vector=254
RHB, disabled
CLK, 60Hz, address=17777546-17777547, vector=100
PCLK, disabled
PTR, address=17777550-17777553, vector=70, not attached
PTP, address=17777554-17777557, vector=74, not attached
TTI, address=17777560-17777563, vector=60, 7b
TTO, address=17777564-17777567, vector=64, 7p
CR, address=17777160-17777167, vector=230, 285 cards per minute, translation 029, not attached, CR11, auto EOF, unknown format
LPT, address=17777514-17777517, vector=200, not attached
DLI, disabled
DLO, disabled
...

编辑

#define TKS (*((volatile unsigned *)0177560))
#define TKB (*((volatile unsigned *)0177562))
#define TPS (*((volatile unsigned *)0177564))
#define TPB (*((volatile unsigned *)0177566))

void punch ( unsigned x )
{
    while((TPS&0x80)==0) continue;
    TPB=x;
}

void notmain ( void )
{
    //unsigned ra;
    //for(ra=0x30;ra<0x37;ra++) punch(ra);
    punch(0x30);
    while((TPS&0x80)==0) continue;
    return;
}

这使得

Disassembly of section .text:

00000000 <start.o>:
   0:   15c6 2000       mov $20000, sp
   4:   09f7 001a       jsr pc, 22 <_punch+0x18>
    ...

0000000a <_punch>:
   a:   1166            mov r5, -(sp)
   c:   1185            mov sp, r5
   e:   17c0 ff74       mov *$177564, r0
  12:   45c0 ff7f       bic $-201, r0
  16:   03fb            beq e <_punch+0x4>
  18:   1d5f 0004 ff76  mov 4(r5), *$177566
  1e:   1585            mov (sp)+, r5
  20:   0087            rts pc
  22:   1166            mov r5, -(sp)
  24:   1185            mov sp, r5
  26:   17c0 ff74       mov *$177564, r0
  2a:   45c0 ff7f       bic $-201, r0
  2e:   03fb            beq 26 <_punch+0x1c>
  30:   15df 0030 ff76  mov $60, *$177566
  36:   17c0 ff74       mov *$177564, r0
  3a:   45c0 ff7f       bic $-201, r0
  3e:   03fb            beq 36 <_punch+0x2c>
  40:   1585            mov (sp)+, r5
  42:   0087            rts pc

有两个问题,其中一个是我没等到忙。在初始化/重置时,没关系,它不忙。我认为最关键的是我在它吐出角色之前停了下来。当我有循环时,它吐出了大部分字符。如果我发送一个字符并停止它就不会出来,但是如果我将等待忙碌置零(notmain()中的最后一件事),那么该字符就会出来。

如果我把它改成这样

#define TKS (*((volatile unsigned *)0177560))
#define TKB (*((volatile unsigned *)0177562))
#define TPS (*((volatile unsigned *)0177564))
#define TPB (*((volatile unsigned *)0177566))

void punch ( unsigned x )
{
    TPB=x;
    while((TPS&0x80)==0) continue;
}

void notmain ( void )
{
    unsigned ra;
    for(ra=0x30;ra<0x37;ra++) punch(ra);
    return;
}

它工作得很好......谢谢你让我开始。

手册注释:

In addition to the word length constraint on basic memory addressing
space, the uppermost 4K words of address space is always reserved for
UNIBUS 1/0 device registers. In a basic PDP-11/40 memory configura·
tion (without Management) all address references to the uppermost 4K
words of 16-bit address space (170000-177777) are converted to full
18-bit reference5 with bits 17 and 16 always set to 1. Thus, a 16·bit
reference to the 1/0 device register at address 173224 is automatically
internally converted to a full 18-bit reference to the register at address
773224. Accordingly, the basic PDP-11/40 configuration can directly
address up to 28K words of true memory, and 4K words of UNIBUS 1/0
device registers.

所以答案就在那里,我没有找对地方。

编辑2:

在汇编中,为了实现从 tty 发送字符的目标,使用 gnu 汇编器语法(* 代替 @,$ 代替 #)

movb $0x32,*$0177566
pwait:
   tstb *$0177564
   bpl pwait
halt

最佳答案

我认为问题在于没有正确使用DL11。您不能随时赋予它一个角色。您必须测试控制寄存器中的“就绪”标志。然后,当准备好后发送角色。此外,您无法可靠地从数据寄存器中读回值。然后您使用该字符作为内存指针(那里肯定会有内存,但写入它可能不是您想要的)。

您可能还有兴趣查看Retrocomputing堆栈交换站点。我可能不是唯一一个拥有 PDP-11 经验的人,但我可能就在这里。

关于assembly - 初学者裸机pdp11控制台输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38387155/

相关文章:

linux - x86-64 System V ABI 记录在哪里?

assembly - 对于无条件跳转指令 0xFF,Mod R/M 字节携带什么含义(如果有)?

Android - 在模拟器中同时运行两个不同的程序

java - 运行 j2me 应用程序时出现问题

sockets - Windows Phone对等-模拟器看不到第二个模拟器

ios - UILocalNotification 不会在 ios9 设备上触发(横幅未显示)

Xcode 6.3.1 模拟器 UI 错误

c++ - 内联汇编程序递增 64 位计数器

Xcode 10.0 模拟器无法启动

assembly - MIPS 汇编作业。好像找不到bug