Hi,

I am relatively new in ASM, so I need some help.

I found this code on the internet and made some modifications.

;**************************************************
; Hello World OS Boot loader
; Designed by Arnav
; http://pendorasoft.byethost15.com/
;**************************************************

[BITS 16]
[ORG 0x0000]

; code located at 0000:7C00, adjust segment registers
          cli
          mov     ax, 0x07C0
          mov     ds, ax
          mov     es, ax
          mov     fs, ax
          mov     gs, ax

; create stack
          mov     ax, 0x0000
          mov     ss, ax
          mov     sp, 0xFFFF
          sti

; post message
          mov     si,msgHello
          call    DisplayMessage
          mov     si,msgName
          call    DisplayMessage
          hlt  
   

; Display Message
DisplayMessage:
          lodsb                                       ; load next character
          or      al, al                              ; test for NUL character
          jz      .DONE
          mov     ah, 0x0E                            ; BIOS teletype
          mov     bh, 0x00                            ; display page 0
          mov     bl, 0x07                            ; text attribute
          int     0x10                                ; invoke BIOS
          jmp     DisplayMessage
     .DONE:
          ret          
          
; data section
msgHello  db 0x0D, 0x0A, "Hello World!", 0x0D, 0x0A, 0x00   
msgName  db 0x0D, 0x0A, "What`s your name", 0x0D, 0x0A, 0x00                  
          
;ASM Signature
          TIMES 510-($-$$) DB 0
          DW 0xAA55

It`s output is:

Hello World!
What`s your name?

Now I`d like to be able to get the user input and to say "Hello, [the user input]."

For example, if the user input is "John", then the program prints "Hello, John."

Any suggestions appreciated.

Hi,

obviously your asm is real mode (because of int 10H (= 0x10) then the code for inputting a string terminated by enter key (0DH) could be:

maxleng equ 100 ; maxleng of inbuffer is 100 chars ;;; not knowing EQU? then replace maxleng of inbuffer by 100.

inbuffer db maxleng, ?, maxleng dup(?)     ;;; defines special buffer for int 21h/0AH function

;;; 0AH require offset of special buffer in dx
mov dx, offset inbuffer 
mov ah, 0ah
int 21h      ;;; read string, if input length exceeds inbuffer[0] string is cut

;;; Now inbuffer[1] contains number of chars read in, inbuffer[2].. inbuffer[1+inbuffer[1]] contains these chars

;;; For output place '$' in inbuffer[2+inbuffer[1]], be careful: must not exceed maxleng

mov bx, 0;
mov bl, inbuffer[1]
mov inbuffer[bx+2], '$'   ;;; terminate string by $ for output int 21h/09h

;;; now output inbuffer to screen, starting from inbuffer[2] 
mov dx, offset inbuffer+2
mov ah,09H                ;;; outputs $ terminated string to screen
int 21h

Well, that's it all. But this code not tested. You should check whether I set the '$' in the right place.

Tell me, if above code is working, also your changes made.

-- tesu

There seems to be some error in the code.

Here are the lines that show errors:

inbuffer db maxleng, ?, maxleng dup(?)     ;;; defines special buffer for int 21h/0AH function
mov dx, offset inbuffer 
mov bl, inbuffer[1]
mov inbuffer[bx+2], '$'   ;;; terminate string by $ for output int 21h/09h
mov dx, offset inbuffer+2

There seems to be some error in the code.

Here are the lines that show errors:

inbuffer db maxleng, ?, maxleng dup(?)     ;;; defines special buffer for int 21h/0AH function
mov dx, offset inbuffer 
mov bl, inbuffer[1]
mov inbuffer[bx+2], '$'   ;;; terminate string by $ for output int 21h/09h
mov dx, offset inbuffer+2

AH YES, the worst has come to the worst! Regrettably, such stuff also depends on the assembly tool on you are trying to assemble that code (I am supposing flat assembler of a kind;)). Unfortunately, you are still hiding this information also you didn't hit on the idea to mention the specific error messages you had got when trying to execute this very plain 80x86 code in real mode.

So I am rather unable to give you any further pieces of advice :(.

Btw, above code you complained on cannot cause of trouble for it runs on my machine without any error message :D

-- tesu

I am sorry for that.:$

I use NASM Assembler.

Here are the error codes:

boot.asm:47: error: comma expected after operand 3
boot.asm:49: error: comma, colon or end of line expected
boot.asm:58: error: comma, colon or end of line expected
boot.asm:59: error: comma, colon or end of line expected
boot.asm:62: error: comma, colon or end of line expected

;new construction of inner memory
;one convention exist for organizing a 3dm stack.

Input
Orbit_Route
Comprehend&Search
KineticMovment
Load ClassMovement
Ingredient
PatternRecognition Iner_CentralPivot
Classes_Mark
Acknowledge 3DAddressingCalculation
Color_Indensity
TestingConsider FigurePosition
Compare

FindFault
DefinNewThings
Solve&Promote GetProperties
Lock_PivotConjunction
StoreExpriment
exhibition
Demonstrate

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.