HW4.asm - .data inBuf.space TOKEN.space TokArray.space Tokspace.word 8 prompt.asciiz P.space new_line.asciiz\\n 80 80 80\"Enter an input string

HW4.asm - .data inBuf.space TOKEN.space TokArray.space...

This preview shows page 1 - 3 out of 6 pages.

.data inBuf: .space 80 TOKEN: .space 80 TokArray: .space 80 Tokspace: .word 8 prompt: .asciiz "Enter an input string:" P: .space 80 new_line: .asciiz "\n" .text .globl main main: rept: jal getline # get an input line li $t0, 0 li $t4, 0 #use for storing curChar into TOKEN li $t5, 0 #use for storing TOKEN into TokArray li $t8, 35 #use for checking '#' ######## la $s1, Q0 #$s1 is the state Q0 CUR li $s0, 1 #$s0 is the T chartype nextState: li $t9, 0 lw $s2, 0($s1) jalr $v1, $s2 # pass control sll $s0, $s0, 2 # Multiply by 4 for word boundary add $s1, $s1, $s0 sra $s0, $s0, 2 lw $s1, 0($s1) #$s1 is Q1 b nextState ######## ACT1: lb $a0, inBuf($t0) #curChar = Get next char jal bin_search #search for type add $s0, $a3, 0 #T = ChType(curChar) addi $t0, $t0, 1 jr $v1 ACT2: sb $a0, TOKEN($t4) #TOKEN = curChar lw $t7, Tokspace add $t7, $t7, -1 #$t7 is tokspace 7 addi $t4, $t4, 1 jr $v1 ACT3: sb $a0, TOKEN($t4) #TOKEN = TOKEN + curChar add $t4, $t4, 1 add $t7, $t7, -1 #Tokspace = Tokspace -1 jr $v1 ACT4: li $s3, 0 #iterator for clearing TOKEN li $s7, 80 #the size of inbuf and TOKEN lb $a0, TOKEN($t9) beq $a0, 0, done1 #if the input is finished goto done1 sb $a0, TokArray($t5)
add

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture