Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. dosseg
  2. .model small
  3. .stack 100h
  4. .data
  5. i dw 5
  6. a dw 15
  7. b dw -3
  8. k dw 9
  9. res dw ?
  10. .code
  11. mov ax, @data
  12. mov ds, ax
  13.  
  14. mov ax, a
  15. cmp ax, b
  16. jg second
  17.  
  18. first: ;if(a<=b)
  19. mov cx, i ;i
  20. add cx, 2 ;i+2
  21. shl cx, 1 ;2(i+2)
  22. add cx, i ;2(i+2)+i
  23. add cx, 2 ;3(i+2)
  24.  
  25. mov ax, cx ;3(i+2)
  26. shl ax, 1 ;6(i+2)
  27. sub ax, 22 ;6i-10
  28. jmp final
  29.  
  30. second: ;if(a>b)
  31. mov ax, i ;i
  32. shl ax, 1 ;2i
  33. shl ax, 1 ;4i
  34. add ax, 3 ;4i+3
  35. neg ax ;-(4i+3)
  36.  
  37. mov cx, ax ;-(4i+3)
  38. sub cx, i ;-4i-3-i
  39. sub cx, i ;-5i-3-i
  40. add cx, 7 ;-(6i-4)
  41.  
  42. final:
  43. abs_1: neg ax
  44. js abs_1 ;|i1|
  45. cmp k, 0
  46. jge abs_0
  47.  
  48. abs_2: neg cx
  49. js abs_2 ;|i2|
  50. add ax, cx ;|i1|+|i2|
  51. jmp ex
  52.  
  53. abs_0:
  54. cmp ax, 6
  55. jle mnr ;if(|i1|<=6)
  56. jmp ex
  57. mnr: mov ax, 6
  58. ex: mov res, ax
  59. mov ah, 4ch
  60. int 21h
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement