LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-21-2005, 07:43 AM   #1
doron_bl
LQ Newbie
 
Registered: Aug 2005
Posts: 2

Rep: Reputation: 0
Printing to screen using AT&T assembly syntax


Hi there,

I'm trying to build a bootsector. I want the bootsector to print some letter on the screen. For that I'm using GAS assembly and writen the following code:

.global _start
_start:
mov 0xb800, %ax
mov %ax, %es
movb $0x41, %es:0
movb $0x1f, %es:1

loop1: jmp loop1


For some reason this doesn't work. I'm trying to run it using Bochs and using rebooting of my machine, both give the same result - Nada !

Can someone please help me and show me some code that really works ? That will be great !

Thanks,
doron
 
Old 08-22-2005, 09:15 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
loop1: jmp loop1
are you sure you want to jump to the same line over and over again?
___________

this *may* be a reason why:

Quote:
mov 0xb800, %ax
your moving 2 bytes to register ax (how big is a register). try a move word?

~schneidz

Last edited by schneidz; 08-22-2005 at 09:31 AM.
 
Old 08-30-2005, 01:00 AM   #3
doron_bl
LQ Newbie
 
Registered: Aug 2005
Posts: 2

Original Poster
Rep: Reputation: 0
Hi All
After almost two weeks, I've found the solution.
The problem was that I had to include .code16 directive at the top of the code so the compiler will compile it in a 16bit mode

Here is the final code plus the compiler and linker commands I've used

file: bootsect.s:

.code16

.global _start
_start:
xor %ax, %ax
mov $0xb800, %ax
movw %ax, %es
movb $0x41, %es:0
movb $0x1f, %es:1

loop1: jmp loop1



as -o bootsect.o bootsect.s
ld -Ttext 0x7C00 -Tdata 0x7C00 --oformat binary bootsect.o -o bootsect.binary

Yes folks thats it, thats what took me about two weeks !!!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help!! loading up GDT (switching to protected mode) assembly AT&T syntax aXoneX Programming 14 07-17-2004 03:55 PM
Help with switching to protected mode GDT AT&T assembly!!!! aXoneX Linux - General 0 07-15-2004 09:36 PM
C & Assembly question eantoranz Programming 3 04-23-2004 01:18 PM
Assembly syntax jinksys Programming 1 09-01-2003 05:07 PM
how to turn OFF syntax highlights when printing? PTBmilo Linux - Software 3 03-18-2003 12:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration