flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar
Again that very common error: you are putting your data at the beginning of program and it gets executed then.
|
|||
![]() |
|
prana
Sorry for the late reply.
Privalov, I couldn't get you! Could you please explain a little on my two questions? Thanks. |
|||
![]() |
|
BiDark
just insert a jump to prevent the data to be executed like this.
Code: org 100h jmp @f a db '!','b','c' @@: mov cl,3 loopcx: mov ah,2 mov dl,[a] int 21h inc [a] loopnz loopcx mov ax,4C00h int 21h Or it would be better if you could declare the data at the end of code. Last edited by BiDark on 26 Sep 2003, 05:38; edited 1 time in total |
|||
![]() |
|
Tommy
You should declare data at the end of your program. Such as:
Code: org 100h mov cl,3 loopcx: mov ah,2 mov dl,[a] int 21h inc [a] loopnz loopcx mov ax,4C00h int 21h a db '!','b','c' You see? Else, you have to jump over the data: Code: org 100h jmp data_end a db '!','b','c' data_end: ... Got it? Regards, Tommy |
|||
![]() |
|
prana
Thanks Tommy for answering.
Cut and pasted your code and the result is: D:\fasmd\EXAMPLES>ex1 !"# D:\fasmd\EXAMPLES> Instead of !bc. What's went wrong? |
|||
![]() |
|
Tomasz Grysztar
You are increasing the first byte of string at "a" label with
Code: inc [a] instruction, and this is the only character you are displaying. If you wanted to display all characters of your string, you have to increase address from which you are reading, for example: Code: mov bx,a loopcx: mov ah,2 mov dl,[bx] int 21h inc bx loopnz loopcx |
|||
![]() |
|
prana
Ok, I understand that the line
inc [a] increments the ASCII content of 'a' and hence the result. I've figured out the correct code with all of your help: Code: org 100h jmp @f a db '!','b','c' @@: mov cl,3 xor ch,ch mov bx,a _loop: mov dl,[bx] mov ah,2 int 21h inc bx loopnz _loop xor ah,ah int 16h mov ax,4C00h int 21h Thanks! |
|||
![]() |
|
prana
I've taken the following code from another thread and modified it a bit:
_____________________________________________ Code: org 100h jmp @f _table db '!','b','c' _msg db 'Enter your name: ',24h _greet1 db 13,10,'Hello, ',24h _greet2 db '!!!',13,10,24h _buffer db 80h,0 rb 80h _lenmsg1 db 13,10,'You have entered ' _lenmsg2 db 0 _lenmsg3 db ' charcters.',24h @@: mov dx,_msg mov ah,9 int 21h mov dx,_buffer mov ah,0Ah int 21h mov dl,[_buffer+1] add dl,'0' mov [_lenmsg2],dl mov dx,_lenmsg1 mov ah,9 int 21h mov cl,[_buffer+1] xor ch,ch mov bx,_buffer+2 _loop: mov dl,[bx] mov ah,2 int 21h inc bx loopnz _loop xor ah,ah int 16h mov ax,4C00h int 21h ______________________________________________________________ My question is that can I modify the following lines Code: mov dl,[_buffer+1] add dl,'0' mov [_lenmsg2],dl in some better way? This takes a total of 261 b now. Could you please help? |
|||
![]() |
|
prana
Could someone help me here on this?
Thanks. |
|||
![]() |
|
wanderer
prana wrote: My question is that can I modify the following lines What are you trying to achieve by this? If you want less size you can just move you variables to the end of the program and place these lines Code: _buffer db 80h,0 rb 80h at the very end. _________________ Best regards, Antoch Victor |
|||
![]() |
|
wanderer
In fact, here is version I tryed to make as short as possible:
Code: org 100h mov dx,_msg mov ah,9 int 21h mov dx,_buffer mov ah,0Ah int 21h mov si,_buffer+1 xor bx, bx mov bl,[si] mov word [si+bx+2], 240ah ; place 0ah, '$' after 0dh in buffer add bl,'0' mov [_lenmsg2],bl mov dx,_lenmsg1 mov ah,9 int 21h mov ah,9 mov dx,_buffer+2 int 21h xor ah,ah int 16h ret _msg db 'Enter your name: ',24h _lenmsg1 db 13,10,'You have entered ' _lenmsg2 db ' ' _lenmsg3 db ' characters: ',24h _buffer db 10,0 rb 10h _________________ Best regards, Antoch Victor |
|||
![]() |
|
prana
Thanks a lot Victor.
I am sorry, to answer so late. Thanks again. |
|||
![]() |
|
wanderer
Not at all, you're welcome.
_________________ Best regards, Antoch Victor |
|||
![]() |
|
OzzY
What is the 'rb' in the code posted by wanderer??
|
|||
![]() |
|
wanderer
rb means reserve byte. The same as "db 10h dup(?)" in masm and tasm. To say the truth I just realized, that it's not necessary at all here and is probably thrown away by fasm.
_________________ Best regards, Antoch Victor |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.