When I shorten the string, it sometimes works, when I make them longer again Sometimes it works.
I don’t know why this doesn’t work.
Can anyone help me?
Thank you.
The assembly code I am using is:
(Emacs 23,Ubuntu 10.10,nasm,VirtualBox OSE)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 0x7c00
bits 16
str:
db "Some say the world will end in fire",10,13
db "Some say in ice",10 ,13
db "From what I've tasted of desire",10,13
db "I hold with those who favor fire",10,13
db "But if I had to perish twice,",10,13
db "I think I know enough of hate",10,13
db "To say that for destruction ice",10,13
db "is also great and would suffice."
db "Robert Frost-Fire and Ice"
db 0
start:
xor ax,ax
mov ds,ax
mov es,ax
mov si, str
xor bx,bx
mov ah, 0x0e
print:
lodsb ;al = current char
cmp al, 0
je end
int 0x10
jmp print
end:
cli
hlt
times 510-( $-$$) db 0
dw 0xAA55
;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
< p>You should add a jmp instruction before the string so that it jumps to start.
This is usually a short jump EB xx followed by NOP 90. Some BIOS may insist that this form is even It is not important to the processor.
In other words, you will find something like:
org 0x7c00
bits 16< br />realstart:
jmp short start
nop
str:
db "Some say the world will end in fire",10,13
:
db "Robert Frost-Fire and Ice"
db 0
start:
xor ax,ax
:
Please remember that short jumps are limited Yes, how far it can go, about / -128 bytes, so your string size is bound to be limited. If your BIOS does not require EB xx 90 format, you can just perform regular jumps.
Another thing you can try is to move the entire string after the hlt instruction:
org 0x7c00
bits 16
start:
xor ax,ax
:
end:
cli
hlt
str:
db "Some say the world will end in fire",10 ,13
:
db "Robert Frost-Fire and Ice"
db 0
However, it depends on your BIOS that does not require jmp/nop at the beginning Combination.
My expectation is that it prints a A string, but it didn’t print.
When I shorten the string, it sometimes works, and when I make them longer again, it sometimes works.
I don’t know why this doesn’t work.
Can anyone help me?
Thank you.
The assembly code I am using is:
(Emacs 23,Ubuntu 10.10,nasm,VirtualBox OSE)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 0x7c00
bits 16
str:
db "Some say the world will end in fire",10,13
db "Some say in ice",10 ,13
db "From what I've tasted of desire",10,13
db "I hold with those who favor fire",10,13
db "But if I had to perish twice,",10,13
db "I think I know enough of hate",10,13
db "To say that for destruction ice",10,13
db "is also great and would suffice."
db "Robert Frost-Fire and Ice"
db 0
start:
xor ax,ax
mov ds,ax
mov es,ax
mov si, str
xor bx,bx
mov ah, 0x0e
print:
lodsb ;al = current char
cmp al, 0
je end
int 0x10
jmp print
end:
cli
hlt
times 510-( $-$$) db 0
dw 0xAA55
;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Because it starts executing code at the instruction of 7c00. Then unfortunately you have your string.
You should add a jmp instruction before the string so that It jumps to start.
This is usually a short jump EB xx followed by NOP 90. Some BIOS may insist that this form is not important even for the processor.
In other words, you will find something like:
org 0x7c00
bits 16
realstart:
jmp short start
nop
str:
db "Some say the world will end in fire",10,13
:
db "Robert Frost-Fire and Ice"
db 0
start:
xor ax,ax
:
Remember that the short jump is limited, how far it can go, about / -128 bytes, so The size of your string is bound to be limited. If your BIOS does not require the EB xx 90 format, you can just make a regular jump.
Another thing you can try is to move the entire string to After the hlt instruction:
org 0x7c00
bits 16
start:
xor ax,ax
:
end :
cli
hlt
str:
db "Some say the world will end in fire",10,13
:
db "Robert Frost- Fire and Ice"
db 0
However, it depends on your BIOS that does not require a jmp/nop combination at the beginning.