.model small
.stack 100h
.data

Spc     db 0dh,0ah, " $"                                                ;New Line

;Bases Conversion
ConT    db 0dh,0ah, "   Conversion  $"                                  ;Conversion Title
ConBs3  db 0dh,0ah, "Base 3  to Base 5  "                           
        db 0dh,0ah,0dh,0ah, "Base 3 [00 to 22] : $"                     ;Enter Base 03 Number
EqBs3       db 0dh,0ah, "Base 5 Equivalent : $"                         ;Equivalent Base 05

ConBs4  db 0dh,0ah, "Base 4  to Base 5  "                           
        db 0dh,0ah,0dh,0ah, "Base 4 [00 to 33] : $"                     ;Enter Base 04 Number
EqBs4       db 0dh,0ah, "Base 5 Equivalent : $"                         ;Equivalent Base 05

ConBs5  db 0dh,0ah, "Base 5  to Base 4  "                           
        db 0dh,0ah,0dh,0ah, "Base 5 [00 to 44] : $"                     ;Enter Base 05 Number
EqBs5       db 0dh,0ah, "Base 4 Equivalent : $"                         ;Equivalent Base 04

.code
main proc

mov ax,@data                    ;initialize ds
mov ds,ax

mov ah,09h
lea dx, Spc                 ;new line
int 21h

mov ah,4Ch                      ;end here
int 21h

main endp
end main

For work I would write this in C, capture the compiler's assembler output and use that for the function. For decades we haven't resorted to assembler except for the smallest of processors or for the lower level of a driver. This is something you will write in C.

Maybe this was homework but that was not told.

Besides what you wrote in your comment about digging out that, what if you try to use base 2 in assembler is well, how to put this. Your software design spec is lacking here. You didn't tell the range you need to cover. For example this might be trivial if the value is from 0 to 255 base 10. It's one eight bit memory location so you take the ascii input to be in whatever base you decided on and write code to convert the STRING of input characters to a number. The CPU you noted has basic math but your input and output is in ASCII so a pile of work to go from text to a number.

https://www.google.com/search?q=assembly+text+to+number finds a lot of priors so no need for me to write your code here. Now you can alter the search to find how folk handles other bases. Or design then write your own. Me? I'll write this in C because for work we must get it done quickly and on time.

commented: i think it wasn't text to number. Bases to Bases like *11 Base 03 = 10 Base 04 +0

Numbers in variables or memory are 8, 16 bits for most assemblers. When you output, that's text so you need routines to take a memory location and output the text in the base you want. Same for input. Characters or text is input and you deal with conversion to a number to be held in memory.

No x86 CPU has instructions to do this for us. Hence we write code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.