Click here to Skip to main content
15,881,616 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
As a very beginner to assembly language all I am trying to do is to access a globally declared string in assembly program and print its content character by character( for now i m trying to print only first character...for testing purpose) but something is really going wrong. Could you please guide me.

Environment: nasm, 16 bit, Intel X86, flat assembler

Code snippet for your reference.
Please note that I have not pasted the entire code for your reference. Its only the subroutine part that I know something is wrong.
MsgX: db "Hello World!", 0x00

prints:
   push bp
   mov  bp, sp
   sub  sp, 2

   push word MsgX
   mov  bx, [bp-2]
   mov  al, byte [bx]
   mov  ah, 0x000E
   int  0x0010
ret

main:
   call prints


Please help :)
Any examples or code snippets in 16 bit would be appreciable.
Posted
Updated 28-Mar-13 11:48am
v2
Comments
Sergey Alexandrovich Kryukov 28-Mar-13 17:46pm    
From your previous question, you still did not answer: what's the OS? You said the the flat model is used, but it does not look so (perhaps you are not familiar with the flat model or its detail, it's only in protected mode). Is it 8086 real-mode (or compatible, real mode)?
—SA
[no name] 28-Mar-13 17:46pm    
What does "something is really going wrong" mean?
[no name] 28-Mar-13 17:50pm    
it is 8086 real mode
Sergey Alexandrovich Kryukov 28-Mar-13 18:06pm    
Now, OS/Platform?
—SA

1 solution

This is the solution for real mode, DOS (required to use int 0x21, which is the DOS "system call"): http://montcs.bloomu.edu/Code/Asm.and.C/Asm.Nasm/hello-in-assembly.shtml[^].

If this is not it, please provide further detail on your platform; please see my comment to the question.

You could do a lot of calculations based on just the CPU model information and memory model used (for Intel, for example), in a way agnostic to the platform, but you cannot do it if I/O is involved, such as screen output. For example, the code referenced above won't work in Windows/*NIX and the like, unless you use some kind of emulator of virtual PC solution. With DOS, for example, you could use either use the system service software interrupt "call", or directly access video memory in its text or video mode. Both ways would depend on platform information.

This is not your first question on assembly programming, but you still did not provide comprehensive information.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900