newbie question on gnu 'as' => explaination about the why (for really newbie ;-))
Hi Frederic ,
Thanks again .
Let me do some more investigation and
study before I ask anymore questions on
AT&T syntax and Assembly .
With Best Regards
--- Frederic Marmond <[email protected]> wrote: >
hum, well...
Quoted 526 lines
I don't use the AT&T syntax, so, I may be wrong, but I think your code
is not right again:
you don't specify any segment! (only the bx register)
So, how do you think the CPU will know where to put your0x411f?
You have to specify the segment after having fill it with a value.
movw 0xb800,%bx
movw %bx,%ds
movw $0x411f,(%bx) <= I'm not sure (perhapse
a AT&T guru may help us)
Here, we
assume that DS is
the default segment token by the as compilerif I take your origin-code:
mov ax,#0xb800 ; Video Memory address is
0xb800
mov es,ax ; Video Memory is made as
Extra Segment
seg es ; Makes next instruction
execute wrt Extra Segmentmov [0],#0x41 ; ASCII value of the Characterto be displayed
; in 1-row & 1-column
seg es ; Makes next instruction
execute wrt Extra Segmentmov [1],#0x1f ; Attribute of the Character to be displayed ; in 1-row & 1-column ; 0x1f represents WhiteThe "seg es" lines are what we need.
I think that by default, 'ds' is used, so, my 3
lines of code may work.in this:
6> movw $0xb800,%bx # Video Memory address 7> movb $0x41,(%bx) # ASCII value to 8> movw $0xb801,%bx # Video Memory address9> movb $0x1f,(%bx) # Attribute of the
you will put
0x411fat [ds:0xb800], which is somewhere around your
program code... it will surely erase something you may need (perhapse
your code!)Quoted 48 lines · Anticipating a Reply
Hi Frederic ,
Thank you very much for all the
explanation you have given about the addressing in 16-bit real mode .From this explanation , I think
I was wrong in line number 7 , which had0xb800acting as an offset to the Data Segment .That is,if I'am not wrong we
always need to specify the addresses in the below format -seg_reg:offset
----
OR
----
if given asmovb $xxx , ( %seg_reg )
then the contents of "
seg_reg" will be considered as an Offset with respect to the Data Segment.1> .code16
2>
3> .globl_start
4>
5>_start:
6> movw $0xb800,%bx # Video Memory address7> movb $0x41,(%bx) # ASCII value to 8> movw $0xb801,%bx # Video Memory address9> movb $0x1f,(%bx) # Attribute of the
10> loop1:
11> jmp loop1Hope I have got the concept correctly .
Thanking you all for bearing my basic
doubts and clearing them too.Quoted 12 lines
With best Regards
--- Frederic Marmond <[email protected]> wrote:
Hi,
Quoted 4 lines
Here are some explainations you may want to know.
When your PC boots, it is in real mode.
This mode (!= protected mode) manage memory inthis
Quoted 10 lines
Quoted 10 lines
way:
segment+offset
The segment is a 64ko range , step by 16 bytes.
So, if you want to write to b8000 (video memory
start in text mode), you
may set your segment at0xb800(=>0xb800* 16 =0xb8000)
Then, you can adress this segment of 65536 bytes
with an offset of 16bits.
(that's why in real mode you can only see thefirst
Quoted 10 lines
Quoted 10 lines
1Mo of your memory:
0xFFFF*16 =0xFFFF0~= 1024*1024 (in fact, a
little bit more than 1Mo,
because of the offset of0xffffmax))
For your problem, in pseudo code:
mov0x411fto 0xb800:0 (write0x411fto the
corner high-left)
mov0x411fto 0xb800:(80*2 *10+ 20*2) (write0x411fto the 10th line
(80*2 *10= 80(charPerLine)*2(1char=ascii+attribut)
Quoted 23 lines
Quoted 23 lines
*10(10th line)) and
20th char)in assembly, segments are stored in special
registers: ds (Data
Segment), CS(Code Segment), Es,Fs,Gs (Extra
Segments), SS(Stack Segment)
Offset may be any of the followings
(Ax,Bx,Cx,Dx,Si,Di,Sp). (and, in
32bits mode: eAx,eBx,eCx....)So, the pseudo code may be write like that ((in
intel syntax, which I
prefer, and that compile with nasm):
mov ax,0xb800
mov es,ax ; we cannot affect
directly value to seg
register (cannot write mov es,0xb800)
mov bx,0x0 ; start of the segment
mov [es:bx],0x411f ;the compilator will
assume automaticaly movw
(mov word => 16 bits)Quoted 6 lines
Quoted 6 lines
That is what Emanuele wrote you (in At&t syntax):
movw $0xB800, %ax
movw %ax, %es ; affect the start
adress to the segmentmovb $0x41, %es:0 ; store valuein
Quoted 2 lines
Quoted 2 lines
the video memory
movb $0x1f, %es:1 ; these 2lines
Quoted 53 lines
Quoted 53 lines
may be = to movw $0x411f,%es:0
hope it helps!
Fred
Quoted 11 lines · Anticipating a Reply
Hello Emanuele ,
Thank you for the below code
you sent . It works perfectly and
will help me learn more of assembly .Can you please help me figure
out where I'am wrong in the code below,
which I have witten for the same
functionality .Quoted 9 lines
.code16
.globl
_start
_start:movw $0xb800,%bx # Video Memory address movb $0x41,(%bx) # ASCII value to bedisplayed
Quoted 5 lines
movw $0xb801,%bx # Video Memory address movb $0x1f,(%bx) # Attribute of theCharacter
Quoted 11 lines
loop1:
jmp loop1Thanks once again .
With Best Regards
--- Emanuele Altieri <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines · wrote:
Quoted 5 lines
I'm assuming that you want to keep your code as
a
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
boot program:
.code16 # needed for
booting
.global_start
_start:movw $0xB800, %ax movw %ax, %es movb $0x41, %es:0 movb $0x1f, %es:1 loop1: jmp loop1Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
To assembly and link the program:
as -o boot.o boot.s
ld -s -oformat binary -Ttext0x0-o bootboot.o
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
The last command creates the "boot" file that is
ready to be
installed in the first sector of the floppydisk:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
dd seek=0 if=boot of=/dev/fd0
Hope this helps
-Emanuele
On Tue, 2002-07-30 at 07:59, Anticipating a
Reply
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines · wrote:
Hi Everybody,
I have got a small piece of Assembly
code
Quoted 123 lines
Quoted 93 lines
Quoted 93 lines
Quoted 93 lines
Quoted 4 lines
,
Quoted 22 lines
which writes a character "A" on the screen .
The below program is compiled and written to the boot sector of a floppy. It compiles using the command :
as86 boot.s -o boot.o
ld86 -d boot.o -o bootI want to rewrite it in AT&T syntax and
want to use GNU "as" assembler to compile it . I tried doing it ,but with no success .Can anybody please help me rewite the below code in AT&T syntax and tell me how to compile & link it ?
Thanks in Advance .
With Best Regards
Quoted 12 lines
THE CODE :
------------entry start
start:
mov ax,#0xb800 ; Video Memory address is
0xb800Quoted 6 lines
mov es,ax ; Video Memory is made as
Extra
Quoted 6 lines
Segment
seg es ; Makes next instructionexecute
Quoted 6 lines
wrt Extra Segment
mov [0],#0x41 ; ASCII value of theCharacter
Quoted 7 lines
to be displayed
; in 1-row & 1-column
seg es ; Makes next instructionexecute
Quoted 29 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
wrt Extra Segment
mov [1],#0x1f ; Attribute of theCharacter
Quoted 22 lines
Quoted 22 lines
Quoted 4 lines
to
Quoted 13 lines
be displayed
; in 1-row & 1-column ; 0x1f represents WhiteCharacter on a Blue Background
loop1:
jmp loop1Quoted 64 lines
________________________________________________________________________
Quoted 63 lines
Quoted 23 lines
Quoted 23 lines
Quoted 11 lines
Want to sell your car? advertise on Yahoo Autos
Classifieds. It's Free!!
Quoted 7 lines
visit http://in.autos.yahoo.com
-
To unsubscribe from this list: send the lineQuoted 8 lines
Quoted 8 lines
"unsubscribe linux-assembly" in
Quoted 3 lines
the body of a message to
Quoted 17 lines
Quoted 17 lines
Quoted 5 lines
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Quoted 5 lines
# boot.sQuoted 7 lines
Quoted 7 lines
#
# To assembly and link as a **boot** program:
#
# as boot.s -o boot.o
# ld -s -oformat binary -Ttext0x0-o bootboot.o
Quoted 2 lines
Quoted 2 lines
#
# To copy it to the boot sector of a floppydisk:
Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
#
# dd seek=0 if=boot of=/dev/fd0
#
# ---
# Emanuele ([email protected])Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
.code16 .global _start _start: movw $0xB800, %ax movw %ax, %esQuoted 8 lines
Quoted 8 lines
movb $0x41, %es:0 movb $0x1f, %es:1loop1: jmp loop1
Quoted 18 lines
________________________________________________________________________
Quoted 17 lines
Quoted 5 lines
Want to sell your car? advertise on Yahoo Autos
Classifieds. It's Free!!
Quoted 5 lines
visit http://in.autos.yahoo.com
-
To unsubscribe from this list: send the line"unsubscribe linux-assembly" in
Quoted 1 line
the body of a message to
Quoted 18 lines
Quoted 18 lines
Quoted 3 lines
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Quoted 4 lines
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to [email protected] More majordomo info at
Quoted 13 lines
Quoted 2 lines
________________________________________________________________________
Quoted 1 line
Want to sell your car? advertise on Yahoo Autos
Classifieds. It's Free!!
Quoted 4 lines
________________________________________________________________________
Want to sell your car? advertise on Yahoo Autos Classifieds. It's Free!!
visit http://in.autos.yahoo.com