0
   **ORG $400400
NUM1 DC.B $F0
NUM2 DC.B $80
SUM     DS.B 1
    ORG $400410
ADNUMS MOVE.B NUM1,D0
       MOVE.B NUM2,D1 
       ADD.B D0,D1 
       MOVE.B D0,SUM              
    END $400410
    END    START** 

I have this program ,and because the add does leave a bit on the X (on the ccr) and i want to let the program read it to through the add, how can i use correctly addx ?

Or can i just add a line like "ADD.B#$1,SUM"? Thanks in advance!

  • I assume you want to get a 16 bit result, in which case you will need 2 bytes for the result obviously. Also you don't want to just unconditionally add `1` since you might not have a carry. So yeah `ADDX` would be good for that but you need to add zero to zero. – Jester Nov 14 '19 at 17:38
  • The MC68k is capable of 8-, 16-, and 32-bit arithmetic. To take advantage of it you would enlarge the 8-bit input values in the register, either sign extending (e.g. `ext.b`) or zero extending to 16 or 32 bits. Then use a 16-bit or 32-bit add (e.g. `add.w`) instruction, and you won't need to look at the carry. – Erik Eidt Nov 14 '19 at 17:42
  • Hello @Jester , thanks for the reply. Do you mean "ADDX.B D0,D0"? I feel kinda confused on how you stated it. In my program i just used "ADDX.B D0,D1" – AlexandrosChanas Nov 14 '19 at 17:43
  • Hello @ErikEidt thanks for the reply!. I used "ADD.W D0,D1" and i get a diffrent result now that before also the carry is 0 now. – AlexandrosChanas Nov 14 '19 at 17:47
  • Ok, but you shouldn't merely `move.b` and then `add.w` -- In between the `move.b` and the `add.w` you need to upgrade the values from 8-bits to 16-bits. Hence, suggestion to use `ext.b d0`, which will sign extend from `d0.b` to `d0.w`, you would do this for both `d0` and `d1` then the `add.w` will be good to go. (Sign extend vs. zero extend is up to you and how you think of your data types for the memory locations `num1` and `num2`.) Of course, the result after the `add.w` is in `d1.w`, i.e. a 16-bit answer. – Erik Eidt Nov 14 '19 at 17:49

0 Answers0