-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlineFromTo.asm
executable file
·122 lines (102 loc) · 2.2 KB
/
lineFromTo.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
; push color
; push x1
; push y1
; push x2
; push y2
lineFromTo:
push bp
mov bp,sp
push bx
mov ax,[bp+6]
sub ax,[bp+10]
jnl lineFromTo_prev1
neg ax
lineFromTo_prev1:
mov cx,[bp+4]
sub cx,[bp+8]
jnl lineFromTo_prev2
neg cx
lineFromTo_prev2:
cmp cx,ax
jle lineFromTo_y_less_x
;--------------------------------
shl ax,6
xor dx,dx
div cx
mov [lineFromTo_temp],ax
mov bx,[bp+8]
mov word [lineFromTo_sign],1
cmp bx,[bp+4]
jl lineFromTo_x_less_y_loop
mov word [lineFromTo_sign],-1
lineFromTo_x_less_y_loop:
mov ax,bx
sub ax,[bp+8]
jnl lineFromTo_x_less_y_loop_next1
neg ax
lineFromTo_x_less_y_loop_next1:
mul word [lineFromTo_temp]
shr ax,6
mov cx,[bp+10]
cmp cx,[bp+6]
jge lineFromTo_x_less_y_loop_next2
add cx,ax
jmp lineFromTo_x_less_y_loop_next3
lineFromTo_x_less_y_loop_next2:
sub cx,ax
lineFromTo_x_less_y_loop_next3:
push cx
push bx
push word [bp+12]
call point
add bx,[lineFromTo_sign]
cmp bx,[bp+4]
jne lineFromTo_x_less_y_loop
;--------------------------------
jmp lineFromTo_end
lineFromTo_y_less_x:
;--------------------------------
push ax
push cx
pop ax
pop cx
shl ax,6
xor dx,dx
div cx
mov [lineFromTo_temp],ax
mov bx,[bp+10]
mov word [lineFromTo_sign],1
cmp bx,[bp+6]
jl lineFromTo_y_less_x_loop
mov word [lineFromTo_sign],-1
lineFromTo_y_less_x_loop:
mov ax,bx
sub ax,[bp+10]
jnl lineFromTo_y_less_x_loop_next1
neg ax
lineFromTo_y_less_x_loop_next1:
mul word [lineFromTo_temp]
shr ax,6
mov cx,[bp+8]
cmp cx,[bp+4]
jge lineFromTo_y_less_x_loop_next2
add cx,ax
jmp lineFromTo_y_less_x_loop_next3
lineFromTo_y_less_x_loop_next2:
sub cx,ax
lineFromTo_y_less_x_loop_next3:
push bx
push cx
push word [bp+12]
call point
add bx,[lineFromTo_sign]
cmp bx,[bp+6]
jne lineFromTo_y_less_x_loop
;--------------------------------
lineFromTo_end:
pop bx
mov sp,bp
pop bp
retn 10
lineFromTo_sign dw 1
lineFromTo_temp dw 0