Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7619561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:43:05+00:00 2026-05-31T03:43:05+00:00

i am trying to code a TSR (DOS 16BIT), in which every tick of

  • 0

i am trying to code a TSR (DOS 16BIT), in which every tick of the INT8 moves an asterisk forward around the perimeter of the screen. I have 4 subroutines with different increments of the ‘*’ position corresponding to the respective screen borders. However, the code hangs and i cannot run it all at once in the debugger either, as it depends upon the interrupt. please suggest a solution

pos:        dw      158,3998,3838,0
routine:    dw      subrt1,subrt2,subrt3,subrt4

subrt1:     
            add di,2
            cmp di,[pos]
            jnz exit
            add bx,2

exit:       ret 

subrt2:     add di,160
            cmp di,[pos+2]
            jnz exit
            add bx,2
            ret 

subrt3:     sub di,2
            cmp di,[pos+4]
            jnz exit
            add bx,2
            ret
subrt4:     sub di,160
            cmp di,[pos+6]
            jnz exit
            mov bx,0
            ret


timer:      push ax

            mov ax,0xb800
            mov es,ax

            mov word[es:di],0x720
            call [routine+bx]           
            mov word[es:di],0x742

            mov al,0x20
            out 0x20,al
            pop ax
            iret

start:      xor ax,ax
            xor bx,bx
            mov es,ax
            cli
            mov word[es:8*4],timer
            mov word[es:8*4+2],cs
            sti
            mov dx,start
            add dx,15
            mov cl,4
            shr dx,cl
            mov ax,0x3100
            int 0x21
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:43:06+00:00Added an answer on May 31, 2026 at 3:43 am

    This is how you fix your problems, which are mostly about correct preservation of the register state. See the comments.

    org 0x100 ;; missing?
    jmp start ;; missing?
    
    pos:        dw      158,3998,3840,0 ;; what is 3T838?
    routine:    dw      subrt1,subrt2,subrt3,subrt4
    state       dw      0 ;; storage for bx
    curpos      dw      0 ;; storage for di
    oldisr      dd      0 ;; address of old timer interrupt ISR
    
    subrt1:     
                add di,2
                cmp di,[pos]
                jnz exit
                add bx,2
    
    exit:       ret 
    
    subrt2:     add di,160
                cmp di,[pos+2]
                jnz exit
                add bx,2
                ret 
    
    subrt3:     sub di,2
                cmp di,[pos+4]
                jnz exit
                add bx,2
                ret
    
    subrt4:     sub di,160
                cmp di,[pos+6]
                jnz exit
                mov bx,0
                ret
    
    
    timer:      push ax
                push bx ;; must preserve bx
                push di ;; must preserve di
                push ds ;; must preserve ds
                push es ;; must preserve es
    
                push cs ;; must load cs into ds to access pos,routine,state,curpos
                pop ds
    
                mov ax,0xb800
                mov es,ax
    
                mov di, [curpos] ;; must retrieve di from storage
                mov bx, [state] ;; must retrieve bx from storage
    
                mov word[es:di],0x720
    
                call [routine+bx]
    
                mov word[es:di],0x72A ;; you need 42 decimal (2A hex), not 42 hex
    
                mov [curpos], di ;; must preserve di between ints
                mov [state], bx ;; must preserve bx between ints
    
                ;mov al,0x20 ;; remove int acknowledge as the old ISR will do it for us
                ;out 0x20,al
    
                pop es ;; must restore es
                pop ds ;; must restore ds
                pop di ;; must restore di
                pop bx ;; must restore bx
                pop ax
    
                ;iret ;; instead of direct iret continue in the old ISR
                jmp far [cs:oldisr] ;; to prevent undesired effects (hangs/crashes)
    
    start:      xor ax,ax
                ; xor bx,bx ;; unnecessary
                mov es,ax
                cli
    
                push word[es:8*4] ;; remember old ISR address
                push word[es:8*4+2]
                pop word[oldisr+2]
                pop word[oldisr]
    
                mov word[es:8*4],timer
                mov word[es:8*4+2],cs
                sti
                mov dx,start
                add dx,15
                mov cl,4
                shr dx,cl
                mov ax,0x3100
                int 0x21
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to code a basic text editor to play around with Java's file objects
I am trying this code in which alert should be displayed once application in
I'm trying to code a page which has many articles. Each article's title is
I am trying to code a function which creates a dropdown of school names
I am trying to code a jquery slider. I have a html code which
I'm trying to code a tooltip, which uses http://craigsworks.com/projects/simpletip/# simpletip plugin, which returns data
I am having an issue converting type. I was trying code like this (minimal,
I´m trying to code a tooltip (Yes I know, I have my reasons to
I am trying to code TDD style in PHP and one of my biggest
I am trying to code a flowchart generator for a language using Ruby. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.