flat assembler
Message board for the users of flat assembler.

Index > Windows > MBR user input

Thread Post new topic Reply to topic

Joined: 20 Feb 2018
Posts: 23
SC0U7 28 Aug 2018, 13:18
Hello i use this code as MBR
but i try use some C functions to get user input but without issue can someone help me with get user input like this :
Enter your name: Peter
If user string equals Peter then show text Hello PPPeter!

thanks for any advices Smile

CPU 386
org 0h 

        jmp short load_prog     
        ident   db "ONETOLVE"

        xor ax,ax
        mov ss,ax
        mov sp,7c00h                                    ; setup stack
        mov ax,8000h
        mov es,ax                                               ; initialize es w/ 8000h
        mov ds,ax                                               ; initialize ds w/ 8000h
;       Load 6 sectors at es:0000

        mov ax,0206h                    ;function/# of sec to read
        mov cx,0001h                    ;0-5 sec # (counts from one), 6-7 hi cyl bits
        mov dx,0080h                    ;dh=head dl=drive (bit 7=hdd)
        mov bx,0h                       ;data buffer, points to es:0
        int 13h
        cmp ah,0
        jne load_1                      ;this is allowable because it is
;       Jump to code at es:prog_continue
        push es
        mov ax,prog_continue
        push ax

        mov ax,3
        int 10h                                                 ; clear screen
;       Display the null terminated message located at 0800:0400

        mov bp,0400h
        mov ah,0eh
        mov si,0ffffh
        inc si
        cmp byte [ds:bp + si],0                 ; keep writing until there is a null byte 
        jz wait_for_key

        push bp
        mov al, [byte ds:bp + si]
        mov bx, 07h
        int 10h                                                 ; teletype the character
        pop bp
        jmp write_char
;       Wait for key
        mov ah,0
        int 16h

;       Copy 512 bytes from ds:0200 to 0000:7c00
;       Jump to 0000:7c00h

        mov cx,0200h                                    ; 512 bytes
        mov si,0200h                                    ; src location
        xor ax,ax
        mov es,ax                                               ; dest segment
        mov di,7c00h                                    ; dest addr
        rep movsb
                                                ; move 512 bytes

;       And we're done... jump to the real boot sector
;       mov dx,0080h                                    ;BIOS function
;       xor ax,ax
;       push ax
;       mov ax,7c00h
;       push ax
;       retf

times 1beh-($-$$) db 0
        ;ok.. a fake partition table. Who cares.
        db 80h                                   ;active
        db 0,0,0
        db 55h                                   ;fake
        times 59 db 0            
        db 55h,0aah
Post 28 Aug 2018, 13:18
View user's profile Send private message Reply with quote

Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 28 Aug 2018, 20:47
I’d start with the fact that AX is not guaranteed to be preserved during BIOS calls.

To help you further we need to know what goes wrong, i.e. what happens not the way you expected. Don’t expect anyone to bother to actually set up proper environment to run the bootloader.
Post 28 Aug 2018, 20:47
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.