PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > PIC32 - Bộ điều khiển tín hiệu số 32-bit

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Tìm Kiếm Bài Trong Ngày Ðánh Dấu Ðã Ðọc Vi điều khiển

PIC32 - Bộ điều khiển tín hiệu số 32-bit Microchip công bố sản phẩm vi xử lý 32-bit ngày 06/11/2007

 
 
Ðiều Chỉnh Xếp Bài
Prev Previous Post   Next Post Next
Old 10-02-2008, 03:57 PM   #1
falleaf
PIC Bang chủ
 
falleaf's Avatar
 
Tham gia ngày: May 2005
Bài gửi: 2,631
:
Send a message via Yahoo to falleaf
MIPS và PIC32

Mở ra luồng này để bạn nào thích nghiên cứu cùng với F về ASM thì ta cùng chơi cho vui.

Bộ công cụ mô phỏng cho MIPS 32 có thể download tại đây:
http://courses.missouristate.edu/Ken.../MARS/Mars.jar

Nó là chương trình chạy trên nền Java, cho nên các bạn cần phải cài sẵn java trên máy. Các bạn cũng có thể download tại đây:
http://java.sun.com/javase/downloads/index.jsp

Còn đây là một chương trình viết bằng ASM, các bạn có thể download về và chạy thử
http://courses.missouristate.edu/Ken.../Fibonacci.asm

Code:
# Compute first twelve Fibonacci numbers and put in array, then print
      .data
fibs: .word   0 : 12        # "array" of 12 words to contain fib values
size: .word  12             # size of "array" 
      .text
      la   $t0, fibs        # load address of array
      la   $t5, size        # load address of size variable
      lw   $t5, 0($t5)      # load array size
      li   $t2, 1           # 1 is first and second Fib. number
      add.d $f0, $f2, $f4
      sw   $t2, 0($t0)      # F[0] = 1
      sw   $t2, 4($t0)      # F[1] = F[0] = 1
      addi $t1, $t5, -2     # Counter for loop, will execute (size-2) times
loop: lw   $t3, 0($t0)      # Get value from array F[n] 
      lw   $t4, 4($t0)      # Get value from array F[n+1]
      add  $t2, $t3, $t4    # $t2 = F[n] + F[n+1]
      sw   $t2, 8($t0)      # Store F[n+2] = F[n] + F[n+1] in array
      addi $t0, $t0, 4      # increment address of Fib. number source
      addi $t1, $t1, -1     # decrement loop counter
      bgtz $t1, loop        # repeat if not finished yet.
      la   $a0, fibs        # first argument for print (array)
      add  $a1, $zero, $t5  # second argument for print (size)
      jal  print            # call print routine. 
      li   $v0, 10          # system call for exit
      syscall               # we are out of here.
		
#########  routine to print the numbers on one line. 

      .data
space:.asciiz  " "          # space to insert between numbers
head: .asciiz  "The Fibonacci numbers are:\n"
      .text
print:add  $t0, $zero, $a0  # starting address of array
      add  $t1, $zero, $a1  # initialize loop counter to array size
      la   $a0, head        # load address of print heading
      li   $v0, 4           # specify Print String service
      syscall               # print heading
out:  lw   $a0, 0($t0)      # load fibonacci number for syscall
      li   $v0, 1           # specify Print Integer service
      syscall               # print fibonacci number
      la   $a0, space       # load address of spacer for syscall
      li   $v0, 4           # specify Print String service
      syscall               # output string
      addi $t0, $t0, 4      # increment address
      addi $t1, $t1, -1     # decrement loop counter
      bgtz $t1, out         # repeat if not finished
      jr   $ra              # return
Vậy chúng ta sẽ thử sử dụng chương trình này, viết thử cho PIC32, và thử xem rằng sẽ có những sự khác nhau nào giữa MARS và MPLAB, giữa PIC32 và core MIPS thông thường?

Bản chất PIC32 chỉ là một sự phát triển thiết kế "thông minh" mà Microchip đã vận dụng từ những kinh nghiệm thiết kế và phát triển thị trường của mình.

Chúc vui
falleaf vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn
 

Ðiều Chỉnh
Xếp Bài

Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 06:17 AM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam