Can't add relative quantities, assembly error

假如想象 提交于 2021-01-29 09:20:28

问题


so for a project i need to program a game in 80386 (32-bit processor).

To draw a pixel we got this example code from the teacher:

-first set the video mode: MOV ah, 00h MOV al, 13h INT 10h

-drawing the pixel:

MOV ESI, 0A0000H ; frame buffer address

MOV EDI, 320 * 2 + 10; add the appropriate offset
MOV AL, 10 ; index in the colour palette
MOV [EDI], AL ; change pixel at column 10 of row 2

This code works perfectly, but in my game code i want to add in the data the x and y positions of the 'player'

xpos dw 10 ypos dw 2

when i try to acces those variables i get the error "Can't add relative quantities"

i've tried:

MOV ESI, 0A0000H ; frame buffer address
MOV EDI, 320 * offset yPosChar + offset xPosChar; add the appropriate offset
MOV AL, 10 ; index in the colour palette
MOV [EDI], AL ; change pixel at column 10 of row 2

and also: (this gets an other error: "illegal memory acces")

MOV ESI, 0A0000H ; frame buffer address
MOV EDI, 320 * [yPosChar] + [xPosChar] ; add the appropriate offset
MOV AL, 10 ; index in the colour palette
MOV [EDI], AL ; change pixel at column 10 of row 2

PLEASE HELP? IDK WHAT IM DOING WRONG AND IT DRIVES ME CRAZY

来源:https://stackoverflow.com/questions/64830004/cant-add-relative-quantities-assembly-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!