divide - divide.asm Description 16 and 32 bit unsigned...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
; divide.asm ; Description: ; 16 and 32 bit unsigned divide routines using the SUBCU instruction ; ; DIVIDE32 = 32 bit divide routine ; Call routine with: XAR0 = Numerator ; XAR1 = Denominator ; Returns: XAR2 = Remainder ; XAR3 = Quotient ; ; DIVIDE = Call routine with: AR0 = Numerator ; AR1 = Denominator ; Returns: AR2 = Remainder ; AR3 = Quotient ;******************************************************************************* ; Begin Program: .global _c_int00 WDCR .set 0x7029 ; Watchdog Control Register .text _c_int00: EALLOW ; Allow writes to GPIO regs (and others) SETC objmode ; Allows 32 bit operations MOV AR0, #WDCR ; Disable watchdog timer MOV AR1, #0x68 ; MOV *AR0, AR1 ; MOV SP, #0x0400 ; Initialize Stack Pointer MAINLOOP: ; 32 bit divide: 1,000,000/503 = 1988 (0x7C4) r.36 (0x24) MOVL XAR0, #1000000 ; Numerator32 = 1,000,000 (0xF4240) MOVL XAR1, #503 ; Den32 = 503 (0x1F4) LC DIVIDE32 MOVL XAR4, XAR2 ; save 32bit remainder (0x24) in XAR4 MOVL XAR5, XAR3 ; save 32bit quotient (0x7C4) in XAR5
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

divide - divide.asm Description 16 and 32 bit unsigned...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online