Re: Help data conversion



On Sun, 07 Aug 2005 14:47:19 -0400, Frank Kotler
<fbkotler@xxxxxxxxxxx> wrote:
>¬a\/b wrote:
>
>> for me it is right
>> if first of jump es=0400h, after jump i have to set ds=0400h (because
>> the jump set cs:ip, right?) is it true? (it is all right if after jump
>> 'es' point where is the data
>> and data is in 0400h in the case cs=ds==0400h. Is it ok?)
>
>Well, when the bios transfers control to our bootsector, we don't know
>how registers are set (except dl = boot device) - varies from one
>machine to another. We know it jumps to 07C00h - usually cs = 0 and ip -
>7C00h, but there are rumors that some machines (certain Compac Presario
>models?) jump to cs = 7C0h, ip = 0.

if push cs; pop ds; i don't see (for the boot programme i have) the
problem even if in the boot programme (it seems to me the programme
that load disk in the memory) use some data

I have a boot prog that say something like

ORG 7c00h
jump start
ROUTINE_FOR_PRINT
msg db "message", 13, 10, 0
start:
ax=07c0h| ss=ax| sp=03feh
push cs
pop ds
mov ah, 00h| mov al, 03h| int 10h
push di| mov di, msg| call ROUTINE_FOR_PRINT| pop di
ah=02h | al=02h |ch=0 | cl=2 | dh=0 | dl=0;
bx=0800h | es=bx| bx=0| int 13h
jump 0800h:0000h

yes in case cs:ip =0000:7c00 is it a problem if
ss:sp =07c0:03fe ?

does ORG 07c00h mean cs:ip = 07c0:0000 or cs:ip =0000:7c00?
or some other? (i think org sets only offset *for data*; so ORG
07c00h means if label is find its address is
offset_label_from_start_of_file+07c00 ) it is right? and if overflow?
org does not influence instructions?

>REM's code starts with a far jump
>(which loads cs *and* ip - that's what makes it "far") to 7C0h:00xx, so
>we know for sure what cs is at that point. Then he sets ds and es to
>that value.

>This needs to be "coordinated" with the "org" statement!
>If you've got a
>variable like "numbuff", the number that Nasm replaces this with is
>calculated by the offset into the file, plus the origin ("org" - Nasm
>defaults to "org 0", if you don't say).

so "a label" is an offset from the begin of file for the assembler?


>Incidentally, "numbuf dw 0" is
>only two bytes - not long enough to hold "1,111,111,111", 0 - but
>there's nothing after it to overwrite, so it works even if it isn't
>"right". A bootsector at "org 7C00h" (which is common) wants ds (and es,
>perhaps) set to 0.

org 7C00h
why es=ds=0
why not es=ds=cs=7c00?
[]

>Thanks for the on-topic discussion!

thank you
.



Relevant Pages

  • Re: Help data conversion
    ... problem even if in the boot programme use some data ... mov ah, 00h| mov al, 03h| int 10h ... jump 0800h:0000h ... you could say that Nasm acts as its own linker - and the "relocation" that gets done is to add the "org" to the file offset. ...
    (alt.lang.asm)
  • mailboxes
    ... specifically Org. ... I've tried to jump ... from bank a few times. ... Or do you need to be druid/shaman and xform? ...
    (alt.games.warcraft)
  • Re: mailboxes
    ... >> How do you get on mailboxes to dance? ... specifically Org. ... >> jump from bank a few times. ...
    (alt.games.warcraft)
  • Re: CS=0000, IP=7C00 assumption
    ... A far jump would be too long to be FAT-compatible, ... required boot sector ID. ... mov sp, 7C00h ... Or save just SS & SP, setup your stack, and push the rest. ...
    (alt.lang.asm)
  • Re: CS=0000, IP=7C00 assumption
    ... and adding a jump at the beginning fixed it. ... I *thought* that the "mythical machine" that refused to boot without the initial jump was on a floppy, so it must have been something in ROM, no? ... mov sp, 7C00h ... push ss; ...
    (alt.lang.asm)