Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----------------------Задание 1
- ; multi-segment executable file template.
- data segment
- ; add your data here!
- bordersText db "Input a & b: $"
- inputNumbersText db 10,13, "Input numbers: $"
- countGoodNumbers db 10,13, "Count good numbers: $"
- pkey db 10,13, "press any key...$"
- a db ?
- b db ?
- count dw 0
- 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
- mov dx, offset bordersText
- mov ah, 9
- int 21h
- mov ah, 1
- int 21h
- mov a, al
- mov ah, 1
- int 21h
- mov b, al
- mov dx, offset inputNumbersText
- mov ah, 9
- int 21h
- ;loop start
- mov cx, 10
- for_loop:
- ;input number
- mov ah, 1
- int 21h
- cmp al, a
- jb end_iterate
- cmp al, b
- ja end_iterate
- inc count
- end_iterate:
- loop for_loop
- ;loop end
- lea dx, countGoodNumbers
- mov ah, 9
- int 21h
- mov ax, count
- OutInt proc ; output number 0 - 99
- 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
- OutInt endp
- 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
- ends
- end start ; set entry point and stop the assembler.
- //-----------------------Задание 2
- ; multi-segment executable file template.
- data segment
- ; add your data here!
- pkey db 10,13,"press any key...$"
- a dw 2
- b dw 6
- c dw 19
- y dw 0
- 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
- mov dx, c
- sub b, dx ; b = b - c
- ;loop start
- mov cx, 10 ; x = 10
- for_loop:
- cmp cx, 6
- jnb xB6
- ;x < 6:
- ;ax = (b - c) / x
- mov ax, b
- mov bx, cx
- idiv cl
- mov bx, ax
- ;ax = x * x
- mov ax, cx
- mul ax
- ;ax = (x * x) + ((b - c) / x)
- add ax, bx
- jmp end_iterate
- xB6:
- ;x >= 6:
- ;ax = x * a
- mov ax, a
- mul cl
- ;ax = (x * a) / (b - c)
- mov bx, b
- idiv bl
- end_iterate:
- add y, ax
- loop for_loop
- ;loop end
- mov ax, y
- OutInt proc ;output number 0 - 99
- 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
- OutInt endp
- 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
- ends
- end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment