编程论坛's Archiver

solerainbow 发表于 2008-7-6 19:17

另一种汇编语言写程序

;*********** WINDLX Ex.3: Factorial                *************
;*********** (c) 1991 G黱ther Raidl                *************
;*********** Modified: 1992 Maziar Khosravipour *************
;--------------------------------------------------------------------------
; Program begin at symbol main
; requires module INPUT
; read a number from stdin and calculate the factorial (type: double)
; the result is written to stdout
;--------------------------------------------------------------------------

                .data
Prompt:         .asciiz         "An integer value >1 : "

PrintfFormat:        .asciiz         "Factorial = %g\n\n"
                .align                2
PrintfPar:        .word                PrintfFormat
PrintfValue:        .space                8


                .text
                .global        main
main:
                ;*** Read value from stdin into R1
                addi                r1,r0,Prompt
                jal                InputUnsigned
               
                ;*** init values
                movi2fp         f10,r1                ;R1 -> D0        D0..Count register
                cvti2d                f0,f10
                addi                r2,r0,1         ;1 -> D2        D2..result
                movi2fp                f11,r2
                cvti2d                f2,f11
                movd                f4,f2                ;1-> D4         D4..Constant 1
               
                ;*** Break loop if D0 = 1
Loop:                led                f0,f4                ;D0<=1 ?
                bfpt                Finish
               
                ;*** Multiplication and next loop
                multd                f2,f2,f0
                subd                f0,f0,f4
                j                Loop

Finish:         ;*** write result to stdout
                sd                PrintfValue,f2
                addi                r14,r0,PrintfPar
                trap                5
                               
                ;*** end
                trap                0       
               
[size=4][b][i]请问有大虾见过这种汇编语言吗,请会的大虾帮忙写个冒泡排序的程序吧,小弟在此先谢过了[/i][/b][/size]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.