flat assembler
Message board for the users of flat assembler.

Index > Main > Of 'LEA' and DS:DX

Author
Thread Post new topic Reply to topic
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 26 Jul 2010, 02:06
hello i need help on how pointers work (string ptrs in this case)....
for example. pointing to 'stringName' in segment data.

Code:
format MZ 
org 100
entry cod:main
segment data
stringName DB 'fasm...',0
segment cod
main:
mov ah,4bh ;exampl. load/Exec
mov al,00
lea  dx,stringName ;<-- 
    


<-- this is where i hav a problem.fasm wont allow that, but nasm works...how can i go about this problem to make sure its DS:DX?
your help will be greatly appreciated...
thanks..


Last edited by typedef on 26 Jul 2010, 02:12; edited 1 time in total
Post 26 Jul 2010, 02:06
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 26 Jul 2010, 02:09
sorry for the unformatted code..i was using my psp...sorry
Post 26 Jul 2010, 02:09
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 26 Jul 2010, 02:12
Code:
lea dx, [blah]
    


Also, don't make things complicated, there is no need to define segments if you don't have > 64 KiB of bloat.

> to make sure its DS:DX?

PUSH CS POP DS

Why do you remove the code tags ??? Confused Confused Confused Confused Confused Confused Confused Confused Confused Confused Confused
Post 26 Jul 2010, 02:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 26 Jul 2010, 02:24
This:
Code:
lea dx,[stringName]    
Or this:
Code:
mov dx,stringName    
Both do the same thing.
Post 26 Jul 2010, 02:24
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Jul 2010, 02:37
I think you should not use "org 100" no need to force some origin (which probably will kill relocations). Also note that when you want to produce COM files then you should use org with $100, or 0x100 or 100h.

Your program in COM version:
Code:
org $100
; This is the entry always:
mov ah,4bh ;exampl. load/Exec
mov al,00
mov dx,stringName ;<--

; Exit program:
int $20

; Now lets put some data:
stringName DB 'fasm...',0    


In the case of doing MZ executables, I think that you will need "mov ax, data / mov ds, ax" since I don't think DOS will setup it for you (and I believe you can't rely that using "push CS / pop DS" will work always). But as DOS386 recommended, don't define more segments than you really need, in this case you should drop data segment and simply put all that data at the end of cod segment (and in this case "push CS / pop DS" is fine of course).
Post 26 Jul 2010, 02:37
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 26 Jul 2010, 02:38
thx. you guys are awesome....quick responses.... +5 Very Happy
Post 26 Jul 2010, 02:38
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 26 Jul 2010, 02:47
im used to C/C++ and so i find ASM quiet 'complicated'. 'complicated' in a way that i kinda feel familiar with it more than i do compared with C/C++
Post 26 Jul 2010, 02:47
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 26 Jul 2010, 03:01
> In the case of doing MZ executables, I
> think that you will need "mov ax, data
> / mov ds, ax" since I don't think
> DOS will setup it for you

Only if you have multiple segments, as both DS and ES
point to the PSP at MZ program start.

> (and I believe you can't rely
> that using "push CS / pop DS" will work always)

It will as long as one has just 1 segment.

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 26 Jul 2010, 03:01
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 26 Jul 2010, 09:53
typedef: DOS Asm indeed has levels you don't need to care about in C/C++. It might be better idea to start with linux / windows asm, where you don't have to complicate things with segments & stuff.

However, if you are taking school course, they (in my experience) seldom realize this, and seldom know linux/windows assembly themselves.
Post 26 Jul 2010, 09:53
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 27 Jul 2010, 01:21
vid wrote:
better idea to start with linux / windows asm, where you don't have to complicate things with segments & stuff


There are other (more horrible) things there Wink

Quote:
if you are taking school course, they (in my experience) seldom realize this, and seldom know linux/windows assembly themselves


Bad shool. If you want to develop for DOS, then you need "MZ" / "org $0100" / "INT $21" etc., OTOH if you don't want to develop for DOS, then you should avoid such stuff and pick the correct examples instead, and download the correct package of FASM.
Post 27 Jul 2010, 01:21
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Jul 2010, 13:27
Quote:
There are other (more horrible) things there

In case he's moving from C/C++ to Asm, eg. he already knows windows interface, what horrible things for him are there?
Post 27 Jul 2010, 13:27
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 29 Jul 2010, 05:58
OK. Thanks guys...Question answered. This thread can now be closed..
Post 29 Jul 2010, 05:58
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.