Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.sys.pdp10 > #9948
| From | Rich Alderson <news@alderson.users.panix.com> |
|---|---|
| Newsgroups | alt.sys.pdp10 |
| Subject | Re: Fizz Buzz |
| Date | 2026-07-25 18:05 -0400 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <mddzeze67yk.fsf@panix5.panix.com> (permalink) |
| References | <87wlulwflh.fsf@atr2.ath.cx> <mdd33x9cbvq.fsf@panix5.panix.com> <87se579i01.fsf@atr2.ath.cx> |
jayjwa <jayjwa@atr2.ath.cx.invalid> writes:
> 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.
Read more carefully.
>> 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.
MONSYM.UNV is a TOPS-20 file. It does not contain Tops-10 monitor calls.
Some of the Tops-10 monitor calls, BUT NOT ALL, are predefined in DEC versions
of Macro-10. In order to get all of them you have to search UUOSYM. That's
specified in the Tops-10 Monitor Calls Reference Manual.
Remember that Tops-10 and TOPS-20 are entirely separate operating systems WHICH
SHARE NO CODE WHATSOEVER. You wouldn't complain about a Windows program that
didn't understand a Linux system call, would you?
> U 000046' 000000000000# monrt
> MONRT UNASSIGNED, DEFINED AS IF EXTERNAL
[ snip ]
>> 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.
Yup!
>> 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.
But you got the point.
>> 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...
Because the JUMPx instructions are TEST instructions, just like the SKIPx
instructions.
>> 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 fact that you are posting to alt.lang.asm leads to the conclusion that you
are doing that. You should have included that newsgroup on your response to
my Phillipic so that your readers there could see the results.
> 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
s/mon/uuo/
and I'm not sure whether MACSYM.UNV is also on Tops-10, but it probably is.
> 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
--
Rich Alderson news@alderson.users.panix.com
Audendum est, et veritas investiganda; quam etiamsi non assequamur,
omnino tamen proprius, quam nunc sumus, ad eam perveniemus.
--Galen
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