FORTRAN 77 on PDP-11
Sean 'Captain Napalm' Conner
spc at conman.org
Fri Jul 29 01:24:03 CDT 2005
It was thus said that the Great der Mouse once stated:
>
> > ;assuming A[0] = MSW, and that each "number"
> > ;is 7 bytes long
> ...
> > movw #7,r3
> > clrw r6 ; clear carry over
> > .loop: clrw r4 ; clear tmp registers
> > clrw r5
> > movb (r0)[r3],r4 ; get unsigned byte into signed word
> > movb (r1)[r3],r5
> > mulw r4,r5 ; do signed multiplication
> > addw r6,r5 ; add in previous "carry over"
> > movb r5,(r2)[r3] ; save result
> > rotl -8,r5,r6 ; save "carry over"
> > bitcw #00FF,r6 ; make sure "carry over" is between 0 - 255
> > sobgeq r3,.loop ; loop
>
> * The comment says 7 bytes long; the code actually does 8 (7..0)
You're right---I wanted 8 bytes, but wrote 7.
> * Why not use movzbw instead of clrw-and-movb?
Because I didn't know about it. I never really *did* any VAX assembly
programming, but I do have a book on it, and I really like the instruction
set.
> * It's canonically bicw, not bitcw.
Ah.
> * You need bicw #ff00,r6, not #00ff.
Oh ... it *clears* bits in the destination that are set in the source.
> * movzbw r6,r6 does what your bi[t]cw tries to, and is shorter.
Ah.
> * If you'd store the numbevrs little-endian, the VAX way, instead of
> big-endian, you could do it much more cheaply with emul - especially
> if you do use a multiple of 4 bytes.
Well, I was trying to show how to do it if the MUL instruction was only
signed in nature and you wanted to do an unsigned multiply of multi-byte
values (remember, the target is a PDP-11).
> > Get's around the fact that the MUL instruction is signed only, even
> > though the longer number is unsigned.
>
> Provided you have integer overflow traps turned off, the difference
> doesn't matter; the only difference between signed and unsigned
> multiply is what constitutes arithmetic overflow.
Um ... no ... you're right. I think.
[ rest snipped ]
-spc (Is it obvious I never programmed assembly on a VAX? 8-/
More information about the cctalk
mailing list