0% found this document useful (0 votes)
55 views4 pages

Strange Document

The document contains assembly code that finds the minimum element in a 4x4 matrix, the row that minimum element is in, and the sum of that row. It stores these values, displays messages with the results, and exits the program. It defines variables for the matrix, results, messages, and includes subroutines to find the minimum, sum the row, and output values on the screen.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views4 pages

Strange Document

The document contains assembly code that finds the minimum element in a 4x4 matrix, the row that minimum element is in, and the sum of that row. It stores these values, displays messages with the results, and exits the program. It defines variables for the matrix, results, messages, and includes subroutines to find the minimum, sum the row, and output values on the screen.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

.

model tiny
.code
org 100h
start:
jmp main
N dw 4
Matrix dw 12, 88, 64, 52
dw 52, 7, 14, 98
dw 78, 16, 17, 91
dw 10, 87, 62, 63
Sum dw ?
RowMin dw ?
Min dw ?
MsgMin db 'Min: ', '$'
MsgRow db 'In Row (form 0 based): ', '$'
MsgSum db 'Summa: ', '$'
CrLf db 0Dh, 0Ah, '$'
main:
;min elem in str
mov ax, [N]
mov cx, 2
mul cx
mov dx, ax ;dx - dlina str of matrix
lea bx, [Matrix]
mov ax, [bx] ;Min:=Matrix[0,0] => ax is Min
mov di, 0 ;RowMin:=0
mov [RowMin], di
mov cx, [N]
@@ForI:
mov si, 0
push cx
mov cx, [N]
@@ForJ:
cmp ax, [bx+si]
jle @@NextJ
mov [RowMin], di
mov ax, [bx+si]
@@NextJ:
add si, 2 ; j:=j+1
loop @@ForJ
pop cx
add bx, dx ;i:=i+1
inc di
loop @@ForI
;save results
mov [Min], ax
;sum elems of str with min elem
lea bx, [Matrix]
mov ax, [RowMin] ;adr str = num
mul dx ;umnozh na razm stroki

mov si, ax
mov ax, 0 ;Sum:=0
mov cx, [N]
@@ForSum:
add ax, [bx+si]
add si, 2
loop @@ForSum
mov [Sum], ax
;show results
mov ah, 09h
lea dx, [MsgMin]
int 21h
mov ax, [Min]
call Show_AX
mov ah, 09h
lea dx, [CrLf]
int 21h

mov ah, 09h


lea dx, [MsgRow]
int 21h
mov ax, RowMin
call Show_AX
mov ah, 09h
lea dx, [CrLf]
int 21h

mov ah, 09h


lea dx, [MsgSum]
int 21h
mov ax, [Sum]
call Show_AX
mov ah, 09h
lea dx, [CrLf]
int 21h
;end of programm
int 20h
; show znak 16-raz digit from register AX on screen
; Entered dannie:
; ax - chislo dlia otobr
Show_AX proc
push ax
push bx
push cx
push dx
push di

mov cx, 10
xor di, di ; di - cifr in str

; if menshe 0 ? ax to
;1) napechatat '-'
;2) else ax poloshit
or ax, ax
jns @@Conv
push ax
mov dx, '-'
mov ah, 2 ; ah - func vivoda on screen
int 21h
pop ax

neg ax

@@Conv:
xor dx, dx
div cx ; dl = num mod 10
add dl, '0' ; perevod in symbols format
inc di
push dx ; sum in stack
or ax, ax
jnz @@Conv
; from stack on screen
@@Show:
pop dx ; dl = vivodimii symbol
mov ah, 2 ; ah - func vivoda on screen
int 21h
dec di ; do then di<>0
jnz @@Show

pop di
pop dx
pop cx
pop bx
pop ax
ret
Show_AX endp

end start

You might also like