Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; multi-segment executable file template.
- data segment
- ; add your data here!
- pkey db 10, 13, "press any key...$"
- PosArrayMax db "Max element in positive array: $"
- PosArray db 10, 4, 6, 7, 13, 2, 1, 9, 0, 4, 3
- PosArrayLen dw $-PosArray
- ArrayBiggerThen5 db 10, 13, "Bigger then 5: $"
- ArrayZeroIndex db 10, 13, "Zero index: $"
- Array db 4, -6, 1, -7, 6, 9, -1, 2, 9, 0, -8, 0
- ArrayLen dw $-Array
- ZeroIndex dw -1
- ends
- stack segment
- dw 128 dup(0)
- ends
- code segment
- start:
- ; set segment registers:
- mov ax, data
- mov ds, ax
- mov es, ax
- ; add your code here
- ;---Max element in positive array
- mov cx, PosArrayLen
- lea si, PosArray
- mov bx, 0
- cklPosArray:
- cmp bl, [si]
- ja nextIter
- mov bl, [si]
- nextIter:
- inc si
- loop cklPosArray
- ;Output Max element in positive array
- lea dx, PosArrayMax
- mov ah, 9h
- int 21h
- mov ax, bx
- call OutInt
- ;---Count numbers > 5 & zero index
- mov cx, ArrayLen
- mov si, 0 ;array index
- mov bx, 0 ;count numbers > 5
- cklArray:
- cmp Array[si], 5
- jng toNextCmp
- inc bx
- toNextCmp:
- cmp ZeroIndex, -1
- jne toEndIter
- cmp Array[si], 0
- jne toEndIter
- mov ZeroIndex, si
- inc ZeroIndex
- toEndIter:
- inc si
- loop cklArray
- ;Output Count numbers
- lea dx, ArrayBiggerThen5
- mov ah, 9
- int 21h
- mov ax, bx
- call OutInt
- ;Output Zero index
- lea dx, ArrayZeroIndex
- mov ah, 9
- int 21h
- mov ax, ZeroIndex
- call OutInt
- ;End
- lea dx, pkey
- mov ah, 9
- int 21h ; output string at ds:dx
- ; wait for any key....
- mov ah, 1
- int 21h
- mov ax, 4c00h ; exit to operating system.
- int 21h
- ;Output Int(0 - 99)
- OutInt proc
- aam
- add ax,3030h
- mov dl,ah
- mov dh,al
- mov ah,02
- cmp dl,48 ;is the number starts as 0
- je next
- int 21h
- next:
- mov dl,dh
- int 21h
- ret
- OutInt endp
- ends
- end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment