Can you explaing this assembly coding?
Francis
Posts: 2
Hi,
I am new to assembly programming. Would anyone be able to help explain the following coding?
what is this particular code mean expecially the' /' in the beginning of global memory address $0C? I found that the manual say it is a division symbol but couldn't find elsewhere for·an example or explaintion. Does it means 1/(context of memory address $0C)?
mov· w,/$0C
Kind regards
Francis
I am new to assembly programming. Would anyone be able to help explain the following coding?
what is this particular code mean expecially the' /' in the beginning of global memory address $0C? I found that the manual say it is a division symbol but couldn't find elsewhere for·an example or explaintion. Does it means 1/(context of memory address $0C)?
mov· w,/$0C
Kind regards
Francis
Comments
It takes the value at file register $0C, inverts all the bits, and then puts the result in the W register. In other words, it loads the value from memory, negates its, and sticks it in W. This info can actually be found in the SX-Key manual in Appendix C under the "mov" command. However, the problem is that in order to find this, you need to read the most convoluted and difficult "operation" notes that any human mind could conceive.
Thanks, PeterM
LOL
Actually you would have to add 1 to the result to get the value "negated".
P.S. Peter is there any way to make the IDE warn about jumps to other code pages unless preceded by a "page" instruction ?
This has bitten me in the butt alot lately because my programs are getting bigger.
Bean.
The command structure you are using, (MOV W,/fr) is also mentioned in the SX-Key Manual, Version 2.0 under:
Appendix C: SX Instruction Set, NOT dest (page 137).
The Operation paragraph briefly explains how MOV W,/fr works.
Dave G
And true, if you want a 'negative' number, you take the 'One's Complement' of the positive number and add one to it.
So, negative $01 is $FE, plus one is $FF. So $FF represents negative one. This works, because if you add one to it, you'll get zero (plus an overflow, but we ignore the overflow here...)
This leaves the open question though:
MOV W, /$0C ; Does this invert "$0C" to "$F3", then put $F3 in the W register?
; Or does it read the 'contents-of' memory *location* $0C, invert *that* value, and put the result in W?
MOV W, /$0C ;W contains the value $01 after executing this instruction
So the second instruction inverts the bits of the value contained·in register $0C
MOV W, /#$0C ;If this were a valid instruction W would contain $F3
but the instruction is MOV W, /fr where fr is a data register. The second operand of the instruction above is a constant which is not the same as a data register. The SX does not provide a move instruction which inverts a constant before placing it in the working register. Though this does does not cause any problems since MOV W, #$F3 does the job for us just as nicely since the inverted value of a constant is calculatable at compile time.
MOV W, /$0C ; W := Inverted contents of location $0C.
The '$0C' is considered a 'data register'. It is the address of a 'register location' (some say RAM) at location $0C. If you wanted the 'literal' value $0C, ie 12, you would say MOV W, #$0C.
Bean,
It's possible to implement this. The problem is that a clever (or diabolical) programmer can easily trip up the warning. For example, you could have code that does a "page" but then jumps to a jump table entry. The jump table could consist of a series of sequential "jmp" instructions. The code would work perfectly, but SASM to generate a bunch of warnings that are actually wrong, thus annoying lots of people. It's problematic at best.
Thanks, PeterM
Cheers
· Francis