Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- ; МАКСРОСЫ ИЗ МЕТОДИЧКИ
- ;------------------------------макрос ввода значений
- mReadAX MACRO buf, sz
- local input, startOfConvert, endofConvert
- push bx
- push cx
- push dx
- input:
- mov [buf], sz
- mov dx, offset [buf]
- mov ah, 0ah
- int 21h
- mov ah, 02h
- mov dl, 0Dh
- int 21h
- mov ah, 02h
- mov dl, 0Ah
- int 21h
- xor ah, ah
- cmp ah, [buf][1]
- jz input
- xor cx, cx
- mov cl, [buf][1]
- xor ax, ax
- xor bx, bx
- xor dx, dx
- mov bx, offset [buf][2]
- cmp [buf][2], "-"
- jne startOfConvert
- inc bx
- dec cl
- startOfConvert:
- mov dx, 10
- mul dx
- cmp ax, 8000h
- jae input
- mov dl, [bx]
- sub dl, "0"
- add ax, dx
- cmp ax, 8000h
- jae input
- inc bx
- loop startOfConvert
- cmp [buf][2], "-"
- jne endofConvert
- neg ax
- endofConvert:
- pop dx
- pop cx
- pop bx
- endm mReadAX
- ;------------------------------макрос вывода сообщений на экран
- Print MACRO str
- push ax
- push dx
- mov ah, 09h
- mov dx, offset str
- int 21h
- pop dx
- pop ax
- ENDM Print
- ;------------------------------макрос вывода результата
- mWriteAx macro
- local convert, write
- push ax
- push bx
- push cx
- push dx
- push di
- mov cx, 10
- xor di, di
- or ax, ax
- jns convert
- push ax
- mov dx, "-"
- mov ah, 02h
- int 21h
- pop ax
- neg ax
- convert:
- xor dx, dx
- div cx
- add dl, "0"
- inc di
- push dx
- or ax, ax
- jnz convert
- write:
- pop dx
- mov ah, 02h
- int 21h
- dec di
- jnz write
- pop di
- pop dx
- pop cx
- pop bx
- pop ax
- endm mWriteAx
- .data
- a db ?
- b db ?
- x db ?
- text_in_a db "Input a $"
- text_in_b db "Input b $"
- text_in_x db "Input x $"
- text_res db "Result $"
- endl db 13,10,"$"
- buf db 10 dup(?)
- .code
- start:
- mov ax, @data
- mov ds, ax
- Print text_in_a
- mReadAX buf, 5
- mov a, al
- Print text_in_b
- mReadAX buf, 5
- mov b, al
- Print text_in_x
- mReadAX buf, 5
- mov x, al
- xor ax, ax
- xor bx, bx
- xor cx, cx
- xor dx, dx
- xor si, si
- xor di, di
- mov al, x
- mov bl, x
- imul bl
- mov cx, ax
- xor ax, ax
- mov al, a
- mov bl, x
- imul bl
- sub cx, ax
- mov ax, cx
- xor bx, bx
- mov bl, b
- add bl, 2
- idiv bx
- mov cx, ax
- xor ax,ax
- mov al, a
- mov bl, a
- imul bl
- imul bl
- sub cx, ax
- mov ax, cx
- Print text_res
- mWriteAx
- mov ax, 4c00h
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement