1 / 9

More on Assembly

More on Assembly. CS 210 Tutorial 5 Assignment preparation. Difference between ldiq and ldq. Ldiq is for loading immediate value into register Ldiq $t0, 0x8000; Ldq is for reading memory in specific location For example: Memory has values 0x8000 : 0x1111111111111111

claus
Download Presentation

More on Assembly

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. More on Assembly CS 210 Tutorial 5 Assignment preparation

  2. Difference between ldiq and ldq • Ldiq is for loading immediate value into register • Ldiq $t0, 0x8000; • Ldq is for reading memory in specific location • For example: Memory has values • 0x8000 : 0x1111111111111111 • 0x8004 : 0x2222222222222222 • Ldq $t1, ($t0); value in $t1 is 0x1111111111111111 • Ldq $t1, 8($t0); value in $t1 is 0x2222222222222222

  3. getChar • Take char value from keyboard to $v0

  4. PutChar • Take char from $a1 put to screen

  5. Printout example • block main uses proc, CALLSYS { • data { • align; • buffer: • asciiz “tide"; • } data • code { • public enter: • ldiq $s0, buffer; • { • while: • ldbu $a1, ($s0); • beq $a1, end; • do: • ldiq $a0, CALLSYS_PUTCHAR; • call_pal CALL_PAL_CALLSYS; • addq $s0, 1; • br while; • end: • } • clr $a0; • bsr Sys.exit.enter; • } code • } block main

  6. Exercise – checking blocks

  7. Result – checking blocks

  8. Read keys and store in memory • code { • public enter: • ldiq $t6, 0x01ffe184;//for example using hardcode • { • loop: • ldiq $a0, CALLSYS_GETCHAR; • call_pal CALL_PAL_CALLSYS; • //blt $v0, end; • mov $v0, $a1; • mov $v0, $t5; • stb $t5, ($t6); • addq $t6, 1; • ldiq $a0, CALLSYS_PUTCHAR; • call_pal CALL_PAL_CALLSYS; • br loop; • end: • } • { • clr $a1; • ldiq $a0, CALLSYS_EXIT; • call_pal CALL_PAL_CALLSYS; • } • } code

  9. Reverse example • Check the code and try to understand it. • Match them together to finish assignment.

More Related