A couple of future assembly addons to manual?
Erik Friesen
Posts: 1,071
I about fell off my chair today when (this will be a duh moment for veteran programmers?) I figured out that the : is special in that its use means a name can be repeated more than once as long as it is in a different sub.
Another nice addition would be a self modifying code demo.
Can someone give me a good explanation of how the movd and mov 0-0 self modifying code actually work?
Another nice addition would be a self modifying code demo.
Can someone give me a good explanation of how the movd and mov 0-0 self modifying code actually work?
Comments
That writes the value 123 into Cog memory location $100.
This will move $1AB into the destination part of the instruction at 'here' creating a 'mov $1AB,#123'. When 'here' is jumped to, 123 will be written to Cog memory location $1AB.
Because the destination register used in the instruction at 'here' is modified it has become a de-facto practice to use 0-0 to show a field ( destination or source ) which will be modified ...
Post Edited (hippy) : 8/12/2008 11:09:54 PM GMT
On the manual, page 348 where the Assembly language elements are described... it says that one of the elements are conditions, and sends you to page 368, where the first statement is that all assembler instructions have the optional field condition and so on. Before anyone tries to learn assembler.. reading the manual is one of the priorities. After all my time with the prop, the simulator and the code written... I miss here and there a detail. The manual is not very clear sometime to show differences with other processors, but no one do that anyways. There is no substitute for a good, careful and complete read to the manual. Any shortcut (like the ones I do) lead to bugs, misunderstandings (like REV recently, read the "rev is driving me crazy" thread for an example, I read the manual but still I thought It worked some other way...), frustration and un-enjoyment. Books do not bite.. well I'm not sure of that, but they produce allergy, well history books anyways
I know the IF_x reference is on the previous page of the manual, but I do believe a reference should be on the JMP page. After all, we are trying to get everyone on board the prop aren't we? If we don't make suggestions to improve the docs, no improvements will ever be done. (same goes for typo's but I can't remember where they were)
That was merely my take on it - to simplify it for others, and an obvious pointer to it.
"Assembly literal: used to indicate an expression or symbol is a literal value rather than a register address"
I know I'm probably wrong but it seems to me it should say,
Assembly literal: used to indicate an expression or symbol is a register address rather than a literal value"
Probably just disgust over the nth time I have forgot the #.
e.g.
JMP #HERE 'stores the address (register if you like) to jump to
JMP HERE 'jumps to the address pointed to at HERE (commonly called an indirect jump)
MOV SOMEWHERE,#HERE 'stores the address (register if you like) as an immediate value
MOV SOMEWHERE,HERE 'stores the data located at the address HERE into a location at the address SOMEWHERE
MOV SOMEWHERE,#0 'stores the immediate value into a location at the address SOMEWHERE
MOV SOMEWHERE,0 'stores the data located at the address HERE into a location at the address SOMEWHERE
Hope this helps.
I would like to see an optional warning generated when the # is missing for a JMP/JMPRET and the CALL allowing to remove the # with an optional warning.
Agreed, though '@' is yet another additional ( and conflicting ) use for the token, so I'd settle for ' jmp *reg' or 'jmp [noparse][[/noparse]reg]'.
It's all well and good saying take care in writing code but when one makes the mistake it's incredibly hard to see the mistake or debug. While 'jmp #reg' makes perfect sense with the Cog architecture, people from other microcontrollers are used to 'jmp label', 'jmp @reg'.