comparison python/cortexm3.py @ 251:6ed3d3a82a63

Added another c3 example. First import attempt
author Windel Bouwman
date Mon, 29 Jul 2013 20:23:13 +0200
parents 90637d1bbfad
children 04c19282a5aa
comparison
equal deleted inserted replaced
250:f5fba5b554d7 251:6ed3d3a82a63
485 def encode(self): 485 def encode(self):
486 imm11 = wrap_negative(self.offset >> 1, 11) 486 imm11 = wrap_negative(self.offset >> 1, 11)
487 h = (0b11100 << 11) | imm11 # | 1 # 1 to enable thumb mode 487 h = (0b11100 << 11) | imm11 # | 1 # 1 to enable thumb mode
488 return u16(h) 488 return u16(h)
489 489
490 @armtarget.instruction
491 class bl_ins(jumpBase_ins):
492 mnemonic = 'BL'
493 def encode(self):
494 imm32 = wrap_negative(self.offset >> 1, 32)
495 imm11 = imm32 & 0x7FF
496 imm10 = (imm32 >> 11) & 0x3FF
497 j1 = 1 # TODO: what do these mean?
498 j2 = 1
499 s = (imm32 >> 24) & 0x1
500 h1 = (0b11110 << 11) | (s << 10) | imm10
501 h2 = (0b1101 << 12) | (j1 << 13) | (j2 << 11) | imm11
502 return u16(h1) + u16(h2)
503
490 class cond_base_ins(jumpBase_ins): 504 class cond_base_ins(jumpBase_ins):
491 def encode(self): 505 def encode(self):
492 imm8 = wrap_negative(self.offset >> 1, 8) 506 imm8 = wrap_negative(self.offset >> 1, 8)
493 h = (0b1101 << 12) | (self.cond << 8) | imm8 507 h = (0b1101 << 12) | (self.cond << 8) | imm8
494 return u16(h) 508 return u16(h)