首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SPARC装配扫描误差

SPARC装配扫描误差
EN

Stack Overflow用户
提问于 2016-11-27 22:09:43
回答 2查看 125关注 0票数 0

我把我的密码附在这篇文章上了。但是,当我在gdb上运行它时,一旦它扫描了第一个号码和第二个号码,它就会给我一个“程序接收信号SIGSEGV,分段错误”。错误。我希望有任何帮助来纠正这一点。谢谢!

代码语言:javascript
复制
 .align 4
    .section        ".bss"
    input: .skip 4

    .section        ".data"
    format: .asciz "%d"
    string1: .asciz "Enter Number 1:\n"
    string2: .asciz "Enter Number 2:\n"
    string3: .asciz "The sum of %d and %d is %d\n"

    .section        ".text"

    .global main
    main:
    save %sp, -96, %sp

    set string1, %o0
    call printf
    nop
    set format, %o0
    set input, %o1
    call scanf
    nop
    set string2, %o0
    call printf
    nop
    set format, %o0
    set input, %o2
    call scanf
    nop
    add %o1, %o2, %o3
    set string3, %o0
    ld [%o1], %o1
    ld [%o2], %o2
    ld [%o3], %o3
    call printf
    nop
    ret
    restore

    mov 1, %g1
    ta 0
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-11-28 05:26:42

多亏了斯特凡和杰斯特的帮助,我才能解决问题!

代码语言:javascript
复制
! SungJae Kim

好了!b321024!任务5!2016年12月2日

代码语言:javascript
复制
.align 4
.section    ".bss"
input1: .skip 4
input2: .skip 4

.section    ".data"
format: .asciz "%d"
string1: .asciz "Enter Number 1:\n"
string2: .asciz "Enter Number 2:\n"
string3: .asciz "The sum of %d and %d is %d\n"

.section    ".text"

.global main
main:
save %sp, -96, %sp

set string1, %o0
call printf
nop
set format, %o0
set input1, %o1
call scanf
nop
set string2, %o0
call printf
nop
set format, %o0
set input2, %o1
call scanf
nop
set input1, %o1
ld [%o1], %o1
set input2, %o2
ld [%o2], %o2
add %o1, %o2, %o3
set string3, %o0
call printf
nop
ret
restore

mov 1, %g1
ta 0
票数 0
EN

Stack Overflow用户

发布于 2016-11-28 00:36:15

我认为它应该更像这样,但我从未编写过SPARC程序集O:)

代码语言:javascript
复制
.align 4
.section        ".bss"
input1: .skip 4
input2: .skip 4

.section        ".data"
format: .asciz "%d"
string1: .asciz "Enter Number 1:\n"
string2: .asciz "Enter Number 2:\n"
string3: .asciz "The sum of %d and %d is %d\n"

.section        ".text"

.global main
main:
save %sp, -96, %sp

set string1, %o0
call printf

set format, %o0
set input1, %o1
call scanf

set string2, %o0
call printf

set format, %o0
set input2, %o1
call scanf

set input1, %o1
ld [%o1], %o1
set input2, %o2
ld [%o2], %o2
add %o1, %o2, %o3

set string3, %o0
call printf
nop
ret
restore

mov 1, %g1
ta 0
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40834509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档