CS 220 Computer Organization - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CS 220 Computer Organization

Description:

depend on condition codes for most control decisions. ZF Zero Flag = 1 if value is ... errmess db You goofed big time!', 0. errmess2 db Oh now you did it! ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 10
Provided by: WRI75
Category:

less

Transcript and Presenter's Notes

Title: CS 220 Computer Organization


1
CS 220Computer Organization
  • Chapter 3 SASM (cont.)

2
CS 220 Computer Organization SASM (cont.)
  • SASM A simple Abstract Language
  • SASM Control Structures
  • conditional and iterative
  • depend on condition codes for most control
    decisions
  • ZF Zero Flag 1 if value is zero
  • SF Sign Flag 1 if value is negative
  • condition codes are set by arithmetic operations
    or the compare instruction
  • Example (conditional)

compareb username, wrightj bez
valid_user moveb mess, invalid user
br end_if valid_user moveb mess,
successful login end_if
If (username .ne. wrightj) then mess
invalid user else mess successful
login end if
Fortran
SASM
3
CS 220 Computer Organization SASM (cont.)
  • SASM A simple Abstract Language
  • SASM Control Structures
  • Example (iterative)

get_username compareb username, wrightj
bez valid_user iadd errorcnt, 1 br
get_username valid_user
do while (username .ne. wrightj) errorcnt
errorcnt 1 end do
Fortran
SASM
4
CS 220 Computer Organization SASM (cont.)
  • SASM A simple Abstract Language
  • Communication
  • Input/Output assume input from keyboard/output
    to screen
  • One Input Instruction
  • get_ch ch
  • Four Output Instructions
  • put_ch ch
  • put_str stringname
  • put_i x
  • put_fp fl

5
CS 220 Computer Organization SASM (cont.)
  • SASM A simple Abstract Language
  • Communication (cont.)
  • String processing
  • strings must be null terminated to use the
    put_str instruction
  • Null terminated means to end in a zero
  • Example
  • errmess db You goofed big time!, 0
  • errmess2 db Oh now you did it!, 0ah, 0
    err mess with newline

6
CS 220 Computer Organization SASM (cont.)
  • Sample Program (Miller, p40)

SASM program to sum the integers 1 through
25 .486 .model flat, stdcall .stack
1000h include sasmacros.inc title sumints
program .data n dd ? number of integers to
sum sum dd ? running sum of integers i dd ? the
integers, loop induction variable str1 db The
sum of the first , 0 str2 db integers is ,
0 newline db 0ah . . .
7
CS 220 Computer Organization SASM (cont.)
  • Sample Program (Miller, p40)

n dd 25 number of integers to sum sum dd 0 runni
ng sum of integers i dd 1 the integers, loop
induction variable str1 db The sum of the first
, 0 str2 db integers is , 0 newline db 0ah .c
ode for_loop compare i, n loop until i exceeds
n bgz done_for iadd sum, i iadd i,
1 br for_loop done_for put_str str1 print out
results put_i n put_str str2 put_i sum put_ch
newline done end
8
CS 220 Computer Organization SASM (cont.)
  • In class lab
  • Get into groups of 2 to 3. Rearrange the desks
    as necessary.
  • Write a SASM program that prints out a sequence
    of n Xs, where n is a positive integer
    initialized in the declarations section of the
    program. (Miller, p42, Problem 14)
  • Write out your solution on a sheet of paper. Use
    the figures and examples from the book to help.
    Appendix B, p315 of your text lists the SASM
    instructions.
  • Turn in whatever you have completed at the end of
    class. Make sure to sign the names of your
    group.
  • These will be graded on your attempt at finding a
    solution, not on the correctness of the solution.

9
CS 220 Computer Organization SASM (cont.)
  • In class lab
  • Prof. Wrights solution to Problem 14,
    chapter 3
  • .486
  • .model flat, stdcall
  • .stack 1000h
  • include sasmacros.inc
  • title line_of_Xs program
  • .data
  • n dd 15
  • i dd 0
  • .code
  • main compare i, n
  • bez did_it for i 0, n-1
  • put_ch X
Write a Comment
User Comments (0)
About PowerShow.com