Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

OOP and TASM

i'm just posting this because some people still didnt realize that
OOP is also possible with TASM.
if u like to find out more about it, search for OOP TASM (or something
like that) on google.

[code]
ideal
locals @@
model tiny, pascal
p386

STRUC pixel GLOBAL METHOD {

set : word = set_pixel
get : word = get_pixel

}
x dw ?
y dw ?
col db ?
ends pixel

STRUC pixel2 GLOBAL METHOD {
}
x dw ?
y dw ?
z dw ?
ends pixel2


CODESEG
org 100h
main:
push cs
pop ds

mov ax,13h
int 10h

CALL p METHOD pixel:set, offset p
CALL p1 METHOD pixel:set, offset p1
CALL p METHOD pixel:get, offset p,170,110
CALL p METHOD pixel:set, offset p

mov ah,08h
int 21h

mov ax,03h
int 10h

ret


proc set_pixel USES es di ax bx dx, STRUCOFS : word
push 0a000h
pop es
mov di,[STRUCOFS]
mov ax,320
mul [(pixel ptr di).y]
add ax,[(pixel ptr di).x]
mov bx,ax
mov al,[(pixel ptr di).col]
mov [es:bx],al
ret
endp

proc get_pixel USES es di ax bx dx, STRUCOFS,@@x,@@y : word
push 0a000h
pop es
mov di,[STRUCOFS]
mov ax,320
mul [@@y]
add ax,[@@x]
mov bx,ax
mov al,[es:bx]
mov [(pixel ptr di).col],al
ret
endp

p : pixel { x = 160, y = 100, col = 15 }
p1 : pixel { x = 170, y = 110, col = 2 }

end main[/code]

Comments

Sign In or Register to comment.