Hello Ross,
 
For assembly programming, the code will often be easier to follow if constants are represented by a label, as a result of using an equate directive.  The following code snippet extends the process described by Peg, when a label is used.
 
IMM_VAL  equ  8192  ; Could be binary, decimal or hex representation
 
 
    lda  RAMvar+1
    sub  #(IMM_VAL%256)  ; Low byte value
    sta  RESULT+1
    lda  RAMvar
    sbc  #(IMM_VAL/256)  ; High byte value
    sta  RESULT
 
This method should work with most assemblers.  Some assemblers have directives to select the low byte or high byte of a word value, and these could alternatively be used.
 
Regards,
Mac
 
Message Edited by bigmac on 
2007-12-03 01:23 AM