Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ASM / C++ -- printing with int 10h, function 0Ah ...

ASM / C++ -- printing with int 10h, function 0Ah ...

Scheduled Pinned Locked Moved C / C++ / MFC
c++delphicssdatabasehelp
8 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    digitalmythology
    wrote on last edited by
    #1

    This is mostly a question for ASM programmers, but there wasn't a catagory for that. Since I use alot of inline ASM in my VC6 projects, and since part of my question relates to C++, I decided to ask it here. I do hope that no one is offended, and if so I do apologize whole-heartedly. Anyway to my question : I am using Borland Turbo Assembler v5.0 in [DOS mode] to comile a bootsector. I need to print several lines of text to the screen [in different colors], so I figured int 10h, function 0Ah is my best bet. However, all I print is garble if anything. Even if I change the message to be printed, the output doesn't change. I think the references to my registers got messed up somehow. Please help. Here are some of my 'rules' for the code, followed by my source-code. 1] The code must compile to 512 BYTES [or less]. 2] I must ORG to 00h or 7C00h, since it is a bootsector. 3] I must be able to print several lines of text, 4] The text must be able to hawe colour attributes 5] I must use only BIOS functions [such as int 10h] since DOS will not be loaded, making int 21h useless. With all that out of the way, here is a source-code : ; BootSector Test v A15.d ; (c)copyright 1996-2006 John T. Hardeman ; All Rights Reserved ... assume cs:code org 100h code segment program: jmp start ; data area here ! string db 'Hello, World !',0 start: ; set up data mov ax,cs mov ds,ax mov es,ax ; clear screen mov ah,00h ; function no. mov al,03h ; video mode int 10h ; BIOS int. ; write string at row 5, col 5 in light-green. mov ah,13h ; function no. mov al,00h ; write mode mov bh,00h ; page no. mov bl,0Ah ; attribute ===> text colour == light green mov dh,05h ; row mov dl,05h ; col mov cx,0Eh ; size of string lea bp,string ; address of string int 10h ; call the video BIOS interrupt ; goto text location mov ah,02h ; function number mov bh,00h ; current page number mov dh,09h ; row (from top) mov dl,09h ; column (from left) int 10h ; call the video BIOS interrupt ; put char @ current text location mov ah,0eh ; function no. mov al,01h ; character mov bh,00h ; page no. int 10h ; call the video BIOS interrupt ; wait for key press mov ax,00h ; function no. int 16h ; call the keyboard BIOS interrupt ; terminate ; ignore this section , as it will ; not be included in the final code mov

    Steve EcholsS 1 Reply Last reply
    0
    • D digitalmythology

      This is mostly a question for ASM programmers, but there wasn't a catagory for that. Since I use alot of inline ASM in my VC6 projects, and since part of my question relates to C++, I decided to ask it here. I do hope that no one is offended, and if so I do apologize whole-heartedly. Anyway to my question : I am using Borland Turbo Assembler v5.0 in [DOS mode] to comile a bootsector. I need to print several lines of text to the screen [in different colors], so I figured int 10h, function 0Ah is my best bet. However, all I print is garble if anything. Even if I change the message to be printed, the output doesn't change. I think the references to my registers got messed up somehow. Please help. Here are some of my 'rules' for the code, followed by my source-code. 1] The code must compile to 512 BYTES [or less]. 2] I must ORG to 00h or 7C00h, since it is a bootsector. 3] I must be able to print several lines of text, 4] The text must be able to hawe colour attributes 5] I must use only BIOS functions [such as int 10h] since DOS will not be loaded, making int 21h useless. With all that out of the way, here is a source-code : ; BootSector Test v A15.d ; (c)copyright 1996-2006 John T. Hardeman ; All Rights Reserved ... assume cs:code org 100h code segment program: jmp start ; data area here ! string db 'Hello, World !',0 start: ; set up data mov ax,cs mov ds,ax mov es,ax ; clear screen mov ah,00h ; function no. mov al,03h ; video mode int 10h ; BIOS int. ; write string at row 5, col 5 in light-green. mov ah,13h ; function no. mov al,00h ; write mode mov bh,00h ; page no. mov bl,0Ah ; attribute ===> text colour == light green mov dh,05h ; row mov dl,05h ; col mov cx,0Eh ; size of string lea bp,string ; address of string int 10h ; call the video BIOS interrupt ; goto text location mov ah,02h ; function number mov bh,00h ; current page number mov dh,09h ; row (from top) mov dl,09h ; column (from left) int 10h ; call the video BIOS interrupt ; put char @ current text location mov ah,0eh ; function no. mov al,01h ; character mov bh,00h ; page no. int 10h ; call the video BIOS interrupt ; wait for key press mov ax,00h ; function no. int 16h ; call the keyboard BIOS interrupt ; terminate ; ignore this section , as it will ; not be included in the final code mov

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      Wow, that's a blast from the past! Forgot you could write code like that. :cool: Problem might be in the line (although, I might be grasping at straws): lea bp, string; You might try: push cs pop es mov bp, string My memory fails me. :((


      - S 50 cups of coffee and you know it's on!

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      D PJ ArendsP 2 Replies Last reply
      0
      • Steve EcholsS Steve Echols

        Wow, that's a blast from the past! Forgot you could write code like that. :cool: Problem might be in the line (although, I might be grasping at straws): lea bp, string; You might try: push cs pop es mov bp, string My memory fails me. :((


        - S 50 cups of coffee and you know it's on!

        D Offline
        D Offline
        digitalmythology
        wrote on last edited by
        #3

        Thanks for trying; now it tells me that the operand types do not match, in the following line :

        mov bp, string

        I made the mistake of donating my old assembly books, or this would be done already. If you have any info on int 10h, AH=0Ah that you can dig up for me, I'd appreciate it very much. TASM / old MASM info is hard to come by these days. Searches for TASM, MASM, and bootcode bring up either info on Tacticle Air and Missles, MASM32, Hutch, and bits about Izcelion. Also another question? I do hope you know something of Operating System boot sequence. At what point will I be able to use C/C++ code to make controls, such as radio buttons, check boxes, progress bars, and Edit Boxes, etc.? When will I be able to use TRUE 3D controls, instead of those that resemble the 16-bit ones of the old Win 3.1? I am guessing that as soon as I enter Protected Mode, after loading the kernel and activating gate A20, I should be ok. What do you think? I'll explain my ideas later, if you would like to know about them ... Please contact me if you do, and thanks again ... My e-mail is webmaster@digitalmythologywebdesigns.com

        -digitalmythology -dm webmaster@digitalmythologywebdesigns.com http://www.digitalmythologywebdesigns.com

        Steve EcholsS 1 Reply Last reply
        0
        • Steve EcholsS Steve Echols

          Wow, that's a blast from the past! Forgot you could write code like that. :cool: Problem might be in the line (although, I might be grasping at straws): lea bp, string; You might try: push cs pop es mov bp, string My memory fails me. :((


          - S 50 cups of coffee and you know it's on!

          PJ ArendsP Offline
          PJ ArendsP Offline
          PJ Arends
          wrote on last edited by
          #4

          I am no expert, but as he wants ES:BP to be the address of the string, why not do

          mov bp, seg string
          mov es, bp
          mov bp, offset string

          This is how the sample code in my old (circa 1986) DOS book does it.


          You may be right
          I may be crazy
          -- Billy Joel --

          Within you lies the power for good, use it!!!

          Within you lies the power for good; Use it!

          Steve EcholsS J 2 Replies Last reply
          0
          • D digitalmythology

            Thanks for trying; now it tells me that the operand types do not match, in the following line :

            mov bp, string

            I made the mistake of donating my old assembly books, or this would be done already. If you have any info on int 10h, AH=0Ah that you can dig up for me, I'd appreciate it very much. TASM / old MASM info is hard to come by these days. Searches for TASM, MASM, and bootcode bring up either info on Tacticle Air and Missles, MASM32, Hutch, and bits about Izcelion. Also another question? I do hope you know something of Operating System boot sequence. At what point will I be able to use C/C++ code to make controls, such as radio buttons, check boxes, progress bars, and Edit Boxes, etc.? When will I be able to use TRUE 3D controls, instead of those that resemble the 16-bit ones of the old Win 3.1? I am guessing that as soon as I enter Protected Mode, after loading the kernel and activating gate A20, I should be ok. What do you think? I'll explain my ideas later, if you would like to know about them ... Please contact me if you do, and thanks again ... My e-mail is webmaster@digitalmythologywebdesigns.com

            -digitalmythology -dm webmaster@digitalmythologywebdesigns.com http://www.digitalmythologywebdesigns.com

            Steve EcholsS Offline
            Steve EcholsS Offline
            Steve Echols
            wrote on last edited by
            #5

            I guess asm compilers have gotten smart - used to be they did what you told them to, with no backtalk, even if it wasn't right. :) I had to dust off about 2 inches of muck from my "Peter Norton's Guide to the IBM PC", to even find int 10h, function ah=0ah! That's where the code came from, but obviously didn't work for you. Sorry, I know nothing about operating system boot sequences, or at what point you can start using the built in controls.


            - S 50 cups of coffee and you know it's on!

            • S
              50 cups of coffee and you know it's on!
              Code, follow, or get out of the way.
            1 Reply Last reply
            0
            • PJ ArendsP PJ Arends

              I am no expert, but as he wants ES:BP to be the address of the string, why not do

              mov bp, seg string
              mov es, bp
              mov bp, offset string

              This is how the sample code in my old (circa 1986) DOS book does it.


              You may be right
              I may be crazy
              -- Billy Joel --

              Within you lies the power for good, use it!!!

              Steve EcholsS Offline
              Steve EcholsS Offline
              Steve Echols
              wrote on last edited by
              #6

              Yeah, I think LEA loads the effective address of DS:BP, not ES:BP, so your code is probably the money ball. (Still dusting off the cobwebs...)


              - S 50 cups of coffee and you know it's on!

              • S
                50 cups of coffee and you know it's on!
                Code, follow, or get out of the way.
              1 Reply Last reply
              0
              • PJ ArendsP PJ Arends

                I am no expert, but as he wants ES:BP to be the address of the string, why not do

                mov bp, seg string
                mov es, bp
                mov bp, offset string

                This is how the sample code in my old (circa 1986) DOS book does it.


                You may be right
                I may be crazy
                -- Billy Joel --

                Within you lies the power for good, use it!!!

                J Offline
                J Offline
                Jorgen Sigvardsson
                wrote on last edited by
                #7

                That's one way to do it TASM. :)

                -- Touch eyeballs to screen for cheap laser surgery

                PJ ArendsP 1 Reply Last reply
                0
                • J Jorgen Sigvardsson

                  That's one way to do it TASM. :)

                  -- Touch eyeballs to screen for cheap laser surgery

                  PJ ArendsP Offline
                  PJ ArendsP Offline
                  PJ Arends
                  wrote on last edited by
                  #8

                  Jörgen Sigvardsson wrote:

                  TASM

                  The book I got the code from was targeted at the Microsoft Macro Assembler (MASM) not the Borland Turbo Assembler (TASM). (Not that it makes any difference in this case)


                  You may be right
                  I may be crazy
                  -- Billy Joel --

                  Within you lies the power for good, use it!!!

                  Within you lies the power for good; Use it!

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups