Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASM
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 Smile | :)
Any examples or code snippets in 16 bit would be appreciable.
Posted 28-Mar-13 12:42pm
Edited 28-Mar-13 12:48pm
v2
Comments
Sergey Alexandrovich Kryukov at 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
ThePhantomUpvoter at 28-Mar-13 17:46pm
   
What does "something is really going wrong" mean?
Zerr0cool at 28-Mar-13 17:50pm
   
it is 8086 real mode
Sergey Alexandrovich Kryukov at 28-Mar-13 18:06pm
   
Now, OS/Platform?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 195
1 Afzaal Ahmad Zeeshan 132
2 ProgramFOX 130
3 Maciej Los 105
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100