A small script that simply prints a given string. It's an improved snippet that combines some recommendations given in my post on string helper functions.

org 100h

mov     si, hello
call    puts

    jmp     .run
    mov     ah, 0Eh
    mov     bx, 7
    int     10h
    cmp     al, 0
    jne     .putc

hello db "Hello World!", 0

1 Answer 1


You have all the elements. The only thing that can be eliminated is jmp .run, as follows:

org 0x100

        mov     si, Prompt
        call    puts

  puts: mov     ah, 0xe
        mov     bx, 7
 .read: lodsb
        or       al, al
        jnz     .post     
 .post: int     0x10
        jmp     .read

 Prompt: db  'Hello World', 0

As INT 10H does not trash AH or BX, there is no need to reinitialize them each time through the loop.

  • 1
    \$\begingroup\$ Use TEST reg, reg to check for zero in preference to OR reg, reg, since the former is more likely to fuse with the conditional branch. I also find it more readable. \$\endgroup\$ Nov 16, 2019 at 4:33
  • \$\begingroup\$ @CodyGray I agree, as test is more representative of what is being done and I think that's what you mean by more readable. Whereas or implies AL is being modified for some other reason. \$\endgroup\$
    – Shift_Left
    Nov 16, 2019 at 7:58
  • \$\begingroup\$ I interpret "trashing" as having a value reset to some default value. Would this be accurate? If so, Is there a way to efficiently determine if an interrupt trashes a register? I've been using HelpPC as a reference for interrupts, and there's no mention of trashing. \$\endgroup\$
    – T145
    Nov 16, 2019 at 17:24
  • \$\begingroup\$ I use trashing in the context that a register has been modified by an interrupt, function or subroutine where its value upon return is indeterminate. As to the reference your using, I think it would be safe to say that if nothing is returned, then nothing is modified either or it specifically states returned values. \$\endgroup\$
    – Shift_Left
    Nov 16, 2019 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.