S
sub
Прога, написанная на асме, работает корректно только из-под Нортона. При запуске из командной строки cmd ничего не выдает (должна рисовать линию). Кто знает в чем проблема и как её решить? Исходник: (писал не сам, тк в асме почти ничего не парю)
[codebox].model small
.data
pos_x dw 320
pos_y dw 20
old_x dw 160
old_y dw 100
x_inc dw -1
y_inc dw -1
color db 39
.stack 256
.386
.code
line_bresenham proc
pusha
mov cx, pos_x
mov dx, pos_y
mov ax, cx
sub ax, old_x
jns pixel_dx
neg ax
mov word ptr x_inc, 1
jmp short pixel_xneg
pixel_dx: mov word ptr x_inc,-1
pixel_xneg: mov bx, dx
sub bx, old_y
jns pixel_dy
neg bx
mov word ptr y_inc, 1
jmp short pixel_yneg
pixel_dy: mov word ptr y_inc,-1
pixel_yneg: shl ax,1
shl bx,1
call set_pixel
cmp ax, bx
jna neg_dxdy
mov di, ax
shr di, 1
neg di
add di, bx
line_cycle_a: cmp cx, word ptr old_x
je exit_bres
cmp di, 0
jl line_calc_a
add dx, word ptr y_inc
sub di, ax
line_calc_a: add cx, word ptr x_inc
add di, bx
call set_pixel
jmp short line_cycle_a
neg_dxdy: mov di, bx
shr di, 1
neg di
add di, ax
line_cycle_b: cmp dx, word ptr old_y
je exit_bres
cmp di, 0
jl line_calc_b
add cx, word ptr x_inc
sub di, bx
line_calc_b: add dx, word ptr y_inc
add di, ax
call set_pixel
jmp short line_cycle_b
exit_bres: popa
ret
line_bresenham endp
pixel_coords proc
push ax
push dx
mov ax, dx
mov bx, 320
mul bx
pop dx
add ax, cx
mov bx, ax
pop ax
ret
pixel_coords endp
set_pixel proc
push ax
push bx
mov al, color
call pixel_coords
mov byte ptr es:[bx], al
pop bx
pop ax
ret
set_pixel endp
begin: ;assume cscode, dsdata, ssstack
mov ax, @data
mov ds, ax
push 0a000h
pop es
mov ax, 0013h
int 10h
call line_bresenham
mov ax, 4c00h
int 21h
end begin[/codebox]
[codebox].model small
.data
pos_x dw 320
pos_y dw 20
old_x dw 160
old_y dw 100
x_inc dw -1
y_inc dw -1
color db 39
.stack 256
.386
.code
line_bresenham proc
pusha
mov cx, pos_x
mov dx, pos_y
mov ax, cx
sub ax, old_x
jns pixel_dx
neg ax
mov word ptr x_inc, 1
jmp short pixel_xneg
pixel_dx: mov word ptr x_inc,-1
pixel_xneg: mov bx, dx
sub bx, old_y
jns pixel_dy
neg bx
mov word ptr y_inc, 1
jmp short pixel_yneg
pixel_dy: mov word ptr y_inc,-1
pixel_yneg: shl ax,1
shl bx,1
call set_pixel
cmp ax, bx
jna neg_dxdy
mov di, ax
shr di, 1
neg di
add di, bx
line_cycle_a: cmp cx, word ptr old_x
je exit_bres
cmp di, 0
jl line_calc_a
add dx, word ptr y_inc
sub di, ax
line_calc_a: add cx, word ptr x_inc
add di, bx
call set_pixel
jmp short line_cycle_a
neg_dxdy: mov di, bx
shr di, 1
neg di
add di, ax
line_cycle_b: cmp dx, word ptr old_y
je exit_bres
cmp di, 0
jl line_calc_b
add cx, word ptr x_inc
sub di, bx
line_calc_b: add dx, word ptr y_inc
add di, ax
call set_pixel
jmp short line_cycle_b
exit_bres: popa
ret
line_bresenham endp
pixel_coords proc
push ax
push dx
mov ax, dx
mov bx, 320
mul bx
pop dx
add ax, cx
mov bx, ax
pop ax
ret
pixel_coords endp
set_pixel proc
push ax
push bx
mov al, color
call pixel_coords
mov byte ptr es:[bx], al
pop bx
pop ax
ret
set_pixel endp
begin: ;assume cscode, dsdata, ssstack
mov ax, @data
mov ds, ax
push 0a000h
pop es
mov ax, 0013h
int 10h
call line_bresenham
mov ax, 4c00h
int 21h
end begin[/codebox]