[SPARC] 부동소수점 매개변수 전달

한국어

첨부 파일에 따른.. 제 결과물입니다. ㅜㅜ

시간상 그냥 넣어요.. 최적화 안시켰어요 아직 ㅜ nop 들의 향현.. 과 반복된 라벨들 ㅜㅜ


.section ".data"

N:.word 0

AD

x1:.single 0

x2:.single 0

x3:.single 0

x4:.single 0

s:.single 0

.section ".text"

fmt0: .asciz "input N = "

fmt1: .asciz "input double Value x%d = "

fmt2: .asciz "%d"

fmt3: .asciz "%f"

fmt4: .asciz "fsumdiff == output : %.1f == \n"

fmt5: .asciz "fsumdiffpt == output : %.1f == \n"

.align 4

.global main,scanf,printf

main: save %sp, -192 ,%sp !i, o , l register size

set fmt0,%o0

call printf ! printf( "input N=" )

nop

set fmt2,%o0 ! scanf( "%d" ,&n)

set N,%o1

call scanf

nop

set fmt1,%o0

mov 1 ,%o1

call printf !printf ( " input double Value x1 =" )

nop

set fmt3,%o0 ! scanf ( "%f" ,&x)

set x1,%o1

call scanf

nop

set fmt1,%o0

mov 2 ,%o1

call printf !printf ( " input double Value x2 =" )

nop

set fmt3,%o0 ! scanf ( "%f" ,&x)

set x2,%o1

call scanf

nop

set fmt1,%o0

mov 3 ,%o1

call printf !printf ( " input double Value x3 =" )

nop

set fmt3,%o0 ! scanf ( "%f" ,&x)

set x3,%o1

call scanf

nop

set fmt1,%o0

mov 4 ,%o1

call printf !printf ( " input double Value x4 =" )

nop

set fmt3,%o0 ! scanf ( "%f" ,&x)

set x4,%o1

call scanf

nop

set N,%l0

set x1,%l1

set x2,%l2

set x3,%l3

set x4,%l4

set s,%l5

ld [%l0],%o0

ld [%l1],%o1

ld [%l2],%o2

ld [%l3],%o3

ld [%l4],%o4

ld [%l5],%o5

call fsumdiff

nop

st %o0,[%fp -20 ]

ld [%fp -20 ],%f0

fstod %f0,%f0

std %f0,[%fp -16 ]

ldd [%fp - 16 ],%o4

mov %o4,%o1

set fmt4,%o0

call printf

nop

set N,%l0

ld [%l0],%o0

set x1,%o1

set x2,%o2

set x3,%o3

set x4,%o4

set s,%o5

call fsumdiffpt

nop

st %o0,[%fp -20 ]

ld [%fp -20 ],%f0

fstod %f0,%f0

std %f0,[%fp -16 ]

ldd [%fp - 16 ],%o4

mov %o4,%o1

set fmt5,%o0

call printf

nop

test: ret

restore

fsumdiff: save %sp, -128 ,%sp

st %i0, [%fp -4 ] ! N

ld [%fp -4 ],%l0

st %i1, [%fp -4 ] ! x1

ld [%fp -4 ],%f0

st %i2, [%fp -4 ] ! x2

ld [%fp -4 ],%f1

st %i3, [%fp -4 ] ! x3

ld [%fp -4 ],%f2

st %i4, [%fp -4 ] ! x4

ld [%fp -4 ],%f3

st %i5, [%fp -4 ] ! *s

ld [%fp -4 ],%f4

cmp %l0, 0 ! if N ? 0

ble allminus

cmp %l0, 1

be addFirst

nop

cmp %l0, 2

be addSecond

nop

cmp %l0, 3

be addThird

nop

cmp %l0, 4

ble addFourth

nop

ret

restore

allminus: fsubs %f4,%f0,%f4

fsubs %f4,%f1,%f4

fsubs %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addFirst: fadds %f4,%f0,%f4

fsubs %f4,%f1,%f4

fsubs %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addSecond:fadds %f4,%f0,%f4

fadds %f4,%f1,%f4

fsubs %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addThird: fadds %f4,%f0,%f4

fadds %f4,%f1,%f4

fadds %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addFourth:fadds %f4,%f0,%f4

fadds %f4,%f1,%f4

fadds %f4,%f2,%f4

fadds %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

fsumdiffpt: save %sp, -128 ,%sp

st %i0, [%fp -4 ] ! N

ld [%fp -4 ],%l0

ld [%i1],%f0

ld [%i2],%f1

ld [%i3],%f2

ld [%i4],%f3

ld [%i5],%f4

cmp %l0, 0 ! if N ? 0

ble allminuspt

cmp %l0, 1

be addFirstpt

nop

cmp %l0, 2

be addSecondpt

nop

cmp %l0, 3

be addThirdpt

nop

cmp %l0, 4

ble addFourthpt

nop

ret

restore

allminuspt: fsubs %f4,%f0,%f4

fsubs %f4,%f1,%f4

fsubs %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addFirstpt: fadds %f4,%f0,%f4

fsubs %f4,%f1,%f4

fsubs %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addSecondpt:fadds %f4,%f0,%f4

fadds %f4,%f1,%f4

fsubs %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addThirdpt: fadds %f4,%f0,%f4

fadds %f4,%f1,%f4

fadds %f4,%f2,%f4

fsubs %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore

addFourthpt:fadds %f4,%f0,%f4

fadds %f4,%f1,%f4

fadds %f4,%f2,%f4

fadds %f4,%f3,%f4

st %f4,[%fp -4 ]

ld [%fp -4 ],%i0

ret

restore


AD