0
votes

I found these codes on Wikipedia (italian) page about "Assembly" with some description lines:

...Sample program "Hello world" in assembly Intel x86 with Intel syntax (uses calls to the operating system DOS). Is not compatible with versions Assembly UNIX GNU:

   MODEL SMALL
    STACK 100H
    .DATA
        HW      DB      "hello, world", 13, 10, '$'
    .CODE
    .STARTUP
        MOV AX, @data
        MOV DS, AX
        MOV DX, OFFSET HW
        MOV AH, 09H
        INT 21H
        MOV AX, 4C00H
        INT 21H
    END

...

...An example of code written in C-asm (using the Intel x86 assembly), which displays a number in binary data received as input, is as follows:

#include <stdio.h>
#include <iostream.h>
#include <conio.h>
int main() 
{
    int a;

    /* Acquisizione del valore numerico */
    printf("Inserisci un valore compreso tra -32768 e 32768: "); 
    scanf("%d", &a); 

    /* Visualizzazione del messaggio di risposta */
    printf("Il valore corrispondente in binario รจ: "); 

    /* Keyword per delimitare le sezioni di codice Assembly */
    asm 
    { 
        /* Visualizzazione della stringa di bit corrispondente */
        MOV BX,WORD PTR a
        MOV CX,00Ah
    }

    /* Etichetta esterna */
    Ciclo: 
        asm
        {
            /* Estrazione di un bit */
            MOV DL,00H
            RCL BX,1   /* Il valore del bit viene posto nel flag di carry */
            ADC DL,'0' /* Determino il carattere da visualizzare */
            MOV AH,02H /* Visualizzazione */
            INT 21h
            Loop Ciclo
        } 
    return 0;
}

Which is the compiler or the command for compile these codes? I tried with gcc but I have to modify the syntax.

1
You don't compile assembly code, you assemble it with an assembler. Do you have a DOS env? - Leeor
@Marco Favorito As the assembler code is a MASM compatible assembler code then it seems you should use some old MS C++. - Vlad from Moscow
This is very old 16 bit MS-DOS code for an antique C compiler. I'm not sure which one, maybe Turbo-C? Unless you are already proficient in C and have s strong inclination for archaeology, you are wasting your time. - chqrlie
@Vlad: this code probably pre-dates MS-C++ - chqrlie
Isn't the first asm code for generating the obsolete .com executable format? - Weather Vane

1 Answers

2
votes

Both fragments are MS-DOS assembly.

The first fragment can be built with FASM. FASM can target MS-DOS.

For the second one, you'll need a very old Microsoft C compiler, something like Quick C 2.x or MSC 6.x. The latest version of Microsoft C that was capable of emitting 16-bit code shipped with Visual C++ 1.54 IIRC. All of those compilers have been long discontinued.

To execute either of those, you'd need a MS-DOS machine, or an emulator such as DOSBox. The Windows command line won't do.