在实模式下用 Bresenham 的线算法计数,汇编

标签 c assembly types x86 floating-point

嘿!
我想在 assembly 中画线。我用 C 写了算法,现在我需要把它放到汇编中。
我在 16 位实模式;图形模式:12h (640*480 16colors)
C 源代码:

//x1/y1/x2/y2 = start x, start y, end x, end y
void draw_line(int x1, int y1, int x2, int y2)
{
    double delta_l = (x2-x1)/(y2-y1);
         //delta_l = like graph slope; maybe it's negative and/or not integer
         // it can be also type 'float'
    double y;

    for(int x = x1; x <= x2; x++)
    {
        y = y1 + ( x * delta_l );
        Round_To_Integer(y);
        Put_Pixel(x, y, color);
    }
}

我的问题是我无法在汇编中使用 float (或 double )进行计数。
请帮我把这段 C 代码“翻译”成 ASM。
谢谢。

最佳答案

我对Bresenham算法的理解是,其核心思想是通过使用一个变量来避免浮点运算,将误差累加到一个整数变量中,当误差超过一定值时进行修正。

page有一步一步的解释。

关于在实模式下用 Bresenham 的线算法计数,汇编,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5687102/

相关文章:

c - 如果使用 printf 格式化后没有参数会怎样?

c - gcc 用 .s 文件编译 .c - .bss 混淆(错误?)

c++ - 将 C++ 内联汇编函数转换为 delphi 内联汇编函数

C# 将 char 转换为大于 256 的 int

c++ - 在 linux 中使用 c/c++ 锁定文件

c - grep C 类型定义的正则表达式

我可以使用 &array[0][0][0] 传递声明为 double ***array 的 3D 数组吗?

assembly - ARM 汇编中的 STR 指令不起作用(使用 KEIL)

types - 在函数式编程中确定函数的类型

haskell - 部分应用说明-join