⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 div.asm

📁 TMS320C3X 汇编语言程序编译环境
💻 ASM
字号:
* 被除数放到R0中
* 除数防R1中
* OUTPUT: R0/R1 into R0
* REGISTERS USED: R0±R3, IR0, IR1
*
* OPERATION: 1. NORMALIZE DIVISOR WITH DIVIDEND
*            2. REPEAT SUBC
*            3. QUOTIENT IS IN LSBs OF RESULT
*

* PROCESSOR INITIALIZATION FOR THE TMS320C3x

SIGN     .set R2
TEMPF    .set R3
TEMP     .set IR0
COUNT    .set IR1
         .global RESET,INIT,BEGIN
         .globl  DIVI
 
* REGISTER FROM 808000H (CTRL)
	 .data
MASK     .word 0FFFFFFFFH
BLK0     .word 0809800H ; 片内1K×32bit RAM块0起始地址
BLK1     .word 0809C00H ; 片内1K×32bit RAM块1起始地址
STCK     .word 0809F00H ; 堆栈起始地址
CTRL     .word 0808000H ; Pointer for peripheral±bus memory map
DMACTL   .word 0000000H ; Init for DMA control (0)
TIM0CTL  .word 0000000H ; Init of timer 0 control (32)
TIM1CTL  .word 0000000H ; Init of timer 1 control (48)
SERGLOB0 .word 0000000H ; Init of serial 0 glbl control (64)
SERPRTX0 .word 0000000H ; Init of serial 0 xmt port control (66)
SERPRTR0 .word 0000000H ; Init of serial 0 rcv port control (67)
SERTIM0  .word 0000000H ; Init of serial 0 timer control (68)
SERGLOB1 .word 0000000H ; Init of serial 1 glbl control (80)
SERPRTX1 .word 0000000H ; Init of serial 1 xmt port control (82)
SERPRTR1 .word 0000000H ; Init of serial 1 rcv port control (83)
SERTIM1  .word 0000000H ; Init of serial 1 timer control (84)
PARINT   .word 0000000H ; Init of parallel interface control (100)
IOINT    .word 0000000H ; Init of I/O interface control (96)
*
         .sect "initialize"; Named section 
RESET    .word INIT ; RS± load address INIT to PC
         .space 191 ; Reserved space
	 
         .text
* THE STATUS REGISTER HAS THE FOLLOWING ARRANGEMENT:
* BITS:    31–14 13  12 11 10  9    8   7   6  5  4  3 2 1 0
* FUNCTION: RESRV GIE CC CE CF RESRV RM OVM LUF LV UF N Z V C
*

INIT:    LDP 0,DP ; Point the DP register to page 0
         LDI 1800H,ST ; Clear and enable cache, and disable OVM
         LDI @MASK,IE ; Unmask all interrupts
         LDI @BLK0,AR0 ; AR0 points to block 0
         LDI @BLK1,AR1 ; AR1 points to block 1
         LDF 0.0,R0 ; 0 register R0
         RPTS 1023 ; Repeat 1024 times ...
         STF R0,*AR0++(1) ; Zero out location in RAM block 0 and ...
         || STF R0,*AR1++(1) ; Zero out location in RAM block 1
         LDI @CTRL,AR0 ; Load in AR0 the pointer to control registers
	 LDI @DMACTL,R0
	 STI R0,*+AR0(0) ; Init DMA control
	 LDI @TIM0CTL,R0
	 STI R0,*+AR0(32) ; Init timer 0 control
	 LDI @TIM1CTL,R0
	 STI R0,*+AR0(48) ; Init timer 1 control
	 LDI @SERGLOB0,R0
	 STI R0,*+AR0(64) ; Init serial 0 global control
	 LDI @SERPRTX0,R0
	 STI R0,*+AR0(66) ; Init serial 0 xmt control
	 LDI @SERPRTR0,R0
	 STI R0,*+AR0(67) ; Init serial 0 rcv control
	 LDI @SERTIM0,R0
	 STI R0,*+AR0(68) ; Init serial 0 timer control
	 LDI @SERGLOB1,R0
	 STI R0,*+AR0(80) ; Init serial 1 global control
	 LDI @SERPRTX1,R0
	 STI R0,*+AR0(82) ; Init serial 1 xmt control
	 LDI @SERPRTR1,R0
	 STI R0,*+AR0(83) ; Init serial 1 rcv control
	 LDI @SERTIM1,R0
	 STI R0,*+AR0(84) ; Init serial 1 timer control
	 LDI @PARINT,R0
	 STI R0,*+AR0(100) ; Init parallel interface control (C30 only)
	 LDI @IOINT,R0
	 STI R0,*+AR0(96) ; Init I/O interface control
	 LDI @STCK,SP ; Init the stack pointer
	 OR 2000H,ST ; Global interrupt enable

DIVI:   ldi 33,r0
	ldi 5,r1
	XOR R0,R1,SIGN ; Get the sign
	ABSI R0;被除数取正
	ABSI R1;除数取正
	CMPI R0,R1 ; Divisor > dividend ?
	BHID ZERO ; If so, return 0
	FLOAT R0,TEMPF ; Normalize dividend
	PUSHF TEMPF ; PUSH as float
	POP COUNT ; POP as int
        LSH -24,COUNT ; Get dividend exponent
	FLOAT R1,TEMPF ; Normalize divisor
	PUSHF TEMPF ; PUSH as float
	POP TEMP ; POP as int
        LSH -24,TEMP ; Get divisor exponent
	SUBI TEMP,COUNT ; Get difference in exponents
	LSH COUNT,R1 ; Align divisor with dividend
	RPTS COUNT
	SUBC R1,R0

* MASK OFF THE LOWER COUNT+1 BITS OF R0.

	SUBRI 31,COUNT ; Shift count is (32 ± (COUNT+1))
	LSH COUNT,R0 ; Shift left
	NEGI COUNT
	LSH COUNT,R0 ; Shift right to get result
*
* CHECK SIGN AND NEGATE RESULT IF NECESSARY.
*
	NEGI R0,R1 ; Negate result
        ASH -31,SIGN ; Check sign
	LDINZ R1,R0 ; If set, use negative result
	CMPI 0,R0 ; Set status from result
ZERO:	LDI 0,R0
        BR $
	.end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -