Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 20th, 2006, 8:55 AM   #31
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
You've commented out all of your labels. There's a reason the code I posted follows this theme:
org 100h
jmp start

; Data definitions here

start:
        ; Executable code here
If you don't jump over the data definitions, they'll be treated as executable instructions, which very rarely works. Also, since you're treating snum as a byte string, you should use db instead of dw. You want something more like this:
org	100h
jmp	start

save db 4 dup '$'
snum db "Enter second$"

start:
	mov	ah,09
	mov	dx,snum
	int	21h

	mov	ax,04C00h
	int	21h
You can also place your data definitions after the executable code and save yourself the trouble, if you want:
org	100h

	mov	ah,09
	mov	dx,snum
	int	21h

	mov	ax,04C00h
	int	21h

save db 4 dup '$'
snum db "Enter second$"
Now it's a moot issue because you terminate the program before IP gets to the data definitions. By the way, one trick you may have noticed to save yourself two mov's at the end is to mov a two byte value to ax rather than splitting it up into two mov's of one byte to ah and al.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old May 20th, 2006, 8:57 AM   #32
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by kruptof
but i keep an dialog boxes with an error on it (i have attached the image of this) do you know what this means Narue and if so can you please explain it to me
It means you mucked something up. That little window tells you (in this order) the code segment (which is essentially meaningless to you, since it's just an index into a descriptor table), the instruction pointer (ie, address within the segment where the Bad Thing happened), and the actual bytes of the instruction (which you can decode if you have the right references handy). Since my references are at home, and I'm not right now, I can't be much more help than that.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old May 20th, 2006, 9:54 AM   #33
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
oh i see so the the first line in my code should always be executable instruction.....another thing you have taught me......................lectricpharaoh.............i read your post and i looked at the error message again and this time i have noticed the error message contained the words IP(Instruction Pointer) and the CS (Code Segment)...........thanks i didn't see that before.
kruptof is offline   Reply With Quote
Old May 20th, 2006, 10:50 AM   #34
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
when i try to run this code below i keep getting an error saying a "byte or a word". why is this, didn't i already say that these two variables are both bytes by saying define bite (db), or is this error sayingg what do you want to move a byte or a word.if so how can i move a word if both of the variabes are a byte long.

Here is the code:
Quote:
;mov dummy,num1;<-----this is the line where i receive the error ;specified above
mov ah,04Ch
mov al,00
int 21h
num1 db 4 dup'$'
dummy db 4 dup'$'
kruptof is offline   Reply With Quote
Old May 20th, 2006, 2:11 PM   #35
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by kruptof
when i try to run this code below i keep getting an error saying a "byte or a word". why is this, didn't i already say that these two variables are both bytes by saying define bite (db), or is this error sayingg what do you want to move a byte or a word.if so how can i move a word if both of the variabes are a byte long.

Here is the code:
You can't do memory-to-memory operations on Intel CPUs, except for a few cases, such as movs (move string, not the plural of MOV). You need to move it into a register from the source memory location, then from that register to the destination memory location:
mov ah, num1
mov dummy, ah
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old May 20th, 2006, 2:28 PM   #36
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
oh...............thanks i understand now..............another question...........how do i move whats inside my save variable into a register such as ax register because when i do
Quote:
mov ax,save
i keep getting an error
kruptof is offline   Reply With Quote
Old May 21st, 2006, 8:32 AM   #37
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by kruptof
oh...............thanks i understand now..............another question...........how do i move whats inside my save variable into a register such as ax register because when i do
i keep getting an error
Assuming save is a memory word to which you have read access, this should not be a problem. Double-check your code and make sure it is declared as such (you may need to use an override, like word ptr save). You may be referencing the address rather than the value at the address, depending on your assembler (for example, in NASM, memory references are enclosed in brackets; without the brackets, it would be semantically the same as mov ax, offset save is in TASM/MASM, which is almost certainly not what you want). Lastly, be sure you're not clobbering a register you shouldn't be. This is a concern when using certain APIs, or interfacing with higher-level languages, though it's almost universally safe to clobber EAX and its smaller components.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:13 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC