Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bc.s compile error #84

Open
teverett opened this issue Oct 18, 2019 · 4 comments
Open

bc.s compile error #84

teverett opened this issue Oct 18, 2019 · 4 comments

Comments

@teverett
Copy link
Collaborator

kato:pdp7-unix tom$ tools/as7 src/cmd/bc/bc.s
I
II
src/cmd/bc/bc.s
src/cmd/bc/bc.s:3: start not defined
src/cmd/bc/bc.s:9: fetch not defined
src/cmd/bc/bc.s:17: pc not defined
src/cmd/bc/bc.s:19: pc not defined
src/cmd/bc/bc.s:23: sp not defined
src/cmd/bc/bc.s:35: sp not defined
src/cmd/bc/bc.s:36: t1 not defined
src/cmd/bc/bc.s:37: t1 not defined
src/cmd/bc/bc.s:45: d1 not defined
src/cmd/bc/bc.s:53: d4 not defined
src/cmd/bc/bc.s:59: stop not defined
src/cmd/bc/bc.s:63: pc not defined
src/cmd/bc/bc.s:70: putc not defined
src/cmd/bc/bc.s:76: putc not defined
src/cmd/bc/bc.s:78: putc not defined
src/cmd/bc/bc.s:87: putc not defined
src/cmd/bc/bc.s:92: putc not defined
src/cmd/bc/bc.s:93: flush not defined
src/cmd/bc/bc.s:100: dp not defined
src/cmd/bc/bc.s:104: pc not defined
src/cmd/bc/bc.s:106: sp not defined
src/cmd/bc/bc.s:108: lastv not defined
src/cmd/bc/bc.s:111: B not defined
src/cmd/bc/bc.s:112: pbs not defined
src/cmd/bc/bc.s:120: dp not defined
src/cmd/bc/bc.s:121: t1 not defined
src/cmd/bc/bc.s:122: t2 not defined
src/cmd/bc/bc.s:124: t1 not defined
src/cmd/bc/bc.s:129: t2 not defined
src/cmd/bc/bc.s:131: t2 not defined
src/cmd/bc/bc.s:132: t1 not defined
src/cmd/bc/bc.s:133: d1 not defined
src/cmd/bc/bc.s:134: t3 not defined
src/cmd/bc/bc.s:135: t3 not defined
src/cmd/bc/bc.s:137: t1 not defined
src/cmd/bc/bc.s:138: t1 not defined
src/cmd/bc/bc.s:142: t2 not defined
src/cmd/bc/bc.s:163: lastv not defined
src/cmd/bc/bc.s:164: lastv not defined
src/cmd/bc/bc.s:174: pbs not defined
src/cmd/bc/bc.s:179: pc not defined
src/cmd/bc/bc.s:183: t1 not defined
src/cmd/bc/bc.s:184: t1 not defined
src/cmd/bc/bc.s:195: t1 not defined
src/cmd/bc/bc.s:196: lastv not defined
src/cmd/bc/bc.s:197: lastv not defined
src/cmd/bc/bc.s:199: dm1 not defined
src/cmd/bc/bc.s:202: dsm not defined
src/cmd/bc/bc.s:203: t1 not defined
src/cmd/bc/bc.s:213: n not defined
src/cmd/bc/bc.s:214: b not defined
src/cmd/bc/bc.s:234: flush not defined
src/cmd/bc/bc.s:235: d1 not defined
src/cmd/bc/bc.s:237: stop not defined
src/cmd/bc/bc.s:239: flush not defined
src/cmd/bc/bc.s:240: d1 not defined
src/cmd/bc/bc.s:242: stop not defined
src/cmd/bc/bc.s:244: flush not defined
src/cmd/bc/bc.s:245: d1 not defined
src/cmd/bc/bc.s:247: stop not defined
src/cmd/bc/bc.s:278: ecla not defined
src/cmd/bc/bc.s:280: putc not defined

@rswier
Copy link
Collaborator

rswier commented Oct 18, 2019 via email

@johnnystarr
Copy link

I have seen examples of BC being used on YouTube. I would love to figure out how to compile this as well. Writing B code is possibly the only reason to really play around with Unix v0 IMO. It seems that the folks at the LivingComputer Museum figured this out.

@mhjacobson
Copy link

bc.s allows you to link a B program with extra tracing. By default, the tracing is controlled by the accumulator switches. By modifying bc.s like so, you can enable the various tracing modes in source:

diff --git a/src/cmd/bc.s b/src/cmd/bc.s
index 4d1ed6a..3738119 100644
--- a/src/cmd/bc.s
+++ b/src/cmd/bc.s
@@ -1,6 +1,12 @@
 "** 06-5-12.pdf page 7
 " bc
 
+" bit 0: dtrace
+" bit 1: ddisp
+" bit 2: histog
+" bit 3: stop
+trmode = 001
+
    jmp start
 rinit:
    jms initio
@@ -11,7 +17,7 @@ initio: 0
    jmp rinit
    jms inter
 inter: 0
-   las
+   law trmode  " load trace mode (was: las)
    and o17
    sza
    jms trace
@@ -46,15 +52,15 @@ trace: 0
    and d1
    sza
    jms dtrace
-   las
+   law trmode  " load trace mode (was: las)
    and d2
    sza
    jms ddisp
-   las
+   law trmode  " load trace mode (was: las)
    and d4
    sza
    jms histog
-   las
+   law trmode  " load trace mode (was: las)
    and d8
    sza
    jmp stop

You can then assemble a B program with it:

$ tools/as7 src/cmd/bc.s src/cmd/bl.s src/cmd/bi.s src/other/hello.s 
I
II
src/cmd/bc.s
src/cmd/bc.s:8: Warning: Global label initio multiply defined
src/cmd/bc.s:220: Warning: Global label d8 multiply defined
src/cmd/bl.s
src/cmd/bl.s:144: Warning: Global label initio multiply defined
src/cmd/bl.s:198: Warning: Global label d8 multiply defined
src/cmd/bi.s
src/other/hello.s

The "multiply defined" warnings can be safely ignored. Running the resultant assembled program with "dtrace" mode on spits out a line for every B interpreter opcode, like this:

1510 s 0002
1511 x 0625
1512 n 0002
1513 n 0005 110145
1515 n 0003
0626 s 0002
0627 n 0010
He<snip>

The fields are: address, opcode, arguments.

The other modes are less interesting. ddisp needs capt and sysloc syscalls that aren't emulated by as7. histog counts each opcode, but the histogram is never displayed. stop exits the program after the first operation.

@philbudne
Copy link
Collaborator

philbudne commented Aug 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants