Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.sys.pdp10 > #9947
| From | jayjwa <jayjwa@atr2.ath.cx.invalid> |
|---|---|
| Newsgroups | alt.sys.pdp10 |
| Subject | Re: Fizz Buzz |
| Date | 2026-07-25 12:00 -0400 |
| Organization | atr2net 2026 |
| Message-ID | <87se579i01.fsf@atr2.ath.cx> (permalink) |
| References | <87wlulwflh.fsf@atr2.ath.cx> <mdd33x9cbvq.fsf@panix5.panix.com> |
Rich Alderson <news@alderson.users.panix.com> writes:
Some of this is personal preference, like the .priou and crlf. I used JSR
so I didn't have to make a stack just for one use. The other stuff I'll
address below.
> TDNE is a hardware instruction.
Noted. It would be easier to see their usage if the accumulators had
names that didn't exactly resemble numbers ( for example: rax, rbx, rcx,
etc) instead of 1, 2, 3, etc. I had misunderstood what that instuction
operated on.
> You don't read manuals very well, do you? I find the following in the
> Monitor Calls Reference manual:
Yes, Chef Ramsay. I did search and find MONRT. (with trailing dot) but
it did not work. I spent 50 minutes yesterday bruteforcing any and all
combos involving. Only EXIT 1, works. Maybe MONRT. isn't in MONSYM or
MACSYM but really it didn't work.
U 000046' 000000000000# monrt
MONRT UNASSIGNED, DEFINED AS IF EXTERNAL
?1 ERROR DETECTED
U 000046' 000000000000# MONRT.
MONRT. UNASSIGNED, DEFINED AS IF EXTERNAL
?1 ERROR DETECTED
U 000046' 000000000000# MONRT
MONRT UNASSIGNED, DEFINED AS IF EXTERNAL
?1 ERROR DETECTED
I also tried EXIT MONRT and EXIT MONRT. , with literals and without.
> Can FLAGS have a value other than 0 or 1? A much better solution in that case
> is to use 0 and -1, and the SETO/SETZ instructions. Here, use
>
> SETOM FLAGS
My orginal design was to set bits for flags if the various tags were
output: one bit for fizz, one for buzz, one for fzbz. Then I realized
it didn't matter what bit was set - only that something was
printed. That condition alone should set the flags. Correction made.
> Well, of course TDNE does not work here. READ THE HARDWARE MANUAL.
>
> The Test Direct instructions compare the contents of the AC to THE CONTENTS OF
> THE EFFECTIVE ADDRESS, not to the immediate value in the instruction, unlike
> all the other Test instructions. What you are saying in TDNE Q3,1 is that the
> processor should bitwise compare the value you've loaded into Q3 WITH THE VALUE
> CURRENTLY IN AC 1. What would have worked is TDNE Q3,[1] with a literal
> containing the value 1.
On TOPS-20, PSOUT% is used for tag output. This requires a pointer in
T1. The logic for checking flags checks that A: is it zero? and B: is it
one? In reality, case "B" is "is it anything other than one"? On
TOPS-20, T1 has stuff in it (the pointer) and was being interpreted as a
flag. TOPS-10 uses OUTSTR, which doesn't involve using T1, so the flags
weren't properly checked. Thus, my code (on TOPS-20) did the right thing
but for the wrong reasons. This is what DDT had to say about the matter.
> But even better is using the -1/0 trick from above, and coding
>
> SKIPN FLAGS
> JRST CHKN.1
Corrected. It's SKIPE, since if flags are zero this means we should
output the number. If flags are one we skip number-outputting code.
> It is preferable always to use JRST rather than JUMPA, because the latter
> invokes the comparison hardware even when the intent is to branch
> unconditionally.
Why would it invoke comparision hardware on ALWAYS? And if you're not
supposed to use it, why provide a JUMPA? I'm going to have to have a
talk with these DEC guys...
> OK, I refuse to believe that this worked, just because you declared that the
> integer 1 was a binary value. Something in AC 1 was ACCIDENTALLY of a
> shape to work.
Yes, the string pointer for PSOUT% on TOPS-20. The TOPS-10 code doesn't
use that printing means and so didn't work.
> It's nice tht you want to teach folks
You have that turned 'round the wrong way. Look at it from the other
direction.
The revised program for TOPS-10:
comment $
Fizz Buzz for PDP-10 TOPS-10
For 1..N, check if each integer is evenly divisible by 3, if so, print
"Fizz". If by 5, print "Buzz". If by both print "FizzBuzz". If neither,
print the bare number.
$
title fizasm
search monsym,macsym
STDAC. ; Labels accums for us
stksz==2 ; Size of stack
size==62 ; Number of terms to see (50)
; Only <= 99 is supported
fizz: asciz /Fizz / ; Tag for N mod 3 == 0
buzz: asciz /Buzz / ; Tag for N mod 5 == 0
fzbz: asciz /FizzBuzz / ; Tag for N mod 15 == 0
crlf: asciz /
/ ; This looks weird (\r\n)
flags: 0 ; 0 = no tag, 1 = tag output
stack: block stksz ; Space for stack
subttl Main
start: move p,[iowd stksz, stack] ; Setup stack + guard
setz cx, ; Zero counter for loop
st.1: addi cx,1 ; Examine next number
chk15: move q1,cx ; Number to examine in Q1
idivi q1,17 ; Div by 15, rem in ac+1
jumpn q2,chk3 ; N mod 15 != 0, don't print
setom flags ; Indicate we've output a tag
outstr fzbz ; T10 has OUTSTR, not PSOUT%
jrst chkn.1 ; to output string to TTY
chk3: move q1,cx ; Re-get number to examine, Q1
idivi q1,3 ; Divide by 3, remainder ac+1
jumpn q2,chk5 ; N mod 3 != 0, don't print
setom flags ; Indicate we've printed a tag
outstr fizz ; Output fizz tag to TTY
chk5: move q1,cx ; Reload number because IDIVI
idivi q1,5 ; in CHK3 blanked it
jumpn q2,chknum ; N mod 5 != 0, don't print
setom flags ; Indicate that we've
outstr buzz ; printed a tag to TTY
jrst chkn.1 ; Printed at least one tag so
; skip printing num itself
chknum: skipe flags ; Did something set flags?
jrst chkn.1 ; Then skip printing num
move q1,cx ; Fetch number to convert
pushj p,numout ; Print bare num
chkn.1: setzm flags ; Reset flags to zero
caige cx,size ; More numbers to check?
jrst st.1 ; Yes (increment above)
outstr crlf ; No, done, tidy output
exit 1, ; MONRT. does NOT work
jrst start ; Restartable program
subttl Number Out Subroutine
; TOPS-10 has no NOUT% like TOPS-20 does, so convert the system number
; by hand to ASCII printing characters for display on the TTY. Only
; supports up to double-digit numbers.
; Input: Number to convert in Q1
; Output: Prints ASCII char(s) equal to the number to the TTY
numout: idivi q1,12 ; Convert to printable char
addi q1,60 ; In first position
caie q1,60 ; Don't print leading zero
outchr q1 ; Print first character
addi q2,60 ; Convert second char
outchr q2 ; And print to TTY
outchr [.CHSPC] ; Emit space character
popj p, ; Return to caller
lit ; Debugger to expand literals
end start ; Assembler is done
.exec fizasm
LINK: Loading
[LNKXCT FIZASM execution]
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fiz
z 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz
41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz
.cont
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fiz
z 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz
41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz
--
PGP Key ID: 781C A3E2 C6ED 70A6 B356 7AF5 B510 542E D460 5CAE
"The Internet should always be the Wild West!"
Back to alt.sys.pdp10 | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fizz Buzz jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-07-23 17:39 -0400
Re: Fizz Buzz Rich Alderson <news@alderson.users.panix.com> - 2026-07-23 23:19 -0400
Re: Fizz Buzz jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-07-25 12:00 -0400
Re: Fizz Buzz Rich Alderson <news@alderson.users.panix.com> - 2026-07-25 18:05 -0400
Re: Fizz Buzz jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-07-26 11:12 -0400
Accumulator naming Rich Alderson <news@alderson.users.panix.com> - 2026-07-29 18:10 -0400
Re: Accumulator naming scott@slp53.sl.home (Scott Lurndal) - 2026-07-30 15:14 +0000
Re: old architectures, was Accumulator naming John Levine <johnl@taugh.com> - 2026-07-30 20:40 +0000
Re: Accumulator naming Rich Alderson <news@alderson.users.panix.com> - 2026-07-30 18:41 -0400
Re: Accumulator naming jayjwa <jayjwa@atr2.ath.cx.invalid> - 2026-07-30 11:24 -0400
Re: Accumulator naming scott@slp53.sl.home (Scott Lurndal) - 2026-07-30 16:03 +0000
Re: Accumulator naming Rich Alderson <news@alderson.users.panix.com> - 2026-07-30 18:56 -0400
Re: Accumulator naming cross@spitfire.i.gajendra.net (Dan Cross) - 2026-07-30 23:48 +0000
Re: Accumulator naming John Levine <johnl@taugh.com> - 2026-07-31 01:31 +0000
Re: Accumulator naming cross@spitfire.i.gajendra.net (Dan Cross) - 2026-07-31 02:52 +0000
Re: Accumulator naming John Levine <johnl@taugh.com> - 2026-07-31 03:36 +0000
Re: Accumulator naming Lars Brinkhoff <lars.spam@nocrew.org> - 2026-07-31 13:40 +0000
Re: Accumulator naming Lars Brinkhoff <lars.spam@nocrew.org> - 2026-07-31 13:35 +0000
the Ten Heavenly Stems (was Re: Accumulator naming) Kragen Javier Sitaker <kragen@canonical.org> - 2026-09-11 16:07 -0300
Re: the Ten Heavenly Stems (was Re: Accumulator naming) Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2026-09-14 01:12 +0800
Re: the Ten Heavenly Stems (was Re: Accumulator naming) Kragen Javier Sitaker <kragen@canonical.org> - 2026-09-14 14:40 -0300
Re: the Ten Heavenly Stems (was Re: Accumulator naming) scott@slp53.sl.home (Scott Lurndal) - 2026-09-14 18:09 +0000
Re: the Ten Heavenly Stems (was Re: Accumulator naming) quadibloc@invalid.com (John Savard) - 2026-10-26 03:00 +0000
Re: Fizz Buzz "Kerr-Mudd, John" <admin@127.0.0.1> - 2026-08-21 13:27 +0100
csiph-web