简体   繁体   中英

intel to ATT assembley conversion for reading data segment of BIOS

What will be the equivalent ATT code for the following intel code:

    BIOS    segment byte at 40h
            org     13h
            memory  dw      ?
    BIOS    ends

That's not a question of at&t syntax as such. It's a question of what assembler and linker you use. Also, I suppose you still need to load the segment register by hand. Thus the simplest case would be to get rid of that whole thing, and instead do something along these lines:

mov $0x40, %ax
mov %ax, %es
mov %es:0x13, %ax

Depending on your requirements and the available tools, you can of course produce fancier code, but I don't see much point.

There's no equivalent for the AT 40h attribute of a segment definition in AT&T syntax as used by the GNU assembler. GAS doesn't actually understand x86 segments and has no special support for them. Neither do the object formats supported by GAS, PECOFF and ELF. Note that sections (sometimes called segments) are not the same thing as x86 segments. Even modern versions of MASM don't support the AT attribute anymore.

If your MASM code uses the BIOS segment like in the following example:

BIOS    segment byte at 40h
        org     13h
        memory  dw      ?
BIOS    ends

_TEXT   SEGMENT USE16
    mov bx, OFFSET memory
    mov ax, SEG memory
    mov es, eax
_TEXT   ENDS

Then you can do the equivalent in AT&T syntax with something like this:

memory = 0x04
memory_seg = 0x40

.text:    
    mov $memory, %bx
    mov $memory_seg, %ax
    mov %ax, %es

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM