Hello!.
First, I don't want you do my homework. The hw consists in take a char chaine and convert it to a number usign macros. For example the chaine 56 in the number 56.
We have a program provided by our instructor which in theory does the same without macros. If I understand the program, the number will be stored in DX and testing in the emulator it works fine for the number with one digit (0-9), but when numbers bigger, it only save the last digit. Example: chaine:8 dx:8 (or 1000) chaine:17 dx:7 (or 111).
Could you give me some advice to fix this example and to be able to start coding the assignment.

TITLE caracteresversnombre
 SPILE   SEGMENT STACK
        DW 100 DUP(?)
 SPILE   ENDS
 SDATA SEGMENT
    chaine db 255 dup('$')
SDATA ENDS
SCODE SEGMENT
        ASSUME CS:SCODE,DS:SDATA
DEBUT:
   mov AX,sdata
   mov DS,AX
   mov DX,offset chaine
   mov AH,0ah
    int 21h
    mov SI,1       
    mov AX,0
    xor CX,CX  
    mov CL,chaine[si]
     inc SI
repeter:
       mov DX,10
        mul DX
        mov DL,chaine[si]
    sub DL,48
    mov DH,0
    add AX,DX
    inc SI
    loop repeter    
   MOV AX,4C00H
   INT 21H
SCODE ENDS
END DEBUT

By the way: this example should work in this way:

Enter a chaine. example ‘827’
Number = 0
Digit = 8
Number = Number * 10 +Digit =0*10+8 = 8
Digit = 2
Number = Number * 10 + 2 = 8*10 + 2 = 82
Digit = 7
Number = Number * 10 + 7 = 82*10+7 = 827

Finally I understand how the program works. The result is in AX registry. For example if the chaine was 41, the result will be 29 (41 in hex).
Now I would like to print it in the screen. I have added some lines (in bold), according a site (http://www.emu8086.com/assembly_language_tutorial_assembler_reference/8086_bios_and_dos_interrupts.html#int21h_09h) but there si something I'm doing wrong because it doesn't works. All I need is to know to to output this result on screen.
I have done programs that prints on screen a string, so I tought it will be the same, but it is not.

TITLE caracteresversnombre
 SPILE   SEGMENT STACK
        DW 100 DUP(?)
 SPILE   ENDS
 SDATA SEGMENT
    chaine db 255 dup('$')
SDATA ENDS
SCODE SEGMENT
        ASSUME CS:SCODE,DS:SDATA
DEBUT:
   mov AX,sdata
   mov DS,AX
   mov DX,offset chaine
   mov AH,0ah
    int 21h
    mov SI,1       
    mov AX,0
    xor CX,CX  
    mov CL,chaine[si]
     inc SI
repeter:
       mov DX,10
        mul DX
        mov DL,chaine[si]
    sub DL,48;
    mov DH,0
    add AX,DX
    inc SI
    loop repeter
    
[B]     mov dx, ax
     mov al, 0
     mov ah, 9
     int 21h    [/B]
        
   MOV AX,4C00H
   INT 21H
SCODE ENDS
END DEBUT

I'm not sure I understand the nomenclature or the proboem. But if you surf to http://www.dc-pc.org/program/anzicode.html you'll see, starting at a 018D, how it compares the byte in AL to 81h, and ripples down the series until it finds a match, where it changes the value of another register.

Duck soup with a text editor to cut and paste it up. Rather than using mul or div, its basically a lookup table that outputs a particular ascii byte to correspond to every input byte.

What ANZI does, BTW, is something you *cannot* do with C, or any of its variants, nor any of the other higher level languages that I know of. This only works in dos assy on the dos 16 color text mode screen.

It relies on INT 10 to control both the char and the attr (foreground and background) colors of each letter in the font.

Thanks for your advice Day Brown. I have replaced the bold lines by:
MOV AH, 0Eh
;MOV AL, DL
INT 10h
and it works.

With today's DRAM size and CPU speed, I avoid calling subroutines. KISS. use a look up table, let it fall thru the table looking for the mathematical match. If you need it again, use a text editor to copy and paste it in. duck soup.

Since I work in dos assy, I use DEXTER.EXE, a text editor that lets me split the screen vertically. Then, I can have the sequence that makes a call on the left, and the subroutine it calls on the right, and be able to scroll and edit each panel, which may or may not be the same .obj , independently.

This article has been dead for over six months. Start a new discussion instead.