Page 1 of 1

stuck on vga problem.

Posted: Fri Jun 04, 2004 8:04 am
by jinksys
Im have a bit of trouble with this assembly program,
all it is supposed to do is put the 15 byte values of
"image" into the VGA buffer...but when I fire up bochs,
I get garbage. If I dont use lodsb and load AX manually,
I get the correct output. any help? also, im confused as to
what $ does when used with labels. At&t syntax doesnt seem
to have brackets like nasm/tasm/masm.

.org 0x0,0x0
.code16

.globl _start
_start:

movw $0x13,%ax
int   $0x10

push $0x0A000
pop %es

xor %di,%di

mov image,%si

movw $15,%cx



write_loop:
lodsb
stosb
loop write_loop

halt:
jmp halt

image: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1

.org 510,0
.byte 0x55,0xAA

Re:stuck on vga problem.

Posted: Fri Jun 04, 2004 8:39 am
by Pype.Clicker
$<somethin> is a litteral in AT&T. <something> is a memory reference.

So, for instance

Code: Select all

movw $0xa000,%ax
will load ax with the value 0xA000 while

Code: Select all

movw 0xa000,%ax
loads %ax with the memory word at offset 0xA000

I'm not ATT-guru enough to tell you what

Code: Select all

 movw label,%ax 
movw $label,%ax
but if you wanna be sure you loaded the *offset* rather than the content, just use LEA instead of MOV ...

Code: Select all

lea label,%ax

Re:stuck on vga problem.

Posted: Fri Jun 04, 2004 3:44 pm
by jinksys
I found the problem, I forgot the bios moves the code to 0:07C0h.
I didnt set the DS appropriately. Now it works.

Could someone tell me if this is correct?

mov $label, %eax // loads address of label into eax
mov label, %eax // loads value from label's address into eax

because I know pushl $label , pushes the address of label onto
the stack, and pushl label, pushes the value of label onto the stack.