Doug8
asked on
Another Assembly Question
I am trying to learn to use assembly and am trying to make a fuction to
draw a pixel to unsigned char far *double buffer using an external
assembly function. and i cant get it to work right. This is what i have
so far and it gives me 2 errors.
; AsmPixel(int x, int y, int value)
Parms struc
dw 2 dup(?)
x dw ?
y dw ?
value dw ?
Parms ends
.model small
.386
.code
public _AsmPixel
extrn _double_buffer:word
ES:DI -> double_buffer
_AsmPixel proc near
push bp
mov dx, 320 ; Put 320 in DX
mul dx ; multiply AX (Y) by DX (320)
add ax, bx ; add BX (X) to AX -> 320*y+x
add di, ax ; add to pointer offset ***
;ES:DI now points at &double_buffer[320*y+x]
mov es:[di], cl ; Store the byte
_AsmPixel endp
draw a pixel to unsigned char far *double buffer using an external
assembly function. and i cant get it to work right. This is what i have
so far and it gives me 2 errors.
; AsmPixel(int x, int y, int value)
Parms struc
dw 2 dup(?)
x dw ?
y dw ?
value dw ?
Parms ends
.model small
.386
.code
public _AsmPixel
extrn _double_buffer:word
ES:DI -> double_buffer
_AsmPixel proc near
push bp
mov dx, 320 ; Put 320 in DX
mul dx ; multiply AX (Y) by DX (320)
add ax, bx ; add BX (X) to AX -> 320*y+x
add di, ax ; add to pointer offset ***
;ES:DI now points at &double_buffer[320*y+x]
mov es:[di], cl ; Store the byte
_AsmPixel endp
ASKER
The errors are end of file found and symbol already different kind on the line of ES:DI-> double_buffer. And i dont know if it contains the address of double_buffer and i dont know the statement lea. Thanx for the suggestion.
Don't you need "end" at the end of file. That should fix the eof error. It's been awhile for me in ASM but don't you need
mov byte ptr es:[di],cl (byte ptr added)?
mov byte ptr es:[di],cl (byte ptr added)?
ASKER
Adjusted points to 70
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you sure ES:DI contains the adress of the buffer? shouldn't you load the adres with lea ?
A good trick is: write it in C and compile to assembly, and use it as a starter.
.luc.