Bon sa m'enerve, je comprend tres bien le principe du SMC, mais j'arrive pas a trouver comment l'appliquer...
Si quelqu'un a un (ou plusieurs) exemple (simple?) a donner sa serait sympa...
; Affiche un pixel en mode OR ou XOR ; d0.w=x d1.w=y d2.w=mode a0.l=dest PutPix: lea.l \Instr(pc),a1 tst.w d2 beq.s \ModeXOR move.w #%0000000111110000,(a1) ; bset d0,(a0,d1.w) bra.s \ModeOK: \ModeXOR: move.w #%0000000101110000,(a1) ; bchg d0,(a0,d1.w) \ModeOK: add.w d1,d1 move.w d1,d2 lsl.w #4,d1 sub.w d2,d1 move.w d0,d2 lsr.w #3,d2 add.w d2,d1 not.w d0 \Instr: dc.w 0 dc.w %0001000000000000 ; pour le mode d'adressage indirect indexé avec déplacement rtsJe n'ai pas testé, donc je ne garantis pas le fonctionnement
__gray_int1_handler_hw2: move.w %sr,-(%a7) | save content of status register on stack move.w #0x2700,%sr | disable ALL interrupts (no one should | interrupt us ...) movem.l %d0-%d7/%a0-%a6,-(%a7)
__gray_to_oldint: movem.l (%a7)+,%d0-%d7/%a0-%a6 move.w (%a7)+,%sr | restore content of status register |-------------------------------------------------------------------------- | JUMP to previous installed interrupt handler |-------------------------------------------------------------------------- .word 0x4ef9 | opcode of "JMP address" instruction __gray_old_int1_hw2: .long 0x00000000
; Affiche un pixel en mode OR ou XOR ; d0.w=x d1.w=y d2.w=mode a0.l=dest PutPix: lea.l \Instr(pc),a1 add.w d1,d1 move.w d1,d3 lsl.w #4,d1 sub.w d3,d1 move.w d0,d3 lsr.w #3,d3 add.w d3,d1 not.w d0 tst.w d2 beq.s \ModeXOR bset d0,(a1,d1.w) bra.s \ModeOK: \ModeXOR: bchg d0,(a1,d1.w) \ModeOK: rts
.word 0x4ef9 | opcode of "JMP address" instruction __gray_old_int1_hw2: .long 0x00000000
Remplir_mémoire_avec_symétrique_par_rapport_à_valeur_divisée_par_shift: move.b d0,\patch_moveq+1 subq.w #1,d1 bcs \fin \loop \patch_moveq moveq #0,d0 sub.b (a0),d0 lsr.b d2,d0 move.b d0,(a0)+ dbf d1,\loop \fin rts
clr_buffer moveq.l #0,d0 move.l d0,d1 move.l d1,d2 move.l d2,d3 move.l d3,d4 move.l d4,d5 move.l d5,d6 move.l d6,d7 move.l d7,a1 move.l a1,a2 move.l a2,a3 move.l a3,a4 move.l a4,a5 move.l a5,a6 movem.l d0-d7/a1-a6,(a0) ;56 bytes movem.l d0-d7/a1-a6,56(a0) movem.l d0-d7/a1-a6,112(a0) movem.l d0-d7/a1-a6,168(a0) movem.l d0-d7/a1-a6,224(a0) movem.l d0-d7/a1-a6,280(a0) movem.l d0-d7/a1-a6,336(a0) movem.l d0-d7/a1-a6,392(a0) movem.l d0-d7/a1-a6,448(a0) movem.l d0-d7/a1-a6,504(a0) movem.l d0-d7/a1-a6,560(a0) movem.l d0-d7/a1-a6,616(a0) movem.l d0-d7/a1-a6,672(a0) movem.l d0-d7/a1-a6,728(a0) movem.l d0-d7/a1-a6,784(a0) movem.l d0-d7/a1-a6,840(a0) movem.l d0-d7/a1-a6,896(a0) movem.l d0-d7/a1-a6,952(a0) movem.l d0-d7/a1-a6,1008(a0) movem.l d0-d7/a1-a6,1064(a0) movem.l d0-d7/a1-a6,1120(a0) [...]
; Patche la fonction ; in : d0.w=mode Patch: add.w d0,d0 ; d0=d0*2 (parce qu'une instruction prend 2 octets) lea.l TabModes(pc),a0 adda.w d0,a0 move.w (a0),d0 ; d0 contient l'instruction (oui, les 3 dernières lignes se résument ; à un move.w TabModes(pc,d0.w),d0 mais je détaille) move.w d0,ApplyPatch ; on écrit l'instruction à l'adresse ApplyPatch rts TabModes: bclr.b d0,(a0) bset.b d0,(a0) bchg.b d0,(a0)