初学者裸机pdp11控制台输出

时间:2016-07-15 02:50:48

标签: assembly emulation simulator bare-metal pdp-11

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

在simh上运行。 show dev有

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)才能让某些角色从控制台中出来,我想从那里开始#34;看"什么,然后建立在那。因此,如果我接近但不完全或者如果这不是最好的外围设备,那么它们都在那个较高的地址空间中。

我正在使用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'.

所以语法有点傻/非标准。至少现在已经在binutils中支持pdp11一些版本,希望也能利用它。 simh的二进制文件格式不是很难弄清楚,单步执行它匹配我想要的指令并提供gnu汇编程序。

尝试了apt-got v3.8-1版本的simh pdp11以及github获得的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.

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

EDIT2:

在汇编中,为了满足从tty发送字符的目标,使用gnu汇编语法(*而不是@和$而不是#)

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

1 个答案:

答案 0 :(得分:2)

我认为问题是没有正确使用DL11。你不能随时给它一个角色。你必须测试&#34;准备好&#34;控制寄存器中的标志。然后,当它准备好发送角色。此外,您无法可靠地从数据寄存器中读回值。然后你使用那​​个角色作为记忆指针(那里肯定会有记忆,但写入它可能不是你想要的)。

您可能也有兴趣查看Retrocomputing Stack Exchange网站。我可能不是唯一一个有PDP-11经验的人,但我可能会在这里。