flat assembler
Message board for the users of flat assembler.
Index
> Main > How can DB contain string? |
Author |
|
roticv 14 Nov 2004, 12:33
The data in [variable] is byte size while the data in ax is word size. How can you move a 16bit value into a 8bit value? Of course the size does not match
The difference between a variable and a constant is that the value in a variable can change, but the value in the a constant is always the same. |
|||
14 Nov 2004, 12:33 |
|
Matrix 14 Nov 2004, 16:05
Hy again,
Code: org 256 ; originate variables and generate a com file mov dx,word [vart] ; now we will put $4421 in dx mov dx,string_byte_array ; this puts offset in for dos function mov ah,9 ; int 21h ah = 9h parameter int 21h int 20h ; exit vart db $21 db $44 string_byte_array: db 'Hello World!$' ; dos string terminator is '$', some use #0 , some are pascal typed beginning has lenght |
|||
14 Nov 2004, 16:05 |
|
Kristian_ 14 Nov 2004, 17:25
Thank you very much!
I have another question about labels! for example I want to test if var1 = var2, so I write this code: Code: org 256mov ah, 9mov ax, var1mov bx, var2cmp ax, bx ; if(ax == bx){je somelabel ; goto somelabel; } else {jmp end ; goto end; }somelabel: ; how can I know where does label ends?mov dx, trueint 21hint 20hend mov dx, falseint 21hint 20hvar1 db 1var2 db 1true db "TRUE$"false db "FALSE$" After I compile and execute this code, program like waits for something, when I press any key it goes back to command line! What is wrong? And how can I know where does label ends? And about fasm tutorials! I read this one from http://decard.net/ Where can I find more? Thank you! |
|||
14 Nov 2004, 17:25 |
|
ASHLEY4 14 Nov 2004, 17:47
Kristian_ wrote: Thank you very much! \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. |
|||
14 Nov 2004, 17:47 |
|
Kristian_ 14 Nov 2004, 21:49
Thank you!
But how does FASM know where does label ends? Isn't label something similar to macro? For example macro starts with { and after end of the macro body there is } What about label? Thank you! |
|||
14 Nov 2004, 21:49 |
|
ASHLEY4 15 Nov 2004, 00:25
You may be mix up labels, with proc, look here for info on how labels work in fasm.
http://www.decard.net/index.php?body=tajga&chapter=chap03 \\\\||//// (@@) ASHLEY4. Batteries not included, Some assembly required. |
|||
15 Nov 2004, 00:25 |
|
Matrix 15 Nov 2004, 20:20
to give an accurate and complete answer to your question: How can DB contain string?
db is not containing the string itself in any way db is a reserved word for assembler meaning : declare byte Code: db $33 ; declares 1 byte with value of 33h db $12,$13,$14,$15 ; declares 4 bytes with value of $12,$13,$14,$15 db 'Hello' ; declares a byte array, this character pattern will be db-ed into your code db 'Hello','$' ; declares a byte array, this character pattern will be db-ed into your code, you can also use , operator to start another array, or single byte like: db 'Hello',13,10,'$' ; this is a valid array, byte 13 10 are CR LF moves to beginning of next line, '$' is dos string terminator |
|||
15 Nov 2004, 20:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.