home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / SUPER_C.ZIP / EX.ASM < prev    next >
Encoding:
Assembly Source File  |  1980-01-01  |  1.7 KB  |  53 lines

  1. ;               Example Assembly Program
  2. ;
  3. ; This program simply prints "Hello, world!" It demonstrates all the 
  4. ; elements of an assembly language program.
  5.  
  6. ;
  7. ; Stack segment:
  8. ;
  9. stakseg segment stack           ; Define the stack segment
  10.  
  11.         db      20 dup ('stack   ') ; Fill it with "stack"
  12.  
  13. stakseg ends                    ; End of stack segment
  14.  
  15. ;
  16. ; Code segment:
  17. ;
  18. codeseg segment                 ; Define code segment
  19.  
  20.         assume  cs:codeseg, ds:codeseg ; Assume CS points to code segment
  21.  
  22. msg:    db      'Hello, world!',0DH,0AH,0
  23.  
  24. main    proc far                ; Main routine
  25.  
  26.         push    ds              ; Set up for return to DS:0, which will, in
  27.         xor     ax,ax           ;   turn, return us to DOS
  28.         push    ax
  29.  
  30.         mov     ax,codeseg      ; DS = codeseg
  31.         mov     ds,ax
  32.         mov     bx,offset msg   ; BX = &msg
  33.  
  34. loop:   mov     al,[bx]         ; AL = *BX
  35.         inc     bx              ; BX++
  36.         or      al,al           ; AL == 0?
  37.         jz      done            ; If yes, exit the loop
  38.         push    bx              ; Save BX
  39.         mov     ah,14           ; Tell ROM BIOS we want function 14, TTY write
  40.         mov     bl,3            ; Using an attribute of 3 (white on black)
  41.         int     10H             ; Call ROM BIOS video function TTY write
  42.         pop     bx              ; Restore BX
  43.         jmp     loop            ; Go do the next character in the string
  44.  
  45. done:   ret                     ; Return to DOS
  46.  
  47. main    endp                    ; End of main routine
  48.  
  49. codeseg ends                    ; End of code segment
  50.  
  51.         end     main            ; End of assembly code; start at main
  52.  
  53.