Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,577 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,894 people online right now. Registration is fast and FREE... Join Now!




Help About Assembly Input and Output on Screen

 
Reply to this topicStart new topic

Help About Assembly Input and Output on Screen, How to display " Hello World " , my program prints a black s

marckiestar
25 Sep, 2008 - 09:13 PM
Post #1

New D.I.C Head
*

Joined: 21 Aug, 2007
Posts: 21



Thanked: 1 times
My Contributions
[b]Hi ! If you have time, please take a look at my sample program.
I wrote it below, I'm trying to print the " Hello World " Stateement , It seems that my code is correct but doesn't display any, it's just some kind of a black screen...

Can you evaluate this one?
Just use this code, don't make any programs anymore, just edit it.

And can you please put comments on your modifications? I'm new with assembly, some programming languages I know are , C++ and Java. I couldn't really cope up with Assembly.

This is it.....
CODE
; My code, can't get it, it doesn't display the text

       DOSSEG
       .MODEL SMALL
       .STACK 200H
       .DATA

hello    db  "Hello World"

; I wrote this for clear screen
.CODE
CLRSCR  PROC
        push ax
        mov ah,00h
        mov al, 03h
        int 10h
        pop ax
        ret
CLRSCR  ENDP
          
; For printing output
PRINTF  PROC
        push ax
        mov ah, 09h
        int 21h
        pop ax
        ret
PRINTF  ENDP
;for takin input
SCANF   PROC
        push ax
        mov ah,0ah
        int 21h
        pop ax
        ret
SCANF   ENDP




BEGIN: MOV AX, @DATA
       MOV DS, AX
       MOV ES, AX

; CLEAR SCREEN
       call CLRSCR


; supposed to be this will print " Hello World "
  lea dx, hello
       call PRINTF


       END BEGIN




What do you think about it? Is my logic correct?

User is offlineProfile CardPM
+Quote Post

fremgenc
RE: Help About Assembly Input And Output On Screen
25 Sep, 2008 - 10:04 PM
Post #2

New D.I.C Head
*

Joined: 15 Nov, 2007
Posts: 20


My Contributions
CODE

;to get a char from dos input
;call the macro from your .code section
;  save ch in an array until a terminating character of your choice is hit

getchar macro ch
    push ax
        mov ah,1h
        int 21h
        mov ch, al
        pop ax
        endm


;printing a string of type word to DOS
printstr macro  xxx
        push ax
    push dx

        mov dx,offset xxx
        mov ah, 9h
        int 21h

        pop ax
        pop dx
        endm


User is offlineProfile CardPM
+Quote Post

David W
RE: Help About Assembly Input And Output On Screen
4 Oct, 2008 - 05:45 AM
Post #3

D.I.C Regular
Group Icon

Joined: 20 Sep, 2008
Posts: 315



Thanked: 16 times
Dream Kudos: 275
My Contributions
Hey ... how about moving up to 32 bits and a nice High Level Assembly Language like HLA .... ?

Here is the code for your HW.hla first program

CODE
program HelloWorld;

#include( "stdlib.hhf" )

static
   last: string;
   first: string;

begin HelloWorld;

   stdout.put( "Hello! Nice HLA assembly language eh Mate?" );
   stdout.put( nl, nl, "What is your last name ? ");
   stdin.a_gets(); //allocates memory for string at address returned in eax
   mov( eax, last ); //now 'last' holds the address of the string
   stdout.put( "What is your first name ? ");
   stdin.a_gets();
   mov( eax, first );
   stdout.put( "Are you really ", first, " ", last, "?", nl, nl );

   stdout.put( "Press 'Enter' to continue ... " );
   stdin.readLn();
  
   str.free( first ); //To free the above allocated memory for the strings
   str.free( last ); //NOTE: stdin.a_gets() allocated dynamic memory

end HelloWorld;


This post has been edited by David W: 4 Oct, 2008 - 06:10 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:16AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month