flat assembler
Message board for the users of flat assembler.

Index > DOS > the confusing part of registers to me

Author
Thread Post new topic Reply to topic
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 04:20
i am new at this (this may make me pathetic, it may be something right in front of my nose that i dont see) what is relation ship of reigisters like
put var1 in si and it ends up loading into bx or ax i dont know but if you know what i mean, what is this, and what registers load int one and come out the other in a different format stuff like that, if you have a link or an answer (if you have a link there may be a part in the cite that i dont under stand and you will have to explain some parts of it to me).

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 14 Dec 2008, 04:20
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 04:22
ok now some unconfusing part of the question, say i put a number into ax and choose the base in bx, is it a mth type of relation ship, and if so could you give me any other registers that do stuff like that and what they do different.
Post 14 Dec 2008, 04:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 14 Dec 2008, 05:46
I'm not sure what you are asking. Registers are just temporary storage, similar to RAM but much faster. Some instructions use implicit registers (like loop, mul, div) but most instructions use explicit registers (like add, xor).

In 16-bit mode only some registers are valid for memory address: BX, SI, DI and BP (and some combinations with index+base).
Post 14 Dec 2008, 05:46
View user's profile Send private message Visit poster's website Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 06:21
well i mean
like
al =letters to print
mov si,var
how does si have anything to do with al?
maybe its lodsb
well i dont know, if you still dont understand just leave it be, its probably a time wasting question on how something does what doesnt exist and only happens not because of what it is, but of what lodsb and cd:ds or something like that makes it happen. but eh, forget it

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 14 Dec 2008, 06:21
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 14 Dec 2008, 09:20
Of course "ax" and "si" have nothing to do with each others. If you move something into "ax" (e.g. mov ax,10), "si" will still hold its original contents because the "mov" instruction only modifies its first operand (the destination operand).

However, in certain cases, like when using string manipulation instructions (e.g. lods*), the CPU will use and/or modify more than one register for different purposes depending on the said instruction.

You have to check the Intel manuals, and more precisely the "Software Developer's Manual, Instruction Set Reference".

Quote:

LODS/LODSB/LODSW/LODSD—Load String

Loads a byte, word, or doubleword from the source operand into the AL, AX, or EAX register, respectively. The source operand is a memory location, the address of which is read from the DS:EDI or the DS:SI registers



And yes, one more thing, if the code contains an interruption (e.g. int 0x10), you can expect it to modify many registers. You definitely need to check Ralf Brown's reference or any other BIOS and DOS interruption reference.
Post 14 Dec 2008, 09:20
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 15:33
for the last time, i have looked at the int list!!!! but about the ds:edi do i load my string into DS or EDI? to get lodsb working
Post 14 Dec 2008, 15:33
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 17:43
can someone please respond to this, i need an answer. it is very important
Post 14 Dec 2008, 17:43
View user's profile Send private message Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder 14 Dec 2008, 19:25
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:54; edited 1 time in total
Post 14 Dec 2008, 19:25
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 14 Dec 2008, 19:38
Since this is the DOS forum he should bother with it. You should "load your string" into DS:SI for LODSx and I have no idea what the int list has to do with it. If you are writing a .COM executable and the string is defined inside the source you may follow asmcoder's advice (except that you must use SI register, not DI), but if you are scanning memory that doesn't exist at compile-time (i.e. run-time allocated memory), then DS must be set.
Post 14 Dec 2008, 19:38
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 19:45
thank you guys so much for responding to my message, i will try edi and ds. thanks!

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 14 Dec 2008, 19:45
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 14 Dec 2008, 19:59
Hey, there is an errata in the Intel manuals, they say this (which I suppose it is the same ManOfSteel posted): "The source operand is a memory location, the address of which is read from the DS:EDI or the DS:SI registers (depending on the address-size attribute of the instruction, 32 or 16, espectively). The DS segment may be overridden with a segment override prefix."

That's wrong, and in the table above that paragraph there are no mentions about EDI (because the table is correct). The pseudo-code below also seems to be correct (again no EDI appearances).
Post 14 Dec 2008, 19:59
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 20:13
so what do you mean? if i put something in ds it will end up in edi?
the code im using is use16
or is it load ds and it will end up in al, or something lik that? using lods of course. or correct me
Post 14 Dec 2008, 20:13
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 14 Dec 2008, 20:17
Just EDI has nothing to do with any version of LODSx. With lodsb AL will be loaded with the contents of the memory location at DS:SI ([DS*16 + SI] physical address). Once AL is loaded, SI is incremented by one.
Post 14 Dec 2008, 20:17
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 20:41
so which register do i load my string for it to be good for lods to load it to al?
Post 14 Dec 2008, 20:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 14 Dec 2008, 20:46
GhostXoPCorp wrote:
so which register do i load my string for it to be good for lods to load it to al?
SI
Post 14 Dec 2008, 20:46
View user's profile Send private message Visit poster's website Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 20:51
thanks beacue what i want to do is put the string in si as the usr is typing to print what he or she is typing, and at the same time save what he or she typed in a register to cmp it for a match with other commands. when the user put types a then b it prints, but will si keep a and b as "ab" so i check it for cmp si, ab?
Post 14 Dec 2008, 20:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20337
Location: In your JS exploiting you and your system
revolution 14 Dec 2008, 20:55
You should keep the string of bytes in memory. A single 16-bit register can only store two byte maximum.
Code:
mov [si],al ;save the entered key
inc si ;point si to the next position in memory.    
Post 14 Dec 2008, 20:55
View user's profile Send private message Visit poster's website Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
GhostXoPCorp 14 Dec 2008, 21:02
great, im building a 16 bit rm dos and it ca onl get 2 bytes, ok thanks for answering all of my questions on this thread. this pretty much sums it up
Post 14 Dec 2008, 21:02
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.