1 / 8

Strings in MIPS

Strings in MIPS. Character Data. §2.9 Communicating with People. Byte-encoded character sets ASCII: 128 characters 95 graphic, 33 control Latin-1: 256 characters ASCII, +96 more graphic characters Unicode: 32-bit character set Used in Java, C++ wide characters, …

genica
Télécharger la présentation

Strings in MIPS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Strings in MIPS

  2. Character Data §2.9 Communicating with People • Byte-encoded character sets • ASCII: 128 characters • 95 graphic, 33 control • Latin-1: 256 characters • ASCII, +96 more graphic characters • Unicode: 32-bit character set • Used in Java, C++ wide characters, … • Most of the world’s alphabets, plus symbols • UTF-8, UTF-16: variable-length encodings Chapter 2 — Instructions: Language of the Computer — 2

  3. How NOT to do Strings in MIPS • Should we try to output a string by putting ASCII values into $a0? • This is not correct. • Just as in C, you output a string by passing the MEMORY ADDRESS of the beginning of a sequence of characters (bytes). • Similarly, if you do a syscall 8 (read_string), the contents of the string read in are not in $a0. • How could, say, a 256 byte string fit into a 4 byte quantity?

  4. A look at syscodes

  5. Hello World # This is a simple program to print hello world .data greet: .asciiz "Hello world\n" .text main: li $v0, 4 la $a0, greet syscall # print the string jr $ra # return from main

  6. Another example .data theString: .space 64 .text main: li $v0, 8 la $a0, theString li $a1, 64 syscall li $v0,4 syscall

  7. If you run this program and type this in: Hello!

More Related