flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > DOS > [trying execute data] can't store a char in db?

Author
Thread Post new topic Reply to topic
theguy



Joined: 22 Jan 2015
Posts: 10
[trying execute data] can't store a char in db?
I've looked online and all the examples that i come across(code listed below) say to do this?


Code:
db 'y'



This will compile but when i try to run the exe it says "NTVDM.EXE has stopped working" and i have to close it, it only happens if i add the code.

In case your wondering what code i have wrote here it is.


Code:
org 100h

db 'y'

Looop:
jmp Looop



The bare minimum to test "db 'y' " as code is all i wrote.
Post 22 Jan 2015, 11:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15235
Location: 1I/ʻOumuamua
COM files begin execution at the very first byte. For your code above the first instruction to be executed to whatever 0x79 disassembles to.

If you want to display 'y' to the screen then you will need to write code to send the character 'y' to the OS to to get it displayed.

You placed this topic in the Windows forum so I don't know how to properly advise because you posted DOS code. If you can confirm whether you want Windows code or DOS code then we can help you better.
Post 22 Jan 2015, 12:00
View user's profile Send private message Visit poster's website Reply with quote
theguy



Joined: 22 Jan 2015
Posts: 10
oops sorry about posting in the wrong forum, yea i'm working with a dos console program.

this code works perfectly fine.


Code:

org 100h 

Looop
jmp Looop




It just loops and doesn't crash but when i add the db 'y' in the code it will crash and i won't be able to print a char to screen if i can't first store it.
Post 22 Jan 2015, 12:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15235
Location: 1I/ʻOumuamua
Store the character below the code:

Code:
org 100h 

Looop
jmp Looop

db 'y'

Post 22 Jan 2015, 12:16
View user's profile Send private message Visit poster's website Reply with quote
theguy



Joined: 22 Jan 2015
Posts: 10
Well that worked! thanks, it's kind of weird because i was following a guy who wrote his code the way i showed you, and it worked for him but maybe it's because he's using linux.
Post 22 Jan 2015, 12:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15235
Location: 1I/ʻOumuamua
Even in DOS you can put your data and strings first if you use an EXE format. You also have to tell the assembler where the first instruction is so that the EXE file can tell the OS how to run the code.

It is the COM format that requires the first instruction to be at the beginning of the file. So for you the first instruction was 'y' (0x79, ...) which is clearly not what you wanted.
Post 22 Jan 2015, 12:29
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.