|
-
Aug 3rd, 2001, 03:31 AM
#1
C to assembly
Im in the middle of making a graphics lib in assembly. I assemble it into an object file, and then i link it into my pascal program. I want a line function, but its in C. I feel like a shmuck asking this, but could some one convert it to asm for me? From what im told, its supposed to be the fastest line algo. Its attached...
-
Aug 10th, 2001, 06:03 PM
#2
Fanatic Member
this is such a common function(Bresinhams Algorithm), i'm almost sure someone must have written in Assembly, i've seen it in C, Basic, etc.
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Aug 10th, 2001, 06:39 PM
#3
Its supposed to be a modified version of it. Faster, supposedly.
-
Aug 12th, 2001, 06:12 PM
#4
Assuming this is what you wanted
Code:
TITLE D:\ftp\breslin4.cpp
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS ENDS
$$SYMBOLS SEGMENT BYTE USE32 'DEBSYM'
$$SYMBOLS ENDS
$$TYPES SEGMENT BYTE USE32 'DEBTYP'
$$TYPES ENDS
_TLS SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS ENDS
; COMDAT ?BresLine@@YAXHHHHE@Z
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC ?BresLine@@YAXHHHHE@Z ; BresLine
EXTRN ?FrameBuffer@@3PAEA:DWORD ; FrameBuffer
EXTRN ?WIDTH@@3HA:DWORD ; WIDTH
; COMDAT ?BresLine@@YAXHHHHE@Z
_TEXT SEGMENT
_Ax$ = 8
_Ay$ = 12
_Bx$ = 16
_By$ = 20
_Color$ = 24
_dX$ = -4
_dY$ = -8
_fbXincr$ = -12
_fbYincr$ = -16
_fbXYincr$ = -20
_dPr$ = -24
_dPru$ = -28
_P$ = -32
_AfbAddr$ = -36
_BfbAddr$ = -40
?BresLine@@YAXHHHHE@Z PROC NEAR ; BresLine, COMDAT
; File d:\ftp\breslin4.cpp
; Line 18
push ebp
mov ebp, esp
sub esp, 104 ; 00000068H
push ebx
push esi
push edi
; Line 24
mov eax, DWORD PTR _Ay$[ebp]
imul eax, DWORD PTR ?WIDTH@@3HA ; WIDTH
add eax, DWORD PTR _Ax$[ebp]
mov ecx, DWORD PTR ?FrameBuffer@@3PAEA ; FrameBuffer
add ecx, eax
mov DWORD PTR _AfbAddr$[ebp], ecx
; Line 25
mov edx, DWORD PTR _By$[ebp]
imul edx, DWORD PTR ?WIDTH@@3HA ; WIDTH
add edx, DWORD PTR _Bx$[ebp]
mov eax, DWORD PTR ?FrameBuffer@@3PAEA ; FrameBuffer
add eax, edx
mov DWORD PTR _BfbAddr$[ebp], eax
; Line 31
mov DWORD PTR _fbXincr$[ebp], 1
; Line 32
mov ecx, DWORD PTR _Bx$[ebp]
sub ecx, DWORD PTR _Ax$[ebp]
mov DWORD PTR _dX$[ebp], ecx
cmp DWORD PTR _dX$[ebp], 0
jl SHORT $L284
jmp $L286
$L284:
; Line 33
mov edx, DWORD PTR _dX$[ebp]
neg edx
mov DWORD PTR _dX$[ebp], edx
; Line 34
mov DWORD PTR _fbXincr$[ebp], -1
$AFTERNEGX$285:
; Line 37
mov eax, DWORD PTR ?WIDTH@@3HA ; WIDTH
mov DWORD PTR _fbYincr$[ebp], eax
; Line 38
mov ecx, DWORD PTR _By$[ebp]
sub ecx, DWORD PTR _Ay$[ebp]
mov DWORD PTR _dY$[ebp], ecx
cmp DWORD PTR _dY$[ebp], 0
jl SHORT $L287
jmp $L289
$L287:
; Line 39
mov edx, DWORD PTR ?WIDTH@@3HA ; WIDTH
neg edx
mov DWORD PTR _fbYincr$[ebp], edx
; Line 40
mov eax, DWORD PTR _dY$[ebp]
neg eax
mov DWORD PTR _dY$[ebp], eax
$AFTERNEGY$288:
; Line 43
mov ecx, DWORD PTR _fbXincr$[ebp]
add ecx, DWORD PTR _fbYincr$[ebp]
mov DWORD PTR _fbXYincr$[ebp], ecx
; Line 50
mov edx, DWORD PTR _dY$[ebp]
cmp edx, DWORD PTR _dX$[ebp]
jle SHORT $L290
jmp $L292
$L290:
; Line 53
mov eax, DWORD PTR _dY$[ebp]
add eax, DWORD PTR _dY$[ebp]
mov DWORD PTR _dPr$[ebp], eax
; Line 54
mov ecx, DWORD PTR _dX$[ebp]
neg ecx
mov DWORD PTR _P$[ebp], ecx
; Line 55
mov edx, DWORD PTR _P$[ebp]
add edx, DWORD PTR _P$[ebp]
mov DWORD PTR _dPru$[ebp], edx
; Line 56
mov eax, DWORD PTR _dX$[ebp]
sar eax, 1
mov DWORD PTR _dY$[ebp], eax
$XLOOP$293:
; Line 58
mov ecx, DWORD PTR _AfbAddr$[ebp]
mov dl, BYTE PTR _Color$[ebp]
mov BYTE PTR [ecx], dl
; Line 59
mov eax, DWORD PTR _BfbAddr$[ebp]
mov cl, BYTE PTR _Color$[ebp]
mov BYTE PTR [eax], cl
; Line 60
mov edx, DWORD PTR _P$[ebp]
add edx, DWORD PTR _dPr$[ebp]
mov DWORD PTR _P$[ebp], edx
cmp DWORD PTR _P$[ebp], 0
jle SHORT $L294
jmp $L296
$L294:
; Line 62
mov eax, DWORD PTR _AfbAddr$[ebp]
add eax, DWORD PTR _fbXincr$[ebp]
mov DWORD PTR _AfbAddr$[ebp], eax
; Line 63
mov ecx, DWORD PTR _BfbAddr$[ebp]
sub ecx, DWORD PTR _fbXincr$[ebp]
mov DWORD PTR _BfbAddr$[ebp], ecx
; Line 64
mov edx, DWORD PTR _dY$[ebp]
sub edx, 1
mov DWORD PTR _dY$[ebp], edx
cmp DWORD PTR _dY$[ebp], 0
jle SHORT $L297
jmp SHORT $XLOOP$293
$L297:
; Line 65
mov eax, DWORD PTR _AfbAddr$[ebp]
mov cl, BYTE PTR _Color$[ebp]
mov BYTE PTR [eax], cl
; Line 66
mov edx, DWORD PTR _dX$[ebp]
and edx, 1
test edx, edx
jne SHORT $L298
jmp $L273
$L298:
; Line 67
mov eax, DWORD PTR _BfbAddr$[ebp]
mov cl, BYTE PTR _Color$[ebp]
mov BYTE PTR [eax], cl
; Line 68
jmp $L273
$RightAndUp$295:
; Line 70
mov edx, DWORD PTR _AfbAddr$[ebp]
add edx, DWORD PTR _fbXYincr$[ebp]
mov DWORD PTR _AfbAddr$[ebp], edx
; Line 71
mov eax, DWORD PTR _BfbAddr$[ebp]
sub eax, DWORD PTR _fbXYincr$[ebp]
mov DWORD PTR _BfbAddr$[ebp], eax
; Line 72
mov ecx, DWORD PTR _P$[ebp]
add ecx, DWORD PTR _dPru$[ebp]
mov DWORD PTR _P$[ebp], ecx
; Line 73
mov edx, DWORD PTR _dY$[ebp]
sub edx, 1
mov DWORD PTR _dY$[ebp], edx
cmp DWORD PTR _dY$[ebp], 0
jle SHORT $L299
jmp $XLOOP$293
$L299:
; Line 74
mov eax, DWORD PTR _AfbAddr$[ebp]
mov cl, BYTE PTR _Color$[ebp]
mov BYTE PTR [eax], cl
; Line 75
mov edx, DWORD PTR _dX$[ebp]
and edx, 1
test edx, edx
jne SHORT $L300
jmp $L273
$L300:
; Line 76
mov eax, DWORD PTR _BfbAddr$[ebp]
mov cl, BYTE PTR _Color$[ebp]
mov BYTE PTR [eax], cl
; Line 77
jmp $L273
$YisIndependent$291:
; Line 80
mov edx, DWORD PTR _dX$[ebp]
add edx, DWORD PTR _dX$[ebp]
mov DWORD PTR _dPr$[ebp], edx
; Line 81
mov eax, DWORD PTR _dY$[ebp]
neg eax
mov DWORD PTR _P$[ebp], eax
; Line 82
mov ecx, DWORD PTR _P$[ebp]
add ecx, DWORD PTR _P$[ebp]
mov DWORD PTR _dPru$[ebp], ecx
; Line 83
mov edx, DWORD PTR _dY$[ebp]
sar edx, 1
mov DWORD PTR _dX$[ebp], edx
$YLOOP$301:
; Line 85
mov eax, DWORD PTR _AfbAddr$[ebp]
mov cl, BYTE PTR _Color$[ebp]
mov BYTE PTR [eax], cl
; Line 86
mov edx, DWORD PTR _BfbAddr$[ebp]
mov al, BYTE PTR _Color$[ebp]
mov BYTE PTR [edx], al
; Line 87
mov ecx, DWORD PTR _P$[ebp]
add ecx, DWORD PTR _dPr$[ebp]
mov DWORD PTR _P$[ebp], ecx
cmp DWORD PTR _P$[ebp], 0
jle SHORT $L302
jmp $L304
$L302:
; Line 89
mov edx, DWORD PTR _AfbAddr$[ebp]
add edx, DWORD PTR _fbYincr$[ebp]
mov DWORD PTR _AfbAddr$[ebp], edx
; Line 90
mov eax, DWORD PTR _BfbAddr$[ebp]
sub eax, DWORD PTR _fbYincr$[ebp]
mov DWORD PTR _BfbAddr$[ebp], eax
; Line 91
mov ecx, DWORD PTR _dX$[ebp]
sub ecx, 1
mov DWORD PTR _dX$[ebp], ecx
cmp DWORD PTR _dX$[ebp], 0
jle SHORT $L305
jmp SHORT $YLOOP$301
$L305:
; Line 92
mov edx, DWORD PTR _AfbAddr$[ebp]
mov al, BYTE PTR _Color$[ebp]
mov BYTE PTR [edx], al
; Line 93
mov ecx, DWORD PTR _dY$[ebp]
and ecx, 1
test ecx, ecx
jne SHORT $L306
jmp SHORT $L273
$L306:
; Line 94
mov edx, DWORD PTR _BfbAddr$[ebp]
mov al, BYTE PTR _Color$[ebp]
mov BYTE PTR [edx], al
; Line 95
jmp SHORT $L273
$RightAndUp2$303:
; Line 97
mov ecx, DWORD PTR _AfbAddr$[ebp]
add ecx, DWORD PTR _fbXYincr$[ebp]
mov DWORD PTR _AfbAddr$[ebp], ecx
; Line 98
mov edx, DWORD PTR _BfbAddr$[ebp]
sub edx, DWORD PTR _fbXYincr$[ebp]
mov DWORD PTR _BfbAddr$[ebp], edx
; Line 99
mov eax, DWORD PTR _P$[ebp]
add eax, DWORD PTR _dPru$[ebp]
mov DWORD PTR _P$[ebp], eax
; Line 100
mov ecx, DWORD PTR _dX$[ebp]
sub ecx, 1
mov DWORD PTR _dX$[ebp], ecx
cmp DWORD PTR _dX$[ebp], 0
jle SHORT $L307
jmp $YLOOP$301
$L307:
; Line 101
mov edx, DWORD PTR _AfbAddr$[ebp]
mov al, BYTE PTR _Color$[ebp]
mov BYTE PTR [edx], al
; Line 102
mov ecx, DWORD PTR _dY$[ebp]
and ecx, 1
test ecx, ecx
jne SHORT $L308
jmp SHORT $L273
$L308:
; Line 103
mov edx, DWORD PTR _BfbAddr$[ebp]
mov al, BYTE PTR _Color$[ebp]
mov BYTE PTR [edx], al
; Line 104
jmp SHORT $L273
$L304:
; Line 105
jmp SHORT $RightAndUp2$303
$L296:
jmp $RightAndUp$295
$L292:
jmp $YisIndependent$291
$L289:
jmp $AFTERNEGY$288
$L286:
jmp $AFTERNEGX$285
$L273:
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0
?BresLine@@YAXHHHHE@Z ENDP ; BresLine
_TEXT ENDS
END
oooops - dunno how to can the smilies. sorry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|