【发布时间】:2022-12-05 06:26:57
【问题描述】:
我不知道是否有人能够帮助我,但我会尽可能清楚地解释我的问题。我正在使用 YASM 学习 8086 FPU。我想画画y = cos(x^2+x+1)This is how this graph looks like。我是在 DosBox 中做的,我正在模拟 8086 处理器。
我的问题:如何标准化图形的(红色)比率,以便在 DosBox 中可读。
到目前为止,我设法绘制了一个坐标平面。而且我想我设法绘制了这张图,但是比例太小无法检查它是否真的很好。这是到目前为止的样子GRAPH IMAGE](https://i.stack.imgur.com/0Hy6X.jpg)。
我正在使用 FPU 来计算 Y 坐标。我正在使用堆栈来计算 Y 坐标。 X 坐标将从 320 变为 0(使用 dec si),如您在我的代码中所见。
在这段代码中,我尝试用不同的 X (si) 计算 Y (di)。把像素放在它必须在的地方。
;------------------------------------------------------------------------
%include 'yasmmac.inc'
org 100h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
section .text ; Code starts here
startas:
call procSetGraphicsMode
;;;;;;;;;;;;;;;;;;;;;;;;; COORDINATE PLANE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov di, 200
mov si, 160
.vertical:
mov cl, 15
call procPutPixel
dec di
jnz .vertical
mov si, 320
.horizontal:
mov di, 100
mov cl, 15 ; 15 = white color
call procPutPixel
dec si
jnz .horizontal
; y = di
; x = si
mov si, 320
mov di, 100
;;;;;;;;;;;;;;;;;;;;;;;; GRAPH ;;;;;;;;;;;;;;;;;;;;;;;;
.loop:
mov [value1], si
mov [value2], si
finit
fild dword [value1]
fild dword [value1]
fild dword [value3] ; move to stack 1
fmul dword [value1]
fadd st0, st1 ; add x in stack head
fadd st0, st3 ; add 1 in stack head
fcos ; cos(x^2 + x + 1)
frndint ; round
fistp word [y] ; Load rounded answer to [y] variable
add di, [y] ; Add [y] to di
mov cl, 4 ; 4 = Red color
call procPutPixel
dec si
jnz .loop
;;;;;;;;;;;;;;;;;;;;;;;; WAIT FOR ESC ;;;;;;;;;;;;;;;;;;;;;;;;
call procWaitForEsc
exit
%include 'yasmlib.asm'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
section .data ; data
value1:
dd 0.0
value2:
dd 0.0
value3:
dd 1.0
xc:
dw 160
yc:
dw 100
x:
dw 0
y:
dw 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
section .bss
yasmlim.asm 如果有帮助
【问题讨论】:
标签: assembly graph x86 fpu yasm