Skip to main content
GameDev.net gamedev.net
🔒 Locked

assembly question

Started by VanillaSnake21 Jun 22, 2007 at 2:58 PM 2 replies 900+ views
Original Post
VanillaSnake21
VanillaSnake21
Hi Im having problems with my code, I'm trying to get the argument string from the PSP at offset 81h, and a part of my code is

	mov ah, 62h
	int 21h     ;// get PSP addrs

	push es
		mov es, bx                ;// bx contains the PSP addrs after the last 62h - 21h call
	        lea ax, byte ptr es:[81h] ;// loads absolute addr of a byte
	pop es

this is not all the code, but i just wanted to clarify something for myself, what is the point of byte ptr infront of es:[81h]? When I run the code through a debugger (CodeView) it disassembles the lea instruction to lea ax, word ptr es:[81h], which is the same as if I had ommited the byte ptr in the first place. Thanks
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts
Extrarius
Extrarius
Labeling a pointer with a size only matters when you're moving data. When you're doing address calculations(as 'lea' does), it doesn't matter at all.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
VanillaSnake21
VanillaSnake21
Quote:
Original post by Extrarius
Labeling a pointer with a size only matters when you're moving data. When you're doing address calculations(as 'lea' does), it doesn't matter at all.


Thanks, thats what I wantd to know
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts
VanillaSnake21
VanillaSnake21
This might be a little off from my OP question, but i didnt wanna start a new thread.
When I display a string, with function 09h, int 21h, I have to put the string I want to display into DS:DX format. So what I do is
mov ax, seg line_str ;move the segment address into axmov ds, ax           ;point ds at address in axlea dx, line_str     ; compute (offset?) global address of line_strmov ah, 09h          ;specify subfunction to use in int21hint 21h              ;call DOS interrupt


So my question is - if lea loads the effective address, which is an absolute address of a mem location, how come this works? Isn't DX supposed to contain the offset to the line_str, but instead here it contains a whole global address. Thanks

EDIT: added comments
You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.