Lecture 9
- Character Strings
- Storage techniques
- 1.1
- Counting – not used
- Count number of characters in a string, one by one until string is fully read
- Counting – not used
- 1.2
- Sentinel - used
- Adds a null character '\0' to the end of the string
- Adds a null character '\0' to the end of the string
- DATA Segment
- A way to put data into main memory
- Open with assembler directive '.data' pus string into main memory
- Msg: .ascii "the sum is: "
- The directive ascii puts the string into memory without null termination
- The directive ascii puts the string into memory without null termination
- CRLF: .asciiz "\n"
- The directive asciiz puts string into memory with null termination
- The directive asciiz puts string into memory with null termination
- System services strings
- Used for input / output
- Very primitive
- Unique to system (not the same on all platforms)
- Spim on unix
- See text appendix A 48 and the lesson nmber two
- Invoked using 'syscall'
- Used for input / output
- Memory access by bytes
- Byte load and save
- Load byte
- Lb ch, 0(aa)
- Aa is he base
- 0 is the offset
- Ch is the absolute address of register to load to
- Lb is 'load byte' to register from main memory
- Actual address = base + offset
- Aa is he base
- String copy
- Sub $sp, $sp, 4
- Sw $s, 0($sp)
- Save the saved register on stack to start
- Sub $sp, $sp, 4
- Void strcopy (char x[], char y[])
- {int i = 0;
- While((x[i] = y[i]) !=0_
- i = i+1
- A way to put data into main memory
No comments:
Post a Comment