Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; multi-segment executable file template.
- data segment
- br dw 43
- kor1 db ?
- kor2 db ?
- pkey db "press any key...$"
- ends
- stack segment
- dw 128 dup(0)
- ends
- code segment
- start:
- ; set segment registers:
- mov ax, data
- mov ds, ax
- mov es, ax
- mov dh, 1
- mov ch, 1
- petlja:
- mov al, dh
- mul ch
- cmp ax, br
- jge racunaj
- jmp uvecaj
- racunaj:
- mov bl, dh
- jmp kraj
- uvecaj:
- add dh, 1
- add ch, 1
- jmp petlja
- kraj:
- mov bh, bl
- mov kor1, bh
- mov dh, bh
- sub dh, 1
- mov kor2, dh
- mov al, bh
- mul bh
- mov bx, ax
- mov al, dh
- mul dh
- mov dx, ax
- sub bx, br
- sub br, dx
- mov dx, br
- cmp bx, dx
- jge veci
- jmp manji
- veci:
- mov dl, kor2
- add dl, 48
- mov ah, 2
- int 21h
- jmp gotovo
- manji:
- mov dl, kor1
- add dl, 48
- mov ah, 2
- int 21h
- gotovo:
- 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