According the following link, the size of "Hello" is 6 because of the null at the end (because its asciiz).
But what would be the size of "Hello\n"
8 or 7?
is \n
considered as 1 byte or 2 bytes?
According the following link, the size of "Hello" is 6 because of the null at the end (because its asciiz).
But what would be the size of "Hello\n"
8 or 7?
is \n
considered as 1 byte or 2 bytes?
This code gives you the length of the of arbitrary string.Using MARS-simulator it will gives you the length of 5
for Hello
and 6
for Hello\n
This means that the size of \n
is 1
byte and the size of Hello\n
is 7
byte.
.data
message: .asciiz "Hello\n"
.text
main:
li $t1,0
la $t0,message
loop:
lb $a0,0($t0)
beqz $a0,done
addi $t0,$t0,1
addi $t1,$t1,1
j loop
done:
li $v0,1
add $a0, $0,$t1
syscall
li $v0,10
syscall