From Newsgroup: alt.lang.asm
ch3u3
Lots of comparisons in this one. It still seems backwards.
@exec ch3u3
LINK: Loading
[LNKXCT CH3U3 execution]
Enter a character (A, B to echo, C to quit): A
A
Enter a character (A, B to echo, C to quit): B
B
Enter a character (A, B to echo, C to quit): D
Enter a character (A, B to echo, C to quit): F
Enter a character (A, B to echo, C to quit): C
Program complete
@cont
Enter a character (A, B to echo, C to quit): *
Enter a character (A, B to echo, C to quit): C
Program complete
@
Last night I found that DDT can display with your symbols already
inserted, like this:
@debug ch3u3
LINK: Loading
[LNKDEB DDT execution]
DDT
ch3u3$:
start$b $g
START/ MOVEI ITER,5
gdb seems so friendly and luxurious after using DDT. The text doesn't
warn about dangling newlines (actually \r\n in TOPS-10/20) but your
program will run incorrectly under EXEC but fine under DDT if you don't
handle them. The text for TOPS-10 mentions them and of course C
programmers have been bit by them at some point.
comment $
Chapter 3 user exercise 3
PBIN% a character. PBOUT% the character only if it is A or B.
Place the above in a loop that terminates after the 5th PBIN%
or if the letter C is entered.
$
title ch3u3
search monsym ; Use monitor's symbols
ac1=1 ; Label accumulators
iter=7 ; Iterator for loopage
char: "X" ; User's character
; User prompts and messages
getchr: asciz /Enter a character (A, B to echo, C to quit): /
compl: asciz /Program complete/
start: movei iter,5 ; Init iterator for loops
loop: hrroi ac1,getchr ; Load prompt
psout% ; And print to TTY
pbin% ; Get char to ac1
movem ac1,char ; Save user's char
; Input will be char\r\n, deal with \r\n on input stream. Oddly,
; the text does not tell you this and your program will run fine
; under DDT while debugging but will fail under EXEC.
pbin%
pbin%
; Now look at what character we have
move ac1,char
cain ac1,101 ; Compare to A (0o101)
jrst disp ; It's A
cain ac1,102 ; Compare to B
jrst disp ; It's B
cain ac1,103 ; Compare to C
jrst done ; C - exit loop to done
jumpa pass ; None of these, no output
disp: pbout% ; Display char in ac1
movei ac1,15 ; Load \r
pbout%
movei ac1,12 ; Load \n
pbout% ; End in \r\n
; Check loop condition. Do we restart the process?
pass: subi iter,1 ; Cut 1 from our looper
jumpn iter,loop ; Not zero? repeat loop
done: hrroi ac1,compl ; Signal program complete
psout%
haltf% ; Exit to monitor
jrst start ; Restartable program
end start ; That's it, halt assembler
--
PGP Key ID: 781C A3E2 C6ED 70A6 B356 7AF5 B510 542E D460 5CAE
"The Internet should always be the Wild West!"
--- Synchronet 3.22a-Linux NewsLink 1.2