Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; multi-segment executable file template.
- data segment
- ; add your data here!
- text db "Y = $"
- pkey db 10,13, "press any key...$"
- a db 2
- b db 6
- c db 19
- x db 1
- o dw 0
- 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, offset text
- mov ah, 9
- int 21h
- ;loop start
- mov cx, 10
- mov bl, c
- sub b, bl ; b -= c
- for_loop:
- cmp x, 6
- jnb xB6
- ;x < 6
- mov ax, 0
- mov dx, 0
- mov al, b
- mov bx, 0
- mov bl, x ; ax = b - c
- idiv bx ; ax = (b - c) / x
- mov bx, ax
- mov ax, 0
- mov al, x ; ax = x
- mul x ; x * x
- add ax, bx ; x * x + (b - c) / x
- jmp end_iterate
- xB6:
- ;x >= 6
- mov al, a ; ax = a
- imul x ; ax *= x
- idiv b ; ax /= b - c
- end_iterate:
- inc x
- ;mov ax, o
- add y, ax ; y += o
- 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