1

I'm currently struggling in outputting AzByCx in ms debug since I don't really know too much about it. Included here are the Basic commands that my teacher sent to us.

Basic commands

I can output A-Z easily, but not AzBxCy, there's not much of a detailed tutorial online so I came here to ask.

ecm
  • 2,583
  • 4
  • 21
  • 29
  • 1
    The 16-bit "accumulator" register is AX, not AC, unless DEBUG.EXE is an even worse assembler than I thought. – Peter Cordes Mar 23 '21 at 13:54
  • 1
    @Peter Cordes: `ax` is indeed the accumulator register. Debug uses `AC` in the flags dump to indicate Auxiliary Carry set, and `NA` instead to indicate it clear. Perhaps that's what got mixed up here. – ecm Apr 07 '21 at 20:09

2 Answers2

2
-e 200 "Az"
-a
1BD8:0100 mov bx, word [200]
1BD8:0104 mov cx, 3
1BD8:0107 mov ah, 2
1BD8:0109 mov dl, bl
1BD8:010B int 21
1BD8:010D mov dl, bh
1BD8:010F int 21
1BD8:0111 add bx, FF01
1BD8:0115 loop 109
1BD8:0117 mov dl, 0D
1BD8:0119 int 21
1BD8:011B mov dl, 0A
1BD8:011D int 21
1BD8:011F mov ax, 4C00
1BD8:0122 int 21
1BD8:0124
-g
AzByCx

What does this do?

  • initialises word at ds:200h to the string "Az" (little endian low byte is "A", high byte is "z")

  • use A command to assemble the following program:

  • load from memory into register bx (to initialise the register without having to look up the numeric ASCII codepoints)

  • set up cx as loop counter for three iterations

  • set up register ah for the interrupt 21h service 02h (display character in dl)

  • display character read from bl (low byte of bx)

  • display character from bh (high byte of bx)

  • add 1 to bl and -1 (in two's complement resulting in 0FFh) to bh which increments the codepoint in bl and decrements the one in bh

  • loop back to display subsequent letters

  • display a linebreak (codepoints 13 and 10, or 0Dh 0Ah) to make the output easier to read

  • terminate program

  • use G command to run the program

ecm
  • 2,583
  • 4
  • 21
  • 29
0

Microsoft DEBUG.EXE can indeed be used to write a simple program in Intel-syntax assembly, see this example. Replace the string definition db "Hello world$" with db "AzByCx$" and you're done.

However, this is definitely not a good way how to learn assembly language. Find a better teacher.

vitsoft
  • 5,515
  • 1
  • 18
  • 31