Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong behavior when assemble instruction beq #4

Open
eeyrw opened this issue Oct 19, 2018 · 0 comments
Open

Wrong behavior when assemble instruction beq #4

eeyrw opened this issue Oct 19, 2018 · 0 comments

Comments

@eeyrw
Copy link

eeyrw commented Oct 19, 2018

I test this asm with the assembler, but it gives wrong result of instruction beq:

.text
loop:
		addi $t1, $t1, 1
		add $t0, $t0, $t1
		addi $t6, $zero, 100
		slt $t5, $t1, $t6
		addi $t6, $zero, 1
		beq  $t5, $t6, loop

It give machine code:

21290001
01094020
200E0064
012E682A
200E0001
11AE0018

I attempted to assemble by other assembler (https://alanhogan.com/asu/assembler.php) which gave result:

00400000: <loop>	; <input:4> loop:
00400000: 21290001	; <input:5> addi $t1, $t1, 1
00400004: 01094020	; <input:6> add $t0, $t0, $t1
00400008: 200e0064	; <input:7> addi $t6, $zero, 100
0040000c: 012e682a	; <input:8> slt $t5, $t1, $t6
00400010: 200e0001	; <input:9> addi $t6, $zero, 1
00400014: 11aefffa	; <input:10> beq $t5, $t6, loop

I checked the last instruction beq and found that the assembler generated incorrect address offset of label loop. In this case, offset should be a negative number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant