write message to screen in AT&T assembly
I'm attemping to write my own bootloader and i'm having issues with writing to the screen. I've found examples using interrupts:
; ---------------------------------------------------------
; Main program
; ---------------------------------------------------------
mov si, msg ; Print message
call putstr
hang: jmp hang ; Hang!
; ---------------------------------------------------------
; Functions and va开发者_如何学运维riables used by our bootstrap
; ----------------------------------------------------------
msg db 'Hello Cyberspace!', 0
; Print a 0-terminated string on the screen
putstr:
lodsb ; AL = [DS:SI]
or al,al ; Set zero flag if al=0
jz .done ; Jump to .done if zero flag is set
mov ah,0x0E ; Video function 0Eh
mov bx,0x0007 ; Color
int 0x10
jmp putstr ; Load characters until AL=0
.done:
retn
however this is in Intel assembly format. When i attempt to convert to AT&T the opcodes themself are easy to flip but I cant figure out how to declare the message.
as it is I can not use the line
msg db "my string",0
as thats Intel. but if i try to convert it to a simliaraly formed AT&T code such as
msg .byte "test"
I cant assemble it. I have tried assembling with the linux "as" and "nasm"
does anyone know how i declare a string in AT&T format assembly?
Try :
msg: .asciz "test"
There is also .ascii , for without the null terminator.
What version of nasm are you using? On my linux box with nasm 2.03.01 your example (with 'msg db "my string", 0') assembled fine.
Also, according to the nasm doc it seems that 'db' is the correct usage.
精彩评论