68000 Assembly Language - MOVE instrunction - 68000

What is the difference between MOVE 1234,D5 and MOVE #1234,D5? Ive tried to look online, but cant see to find what the first instruction is doing.

The second moves the value 1234 into D5, the first moves the value at address 1234 into D5. You might want to look into addressing modes (for example, here: http://alanclements.org/68kaddressingmodes3.html).

The '#' represents a CONSTANT as explained here.
On Page 43 it states: A constant as a source operand is specified by preceding it
with the special character #

Related

How to go back to previous when doing find replace confirm in vi?

Frequently when I am doing a find and replace in vi I will do it like this:
:%s/find/replace/gc
This gives you the option to skip by pressing n, or replace by pressing y. But, sometimes I will accidentally skip over one in a large file by pressing n when I meant to press y.
How do I go backwards to the previous one and give me a second change?
Essentially, how to I find (search) the other direction temporarily? thanks.
I'm not sure if you would like to interrupt current find-replace operation and resume it again. But if that is acceptable, here is my suggestion:
Start your find-replace the way you mentioned:
:%s/find/replace/gc
After you accidentally skip over a substitution by pressing n, interrupt the search by pressing <ctrl-C>
Press <shift-N> to go back to the previous occurrence of your find term
Run find-replace a little differently while you are at this word: :.,$s/find/replace/gc
Continue the operation
All this functionality works with vim native capabilities without having to install any addon.
Note: The .,$ range specifier indicates to perform :s (substitute) operation over a range of lines that start with current line (indicated by .) and until last line (indicated by $).
Note2: It might be known to you, but reiterating for anyone else who stumbles upon this post searching for something similar - The % range specifier indicates to perform :s (substitute) operation over all lines of currently active buffer.
This is not answer to the question, but a very good alternative. I recently discovered the CtrlSF plugin and it improves the search /replace process dramatically.
Basically, you have the search results in a buffer and you can do all the replacements in this single buffer.
In your scenario, you first do :CtrlSF find, get a buffer with all the matches in all files and then you do /find and move with n over your targets and change them (of course, you can actually change only the first one and then repeat the replacement with .).
If you miss some target, you just hit N to go back to the previous result and replace it.
Seems like you can't back to previous match using this pattern. Appeared bar propose following commands y/n/a/q/l/^E/^Y but no one of them will return backward to previous match.
But you can use little different pattern described bellow:
Type this /pattern replacing pattern with interested word;
Your cursor is navigated to first occurrence, if you don't need to change it press n it will navigates you to the next occurrence;
Since you understand you need to replace a word, do this by typing cw, this command cuts the forward word and turns you to insertion mode;
Type in desired text on the released place and press ESC to switch back to command mode;
Now again press n until desired occurrence;
Since you realize that you need to change an occurrence, just press on . it will repeat previously mentioned actions;
If you want to go back just use N.

Which Letter takes up the most EM (globally)?

I was reading up on changing placeholder text when I stumbled across this question.
I went back and learnt about placeholders, anyway. And one SO answer said something along the lines of:
Be careful when designing your placeholder text, since anything outside of the control will be cut off.
Putting these two answer together, it made me think (yes, I know, bad thing to do!) -
What is the longest letter in EM in Global (language) terms?
(since we are meant to size letters in EM and all).
The longest in the English Alphabet is 'W' apparently (from linked Question) - so in terms of global languages, what is?
If I had a control such like:
+------------------------+
|123456789101112131415161|
+------------------------+
where the placeholder was 24 numbers long. How can i ensure they all fit?
Since numbers seem to be the same EM width:
11111
22222
33333
44444
55555
66666
77777
88888
99999
How can I ensure that 24 characters, no matter what length/EM width will fit?
I could just go:
+------------------------+
|WWWWWWWWWWWWWWWWWWWWWWWW|
+------------------------+
But what if there is a wider letter used from another language? How can I ensure that the placeholder text can be read? (without resizing the input itself dynamically)? I literally want the minimum width it would have to be to display 24 characters, no more - no matter what language is placed in the field.
Here's an example of an even longer 'letter' than English's W:
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
ŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒŒ
ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ
EDIT
I know how i would test (as above) but not 'contenders' as to which is the widest character in the world?
determine your font (eg. Arial)
determine your font-size (eg. 10px)
determine your font-weight (eg. bold)
determine your character-set (eg. UTF-8)
print a couple of same characters (eg. 24) per row for each character of the character set
devide and conquer
-> remove rows that are obviously shorter than others and refresh the page
-> repeat removal as long as there are more than one rows on the page (for equally long rows just pick any one)
Print each character enclosed by a span and then search for the calculated width for that character (either in your browser's devtools or you can automate this with a simple Javascript script that will check the largest of your characters).

Move over last editing positionS

I want to see complete list of editing positions, not just a last one like '.
Jumps (<c-o> & <c-i>) are not it, since you can edit few times without any jump.
Is something like that possible or plugin should be implemented ?
EDIT
Enter in the blank line some text<esc> then do 0i1<esc> after that $a2<esc> then o<esc>. I want to have a key to return first to 2 then 1. g;/g, do not do that, they see those 2 edits as single one.
SOLUTION
It appears that this works
set fo=
au InsertEnter * set tw=1
au InsertLeave * set tw=78
After that you can use g; / g,
So basically, you want the functionality of the built-in g; / g, commands without the special treatment described at their :help:
When two undo-able changes are in the same line and at a column position less
than 'textwidth' apart only the last one is remembered. This avoids that a
sequence of small changes in a line, for example "xxxxx", adds many positions
to the change list. When 'textwidth' is zero 'wrapmargin' is used. When that
also isn't set a fixed number of 79 is used. Detail: For the computations
bytes are used, not characters, to avoid a speed penalty (this only matters
for multi-byte encodings).
Unfortunately, you only have two options:
Write your own plugin that records the insert positions (e.g. via an :autocmd InsertLeave, but capturing changes from other modes will be harder), and provides mappings to jump to them.
Modify Vim's source code to adapt the mentioned special treatment to what you have in mind.
Edit: try http://lifehacker.com/202093/go-back-in-text-file-time-with-vim-70
it could be what you were looking for
You may want to try:
:ju (show all the "jumps", ie places where you went in the file. Not always places where you edited, though)
If you want to jump directly to the "position n-3" : 3 <c-o> will do that
Another way: g ; to go back and g , to go forward
Another way: You can "mark" positions, and refer to them later
ma mark the current position and labels it "a"
mb mark another position, and labels it "b"
then
'a goes back to position a, 'b goes to position b.
it also works in commands :
:.,'as/^/# / : add "# " in front of the lines from the current one (.) to the one where mark a is ('a)
(etc)
Another way: to quickly jump to the SAME word you are currently over (usefull to jump from function definition to function usage(s): * (until you reach the one you want)
I think what you want is g-. See also :help :undolist. For full details, read
:help undo-tree
:help usr_32.txt
Edit: As the comment pointed out, this is not what the question asked for. I was really thinking of g; and g,, as mentioned by #Olivier Dulac.

:g showing functions and comments below

I'm not sure if this can be accomplished with regex, so here goes and hoping for the best.
If in vim I do,
:g/function
I get a list of all function rows.
Now, I'd like that but with comments (!) below until the first non comment row, so I get something like:
3 function MyFunction()
4 !This is a comment
5 !This is also a comment
23 function MyOtherFunction()
24 !This is a comment
25 !This is also a comment
Something like that possible ?
Yes
:g/^func/.;/^[^!]/-1 print
Update
An explanation was suggested...so here goes... vi(1) is powerful in part because it is a cursor-addressing extension to Ken Thompson's original line-oriented ed(1) editor. (ed(1) and its spinoff ex is still available on Linux after all these years, albeit in clone form like vi itself.) ed and its early-unix siblings were the first programs anywhere to use regular expressions.
Ok, create a file with 26 or so lines, one for each letter of your alphabet and start vi, ed, or ex. (For ed or ex, leave out the : characters.) Try:
:1;/m/p
The general form of a vi command is: addr, addr2 commmand
In my example the command is just p for print. addr1 and addr2 are usually a line number or a regular expression using /re/ to search downward or ?re? to search upward. Try /c/;/g/p which prompts me to explain: the ; causes the editor to switch to the line found by the first address before it evaluates the second address. It doesn't always matter in the default wrapscan mode but if you type :set nows (not in ed) then search patterns won't wrap and the difference between , and ; becomes bigger.
The most important line mode command wasn't used in my example but it should be mentioned here: :s/pattern/replacement/ or :s/pattern/replacement/g. This command can of course take addresses so a typical command is 1,$s/old/new/g The $ identifies the last line. The default address for most commands is the current line but for the global or g command it defaults to 1,$ and has the general form
addr1, addr2 g /pattern/ any_linemode_command
For example, say I'm Jeff but I want to blame Joel for different types of critical errors in the logs. I need to be stealthy and not change the Jeff's on mere warning lines, so I need:
g/critical.*error/s/Jeff/Joel/
That will run the substitute command on every line of the file that has the pattern "critical anything error" and then just change Jeff to Joel.
So now the answer should be fairly clear. The command works as follows: on every line of the file, check to see if the line begins with /^func/ (func at the beginning of the line) and if it does, start with . (the current line) then, resetting the current address to that line (;) search for a line that does NOT begin with !, and if it's found, subtract one from the line number found (back up slightly to the last actual comment) and then just run the print command.

Search for string and get count in vi editor

I want to search for a string and find the number of occurrences in a file using the vi editor.
THE way is
:%s/pattern//gn
You need the n flag. To count words use:
:%s/\i\+/&/gn
and a particular word:
:%s/the/&/gn
See count-items documentation section.
If you simply type in:
%s/pattern/pattern/g
then the status line will give you the number of matches in vi as well.
:%s/string/string/g
will give the answer.
(similar as Gustavo said, but additionally: )
For any previously search, you can do simply:
:%s///gn
A pattern is not needed, because it is already in the search-register (#/).
"%" - do s/ in the whole file
"g" - search global (with multiple hits in one line)
"n" - prevents any replacement of s/ -- nothing is deleted! nothing must be undone!
(see: :help s_flag for more informations)
(This way, it works perfectly with "Search for visually selected text", as described in vim-wikia tip171)
:g/xxxx/d
This will delete all the lines with pattern, and report how many deleted. Undo to get them back after.
Short answer:
:%s/string-to-be-searched//gn
For learning:
There are 3 modes in VI editor as below
: you are entering from Command to Command-line mode. Now, whatever you write after : is on CLI(Command Line Interface)
%s specifies all lines. Specifying the range as % means do substitution in the entire file. Syntax for all occurrences substitution is :%s/old-text/new-text/g
g specifies all occurrences in the line. With the g flag , you can make the whole line to be substituted. If this g flag is not used then only first occurrence in the line only will be substituted.
n specifies to output number of occurrences
//double slash represents omission of replacement text. Because we just want to find.
Once got the number of occurrences, you can Press N Key to see occurrences one-by-one.
For finding and counting in particular range of line number 1 to 10:
:1,10s/hello//gn
Please note, % for whole file is repleaced by , separated line numbers.
For finding and replacing in particular range of line number 1 to 10:
:1,10s/helo/hello/gn
use
:%s/pattern/\0/g
when pattern string is too long and you don't like to type it all again.
I suggest doing:
Search either with * to do a "bounded search" for what's under the cursor, or do a standard /pattern search.
Use :%s///gn to get the number of occurrences. Or you can use :%s///n to get the number of lines with occurrences.
** I really with I could find a plug-in that would giving messaging of "match N of N1 on N2 lines" with every search, but alas.
Note:
Don't be confused by the tricky wording of the output. The former command might give you something like 4 matches on 3 lines where the latter might give you 3 matches on 3 lines. While technically accurate, the latter is misleading and should say '3 lines match'. So, as you can see, there really is never any need to use the latter ('n' only) form. You get the same info, more clearly, and more by using the 'gn' form.

Resources