Beruflich Dokumente
Kultur Dokumente
02 .data
03 prompt: .asciiz "\n How many integer numbers?(5 integers,minimum)"
04 result: .asciiz "The minimum integer is "
05
06 ################## CODE SECTION ##################
07 .text
08 .globl main
09 main:
10 li $v0, 4 # system call code for Print String
11 la $a0, prompt # load address of prompt into $a0
12 syscall # print the prompt message
13
14 li $v0, 5 # system call code for Read Integer
15 syscall # reads the value into $v0
16
17 blez $v0, end # branch to end if $v0 < = 0
18 li $t0, 0 # clear register $t0 to zero
19 loop:
20 add $t0, $t0, $v0 # sum of integers in register $t0
21 addi $v0, $v0, -1 # summing integers in reverse order
22 bnez $v0, loop # branch to loop if $v0 is != zero
23
24 li $v0, 4 # system call code for Print String
25 la $a0, result # load address of message into $a0
26 syscall # print the string
27
li $v0, 1 # system call code for Print
28
Integer
29 move $a0, $t0 # move value to be printed to $a0
30 syscall # print sum of integers
31 b main # branch to main
32 end: li $v0, 4 # system call code for Print String
33 la $a0, # load address of msg. into $a0
34 syscall # print the string
35 li $v0, 10 # terminate program run and
36 syscall # return control to system
The first group which solves the problem by Friday night (by midnight) will get
20 points, the second group 16 points, the third group 12 points, the forth group 8
points, the fifth group 4 points, the sixth and the following groups will get 2
points.
If the solution is submitted on Saturday (by midnight) the above points will be
multiplied by 0.8.
If the solutions are submitted on Sunday (by midnight) the above points will be
multiplied by 0.6.
Each group needs to post its members to moodle page of the course.
.MODEL SMALL
.STACK 32
.DATA
DIZI DB 2,3,1,5
.CODE
ANA PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV CX,3
LEA SI,DIZI
BAS:
MOV AL,[SI]
MOV BL,[SI+1]
CMP AL,BL
JA BUYUK
JNA KUCUK
BUYUK:
MOV CL,AL
INC SI
DEC CX
CMP CX,0
JE BITIR
KUCUK:
INC SI
DEC CX
CMP CX,0
JE BAS
BITIR:
MOV AH,4CH
INT 21H
ANA ENDP
END ANA
data segment
dizi db 3,4,6,7,8,9
enbuyuk db ?
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
mov ax,@data
mov ds,ax
mov es,ax
lea si,dizi
mov bl,[si]
mov cx,5
dongu :
inc si
cmp bl,[si]
ja degis
devam:
loop dongu
jmp son
degis :
mov bl,[si]
jmp devam
son :
mov enbuyuk,bl
mov ax,4c00h
int 21h
ends
end start
en buyuk
data segment
dizi db 3,4,6,7,8,9
enkucuk db ?
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
mov ax,@data
mov ds,ax
mov es,ax
lea si,dizi
mov bl,[si]
mov cx,5
dongu :
inc si
cmp bl,[si]
jb degis
devam:
loop dongu
jmp son
degis :
mov bl,[si]
jmp devam
son :
mov enkucuk,bl
mov ax,4c00h
int 21h
ends
data segment
LIST DB 05H, 31H, 34H, 30H, 38H, 37H
SIZE=$-OFFSET LIST
MINIMUM DB ?
MAXIMUM DB ?
AVARAGE DB ?
ends
stack segment
DW 128 DUP(0)
ends
code segment
MOV DS, AX
MOV ES,AX
MOV CX,SIZE
LEA SI,LIST
MIN:
LEA DI,MINIMUM
MOV AL,[SI]
CMP AL,[SI+1]
ADD SI, 1
LOOP MIN
MAX:
LEA DI,MAXIMUM
MOV AL,[SI]
CMP AL,[SI-1]
ADD SI, 1
LOOP MAX
AVG:
ADD SI, 1
LOOP AVG
DIV BX
MOV AX,4C00H
INT 21H
start endp
ends
end start
ret