flat assembler
Message board for the users of flat assembler.
Index
> Main > Effective memory addressing problem-Strings |
Author |
|
edfed 09 Feb 2008, 12:55
like you said
first byte to 0b8000h second to 0b8002h etc... an instruction is needed: mov |
|||
09 Feb 2008, 12:55 |
|
DJ Mauretto 09 Feb 2008, 13:26
Code: msg db 'Why u dont work?', 0 @Print: PUSH ES PUSH 0B800H ; Segment Memory Video XOR DI,DI POP ES MOV SI,msg ; Load OFFSET String @@: MOV AL,[SI] ; Load Byte From String OR AL,AL ; End Of String ? JZ @End MOV [ES:DI],AL ; Write Byte ADD DI,2 ADD SI,1 JMP @B @End: POP ES RET Note: On windows Xp console mode set video mode before to write, or make a dummy read using int 10h ah 0fh |
|||
09 Feb 2008, 13:26 |
|
vargadanis 09 Feb 2008, 13:52
Yeah.. it doesn't work. I used the exact same code here and there was no output for the code when i booted it up. I am getting angry at this whole asm thing.
I chkd out the video memory and it was a mess but not what we wanted... Let's go a little bit basic... How do I refer to the first byte of the msg? |
|||
09 Feb 2008, 13:52 |
|
DJ Mauretto 09 Feb 2008, 13:58
try this on xp or win 98 console mode
Code: ORG 100H MOV AX,0003H INT 10H CALL @Print XOR AX,AX INT 16H RET @Print: PUSH ES PUSH 0B800H ; Segment Memory Video XOR DI,DI POP ES MOV SI,msg ; Load OFFSET String @@: MOV AL,[SI] ; Load Byte From String OR AL,AL ; End Of String ? JZ @End MOV [ES:DI],AL ; Write Byte ADD DI,2 ADD SI,1 JMP @B @End: POP ES RET msg db 'Why u dont work?', 0 compile FASM msg.asm Please post your example |
|||
09 Feb 2008, 13:58 |
|
edfed 09 Feb 2008, 14:03
easy:
your message is at [data segment:msg]. the text screen is at 0b800h the first char is at [text screen:0] so, to put a char on the screen at boot: Code: org 7c00h mov ax,cs mov ds,ax mov ss,ax mov ax,0b800h mov es,ax mov si,msg mov di,0 mov ah,[color] @@: mov al,[si] cmp al,0 je @f inc si mov [es:di],ax add di,2 jmp @b @@: jmp $ msg db 'message to print at boot',0 colr db 71h ;blue text on grey background rb 510-($-$$) dw 0aa55h compile, copy to bootsector of a drive and reboot! |
|||
09 Feb 2008, 14:03 |
|
DJ Mauretto 09 Feb 2008, 14:10
You need a bootcode
I did not understand what you are trying to do, my code works fine ,but it is for dos,win98 or Xp |
|||
09 Feb 2008, 14:10 |
|
vargadanis 09 Feb 2008, 14:24
Is it important at all where the msg db is located? I mean in the end or in the beginning of the file? What does jmp $ exactly doing?
One more thing that I am not sure about (FASM syntax): how is it possible to jump to @f label if only @@-s are defined? |
|||
09 Feb 2008, 14:24 |
|
vargadanis 09 Feb 2008, 14:25
DJ Mauretto wrote: You need a bootcode That could be... sorry for being asxxxle |
|||
09 Feb 2008, 14:25 |
|
edfed 09 Feb 2008, 15:29
jmp $= jmp to jmp
it means: there: goto there for @@: if no @@: is defined after @f, it don't works. @f is the reference to the following @@:, the next one @b is a refenrence to @@: before. |
|||
09 Feb 2008, 15:29 |
|
vargadanis 09 Feb 2008, 15:40
smart I don't think there is such thing in NASM. I do stuff mostly in NASM but getting familiar with FASM as well. I really like the advanced syntax
|
|||
09 Feb 2008, 15:40 |
|
edfed 09 Feb 2008, 16:37
did you read the fasm.PDF file?
all is explained into. take one or two hours, read this, and begin the enjoyment. |
|||
09 Feb 2008, 16:37 |
|
vargadanis 10 Feb 2008, 12:39
U think that fasm is so much more enjoyable than any other? I am just wondering not accusing
|
|||
10 Feb 2008, 12:39 |
|
Alphonso 10 Feb 2008, 17:51
Something like..
Code: org 100h ;or format MZ push cs ; pop ds ;incase you want a .exe mov ax,0b800h ; mov es,ax ;Set up ES: for text mov ax,3 ; int 10h ;set up video mode for B800 mov si,msg ;Start of msg mov di,0 ;top left position on the screen mov ah,9fh ;background / foreground color mov cx,msg_len ;length of message @@: lodsb ;get byte in al from DS:SI and inc SI by 1 stosw ;store word in ax to ES:DI and inc DI by 2 loop @b ;Dec cx, jump to @@ until cx 0 mov ax,1 ; int 16h ;wait for keypress int 20h ;old style exit msg db 'Why u dont work?' msg_len=$-msg |
|||
10 Feb 2008, 17:51 |
|
vargadanis 10 Feb 2008, 19:38
Wow...
U did a really good job on commenting ur code which is to be honest very clean. Makes it enjoyable to read. |
|||
10 Feb 2008, 19:38 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.