generic swap method in javascript

D

Dr J R Stockton

In comp.lang.javascript message <timstreater-150A94.10555217062010@news.
individual.net>, Thu, 17 Jun 2010 10:55:52, Tim Streater
Was it not "swap bytes" on an operand in the PDP-11? So you might say:

swab R3 or swab (SP)

for example to swap the bytes in register 3 or the top item on the stack.

Probably, since it is on page 10-13 of my copy of a handbook for the
LSI-11 series.

Did you ever consider 014747, which is MOV -(PC),-(PC) ?
 
E

Evertjan.

Tim Streater wrote on 17 jun 2010 in comp.lang.javascript:
Was it not "swap bytes" on an operand in the PDP-11? So you might say:

swab R3 or swab (SP)

for example to swap the bytes in register 3 or the top item on the stack.

This could be, tim,
as my connection at Philips in that era was a PDP-11 programmer.

If so, it was NOT an 2650 opcode. ;-(

=============

The problem of storng a word highbyte first or lowbyte first was a mayor
headache, so the operand was very useful, methinks.

I think Steve Morse of 8086 fame, now a mayor programmer for Ellis Island
files and Jewish geneology <http://stevemorse.org/>, wrote about that in
one of his books of the late 1970's?

No, not this one: <http://stevemorse.com/>
 
T

Tim Streater

Dr J R Stockton said:
In comp.lang.javascript message <timstreater-150A94.10555217062010@news.
individual.net>, Thu, 17 Jun 2010 10:55:52, Tim Streater


Probably, since it is on page 10-13 of my copy of a handbook for the
LSI-11 series.

Did you ever consider 014747, which is MOV -(PC),-(PC) ?

Doesn't that cause your code to execute backwards, eating itself as it
goes? Or something?
 
A

Andrea Giammarchi

just because nobody wrote any example like this one ...

var
a = 1,
b = 2
;

with ({swap:null}) {
swap = a;
a = b;
b = swap;
}

which can be shortcutted to:

with ({swap:a}) {
a = b;
b = swap;
}

another missed opportunity via one of the most misunderstood operator

Regards,
Andrea Giammarchi
 
D

Dr J R Stockton

In comp.lang.javascript message <timstreater-A97D44.21225919062010@news.
individual.net>, Sat, 19 Jun 2010 21:22:59, Tim Streater
Doesn't that cause your code to execute backwards, eating itself as it
goes? Or something?

IIRC, it only creates, without eating. Each successive instruction
written is freshly written before the previous one. On a PDP-11,
hardware may stop it at address 0400 (?), but on an LSI-11 it may
overwrite the interrupt despatch area ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,077
Messages
2,570,569
Members
47,206
Latest member
MalorieSte

Latest Threads

Top