Forum Stats

  • 3,722,782 Users
  • 2,244,412 Discussions
  • 7,850,085 Comments

Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

RISC-V assembly help me..plz

I must build caculator + x - /

no(){} no priority

example 2+3x4-4 =

2+3=5

5x4=20

20-4=16

like this caculator

How can i build this caculator ....??



below code I built...


.globl main


.data

msg:.asciz "expression\n"

psg:.asciz "입력된 expression\n"

rsg:.asciz "Answer ="

space:.space 512

str1:.asciz "+"

str2:.asciz "-"

str3:.asciz "*"

str4:.asciz "/"

.text



main:

la a0,msg

li a7,4

ecall


la a0,space

li a1,512

li a7,8


ecall

la a0,psg

li a7,4

ecall

la a0,space

li a7,4

ecall

la t0,space # t0 에 space 의 주소값

la s4,str1 #s4 +

la s5,str2 #s5 -

la s6,str3 # s6 *

la s7,str4 # s7 /

li s8,0 # result 값 저장 

for:

beq t0,s4,plus

beq t0,s5,minus

beq t0,s6,multi

beq t0,s7,divide

add s8,s8,t0


plus:

minus:

multi:

divide:


























la a0,rsg

li a7,4

Sign In or Register to comment.