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
stuck on vga problem.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:stuck on vga problem.
$<somethin> is a litteral in AT&T. <something> is a memory reference.
So, for instance
will load ax with the value 0xA000 while
loads %ax with the memory word at offset 0xA000
I'm not ATT-guru enough to tell you what
but if you wanna be sure you loaded the *offset* rather than the content, just use LEA instead of MOV ...
So, for instance
Code: Select all
movw $0xa000,%ax
Code: Select all
movw 0xa000,%ax
I'm not ATT-guru enough to tell you what
Code: Select all
movw label,%ax
movw $label,%ax
Code: Select all
lea label,%ax
Re:stuck on vga problem.
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.
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.