From: cerise-nasm@l.armory.com - 2006-04-05 22:10:26
|
I'm using nasm 0.98.39 and I'm trying to assemble plain binary which will spit out a string when plopped onto a floppy disk and made to boot. I've done this a couple of different ways, but what I'd really like to do is have the string pointed to by ds:si. The string is defined as: message db "Hello!", 0x0D, 0x0A, 0x00 I've tried: lds si, message (invalid comination of opcode and operands) lds si, [message] (which gives ds:si f000:ff56, not 0000:7c03) The latter struck me as odd because I took [message] to be accessing the memory address contained in message, not the address of message -- which isn't what I want. I also attempted defining a pointer (ptr dw message, 0) and using lds si, [ptr] which inexplicably gives me f000:ff53. I also tried setting it through eax (mov eax, message ; mov si, ax ; shr eax, 16 ; mov ds, ax ) with no luck. I tried setting ds to seg message and si to message, but I can't use seg in plain binary. Using the tremendous power of mathematics, I can do mov eax, 0x00007c03 mov si, ax shr eax, 16 mov ds, ax call putstr and I get my string AOK, but there is seemingly no symbolic form I can use. What is the correct form to make this work? I'd prefer to let the computer do the adding. 8) -Phil/CERisE P.S. If you really want to see the rather amateurish code, here it is. I used to have message right after the hlt command, but when plain arithmetic became a necessity, I used the more conventional format. I've also tried all my labels with :s -- odd that it's optional, but kinda cool. I imagine it'll bite me hard some day when I mistype an identifier in a ton of code though. 8) jmp start message db "Hello!", 0x0D, 0x0A, 0x00 ptr dw message, 0 start lds si, [ptr] ;mov eax, 0x00007c03 ;mov si, ax ;shr eax, 16 ;mov ds, ax call putstr hlt putstr mov ah, 0x0E xor ebx, ebx putloop lodsb or al, al jz putend int 0x10 jmp putloop putend ret |