Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dosseg
- .model small
- .stack 100h
- .data
- i dw 5
- a dw 15
- b dw -3
- k dw 9
- res dw ?
- .code
- mov ax, @data
- mov ds, ax
- mov ax, a
- cmp ax, b
- jg second
- first: ;if(a<=b)
- mov cx, i ;i
- add cx, 2 ;i+2
- shl cx, 1 ;2(i+2)
- add cx, i ;2(i+2)+i
- add cx, 2 ;3(i+2)
- mov ax, cx ;3(i+2)
- shl ax, 1 ;6(i+2)
- sub ax, 22 ;6i-10
- jmp final
- second: ;if(a>b)
- mov ax, i ;i
- shl ax, 1 ;2i
- shl ax, 1 ;4i
- add ax, 3 ;4i+3
- neg ax ;-(4i+3)
- mov cx, ax ;-(4i+3)
- sub cx, i ;-4i-3-i
- sub cx, i ;-5i-3-i
- add cx, 7 ;-(6i-4)
- final:
- abs_1: neg ax
- js abs_1 ;|i1|
- cmp k, 0
- jge abs_0
- abs_2: neg cx
- js abs_2 ;|i2|
- add ax, cx ;|i1|+|i2|
- jmp ex
- abs_0:
- cmp ax, 6
- jle mnr ;if(|i1|<=6)
- jmp ex
- mnr: mov ax, 6
- ex: mov res, ax
- mov ah, 4ch
- int 21h
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement