7 Replies - 3008 Views - Last Post: 19 August 2012 - 09:58 AM

#1 ellosma  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 19-August 12

ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 03:22 AM

I had to do this program in assembly x86 tasm , and the text of the program , my first and second code, the problem explanation are here, i'll hope someone hell me..

"write an assembly launguage code that:
- read a five digit number from kayboard
- print all the possible combinations (only two digit) make with the five digit i have read before
- print all the combinations in ascending order"

FOR EXEMPLE : if i write 1000, all the combinations are : 00001, 00010 , 00100, 01000 , 10000. but i've to write only the combinations with two digit, that is : 00010.
if i digit 12345 , some of combinations are: 123,124,125,213,212,214,215,312,314... ecc but i only write 00012,00013,00014,00015,00021,00023,00024,00025,00031,00032,00034,00035,00041,00042,00043,00045,00051,00052,00053,00054 because there are only two digit ( 0 not included ).
the link that i post, read a four number digit and print ALL the combinations , not only two digit combinations ( https://dl-web.dropb....txt?w=d5d92988 ).
this another link that i post , (https://dl-web.dropbox.com/get/Shared%20with%20Elena/ASM/ultima_esercitazione/evvai%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21.asm?w=b4ca4ba0 ) print a number of five digit but print all the combinations , not only two digit combinations, and it also print combinations with a max of four digit. FOR EXEMPLE: if i write 12000 , the second program write 12, 120, 1200 but not 12000. i should only write 12 , 21 , 20 , 10

thanks a lot

Is This A Good Question/Topic? 0
  • +

Replies To: ASSEMBLY - PROBLEM WITH A CODE

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5632
  • View blog
  • Posts: 12,083
  • Joined: 02-June 10

Re: ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 03:56 AM

We don't write your code for you. We aren't your code monkeys.
Attached Image

Show us what you wrote and tell us what your specific problem is and someone will try to HELP you.
Was This Post Helpful? 0
  • +
  • -

#3 ellosma  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 19-August 12

Re: ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 04:45 AM

i don't ask to solve my code! if you can read, i have post two code. i only ask to help me to solve the problem , not to write the code for me. i study and i don't want that anyone do the project for me , so think before speak !
Was This Post Helpful? -1
  • +
  • -

#4 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5632
  • View blog
  • Posts: 12,083
  • Joined: 02-June 10

Re: ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 05:15 AM

That attitude isn't going to go far here.

There is no code in your post. Links to code elsewhere aren't the way things are done here. You need to include the code IN the post, inside code tags.
:code:

For example: (Yes I know it isn't assembly, its just an example of how your code should be included in the post)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
              
            String strHostName = Dns.GetHostName();
            textBox2.Text=("Host Name: " + strHostName);
            IPHostEntry iphostentry = Dns.GetHostEntry(strHostName);
            double nIP = 1.0;
            foreach(IPAddress ipaddress in iphostentry.AddressList)
                 {    
                    textBox1.Text=("IP #" + nIP + ": " +                      
                    ipaddress.ToString());
                    nIP++;
                 }   
        }
        private void textBox1_TextChanged_1(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}


Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5632
  • View blog
  • Posts: 12,083
  • Joined: 02-June 10

Re: ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 05:24 AM

Also, please keep in mind that this is an English speaking site in the USA. We do our best to help those that have to translate from their native language into English, such as yourself. But often times it is very hard to comprehend the full meaning of what foreign speakers are trying to convey to us. Programming is a complex topic and translate.google.com doesn't do a good job all the time.

You have to be patient and sometimes rephrase things to get your meaning across. I had to re-read your post several times before finding the one sentence that contained any hint of the actual problem. The rest of the post just reads like your teacher's instructions for the assignment.
Was This Post Helpful? 0
  • +
  • -

#6 ellosma  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 19-August 12

Re: ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 05:42 AM

this is the code that I WRITE :


;------------------------------------------------------------------------------
  TITLE -  Programma N° 28
;------------------------------------------------------------------------------

;----------------------------------------------------------
; Prova Assembler esame di Calcolatori Elettronici A  
;----------------------------------------------------------
;NOME: prog33.asm

;DESCRIZIONE: Programma N. 28
;
;
;	Il programma deve:
;	- accettare in ingresso un numero di quattro cifre
;	- stampare tutti i numeri (di 2 cifre) diversi tra loro che è possibile
;	  formare con le cifre del primo numero
;	- stampare i numeri in modo che compaiano in una sola schermata
;	- stampare i numeri in ordine crescente

;**********************************************************
; Definizioni costanti
;**********************************************************

;----------- Gestione video -----------
PAGINA            EQU   00h

;-------- Gestione bios video ---------
BIOS_VIDEO        EQU   10h   ; Interrupt gestione video
SET_VIDEO_MODE    EQU   00h   ; Impostazione modalita' video
MODO_TESTO        EQU   03h   ; Modaliita' 80 x 25 caratteri a colori
W_CHR_TTY         EQU   0Eh   ; Scrittura carattere
SET_CURSOR        EQU   02h   ; Posizione cursore
S_COLORE          EQU   03H   ; Colore: azzurro su sfondo nero

;--------- Gestione tastiera ----------
KEY_IO_SERVICE    EQU   16h   ; Interrupt gestione tastiera
R_KEY             EQU   00h   ; Legge un carattere

;----------- Interrupt DOS ------------
DOS               EQU   21h   ; Interrupt DOS
PRINT_STRING      EQU   09h   ; Stampa stringa


;--------- Costanti programma ---------
; Costanti realtive a tasti della tastiera e caratteri
TASTO_INVIO       EQU   0Dh
BS                EQU   08h
HT                EQU   09h
CR                EQU   0Dh
LF                EQU   0Ah

;**********************************************************
; Definizioni variabili
;**********************************************************

DSEG SEGMENT PARA PUBLIC 'DATA'

;-------- Stringhe da stampare --------
; Stringhe di output del programma
  PRESENTAZIONE_S   DB    HT,HT,'SEQUENZA ORDINATA DI NUMERI DECIMALI A 5 CIFRE',CR,LF,'$'
  IMMISSIONE        DB    CR,LF,'Inserire un numero composto da 5 cifre: $'
  TERMINE           DB    CR,LF,CR,LF,'Ripetere? (s\n) $'

;-------- Variabili programma ---------
  V                 DB    5 DUP(0)   ; Vettore che memorizza le cinque cifre
  E					DW	  0          ; Numero corrente
  
  

DSEG ENDS



;**********************************************************
; Definizione stack
;**********************************************************

STACKM SEGMENT PARA STACK 'STACK'

  DB  64 DUP('        ')

STACKM ENDS



;**********************************************************
; Codice programma
;**********************************************************

  ASSUME CS:CSEG, DS:DSEG, SS:STACKM

CSEG SEGMENT PARA PUBLIC 'CODE'

;* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;----------------------------------------------------------
;|               Corpo pincipale programma                |
;----------------------------------------------------------


MAIN     PROC FAR

    PUSH  DS                  ; Istruzioni necessarie da lasciare in
    MOV   AX,00h              ; questa posizione
    PUSH  AX

    CALL  INIZIALIZZAZIONE

CICLO_PRINCIPALE:

      CALL  PRESENTAZIONE     ; Stampa etichetta programma
      CALL  LEGGI_DATI        ; Legge il numero in ingresso
      CALL  STAMPA_SEQUENZA   ; Stampa la sequenza ordinata di numeri
      CALL  TEST_FINALE       ; Ripetere? (s/n)
      JZ    FINE
      
      CALL  SETTA_MOD_VIDEO   ; Pulisce lo schermo

    JMP   CICLO_PRINCIPALE

FINE:
    CALL  SETTA_MOD_VIDEO     ; Ripristina il video e pulisce lo schermo

  RET

MAIN     ENDP



;* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;----------------------------------------------------------
;|                       Procedure                        |
;----------------------------------------------------------


;----------------------------------------------------------
;------------- Procedura di inizializzazione --------------
;
; Registri utilizzati:  AX, DS
;----------------------------------------------------------

INIZIALIZZAZIONE    PROC NEAR

      MOV   AX,DSEG           ; Inizializzazione segmento dati
      MOV   DS,AX

      CALL  SETTA_MOD_VIDEO

    RET

INIZIALIZZAZIONE    ENDP


;----------------------------------------------------------
;--------------- Procedura di presentazione ---------------
;
; Registri utilizzati:  DX
;----------------------------------------------------------

PRESENTAZIONE   PROC NEAR

      MOV   DX,offset PRESENTAZIONE_S
      CALL  STAMPA_STRINGA

    RET

PRESENTAZIONE   ENDP

;-----------------------------------------------------------;
;             Procedura per stampare a colori               ;
;-----------------------------------------------------------;
STAMPA_COLORE		PROC	NEAR

					PUSH	AX						;salvo i registri nello stack
					PUSH	BX
					PUSH	CX
					PUSH	DX

					XOR		BX,BX                   ;azzero i registri
					XOR 	CX,CX
					XOR		DX,DX

					MOV		BH,PAGINA				;numero di pagina
					MOV 	AH,09h					;funzione stampa a video
					MOV		BL,S_COLORE				;colore scelto: azzurro su sfondo nero
					MOV		CX,01h					;numero di volte che ripeto il carattere
					INT		10h
					
					POP		DX						;ripristino i registri dallo stack
					POP		CX
					POP		BX
					POP		AX
					RET
					
STAMPA_COLORE		ENDP


;----------------------------------------------------------
;-------------- Procedura per leggere i dati --------------
;
; Ritorna:              V inizializzato
; Registri utilizzati:  AL, DX
;----------------------------------------------------------

LEGGI_DATI    PROC NEAR

      MOV   DX,offset IMMISSIONE
      CALL  STAMPA_STRINGA

      CALL  LEGGI_CIFRA
      MOV   [V+0],AL
      CALL  LEGGI_CIFRA
      MOV   [V+1],AL
      CALL  LEGGI_CIFRA
      MOV   [V+2],AL         
      CALL  LEGGI_CIFRA
      MOV   [V+3],AL 
      CALL  LEGGI_CIFRA
      MOV   [V+4],AL
	
	  RET

LEGGI_DATI    ENDP


;----------------------------------------------------------
;----------- Procedura per stampare la sequenza---------
;
; Parametri:            V,E
; Registri utilizzati:  AX,BX, CX, DX
;----------------------------------------------------------

STAMPA_SEQUENZA   PROC NEAR
;---------------------------------
      MOV   DX,0400h              ; Sposta il cursore in (4,0)
      CALL  SPOSTA_CURSORE
;---------------------------------

; Procedura di ordinamento del vettore V
      XOR   AX,AX
SU1:
      MOV   DI,AX
	  MOV   CL,V[DI]
	  
	  MOV   BX,AX
	  INC   BX
SU2:	  
      	  MOV DI,BX
		  CMP CL,V[DI]
		  JNG GIU
		  
		  MOV CH,V[DI]
		  MOV V[DI],CL
		  MOV DI,AX
		  MOV V[DI],CH
		  MOV CL,CH
		
GIU:		
 		  INC   BX
          CMP   BX,4
	      JNE   SU2

	  INC   AX
	  CMP   AX,3
	  JNE   SU1

	  
	  
	; Inizio algoritmo sequenza
    MOV [E],-1   ; Inizializzo numero corrente


      MOV CH,0
 A1:
         MOV CL,0
  A2:
            MOV DH,0
   A3:
               MOV DL,0
    A4:

                  ; Test di verifica che tutte le cifre siano tutte diverse
				  CMP CH,CL
				  JE NULLA
                  CMP CH,CL
				  JE NULLA
                  CMP CH,DH
				  JE NULLA
                  CMP CH,DL
				  JE NULLA
                  CMP CL,DH
				  JE NULLA
                  CMP CL,DL
				  JE NULLA
                  CMP DL,DH
				  JE NULLA

                  ; Test di verifica che il numero corrente sia maggiore del precedente
				  CALL CONV_DEC
                  CMP [E],AX
                  JGE NULLA
                  MOV [E],AX
          
		          ; Il numero formalmente corretto per la sequenza viene stampato
				  CALL STAMPA_NUMERO
 
     NULLA:
                  INC DL
                  CMP DL,4
                  JNE A4

               INC DH
               CMP DH,4
               JNE A3

            INC CL
            CMP CL,4
            JNE A2

         INC CH
         CMP CH,4
         JNE A1
	  
    RET

STAMPA_SEQUENZA   ENDP


;----------------------------------------------------------
;----------- Procedura per convertire gli elementi del vettore in numero---------
;
; Parametri:  V contiene le quattro cifre decimali
; Registri utilizzati:  AX,BX, CX, DX
; Ritorna:  AX numero convertito
;----------------------------------------------------------

CONV_DEC    PROC NEAR

		PUSH DX
		XOR AX,AX
        XOR BX,BX

		MOV BL,CH     ; Carico la prima cifra in AL
        MOV DI,BX
        MOV AL,V[DI]
		MOV BX,10     ; Moltiplico la prima cifra x10 
		MUL BX
		
		MOV BL,CL     ; Carico la seconda cifra in BL
        MOV DI,BX
		XOR BH,BH
        MOV BL,V[DI]
		ADD AX,BX     ; Sommo la seconda cifra alla prima moltiplicata x10
		MOV BX,10     ; Moltiplico AX x10
		MUL BX

		POP DX
		PUSH DX
		
		MOV BL,DH     ; Carico la terza cifra in BL
        MOV DI,BX
		XOR BH,BH
        MOV BL,V[DI]
		ADD AX,BX     ; Sommo la terza cifra ad AX
		MOV BX,10     ; Moltiplico AX x10
		MUL BX

		POP DX
		PUSH DX

		MOV BL,DL     ; Carica la quarta cifra in BL
        MOV DI,BX
		XOR BH,BH
        MOV BL,V[DI]
		ADD AX,BX     ; Sommo la quarta cifra ad AX

		POP DX
    RET

CONV_DEC    ENDP



;* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;----------------------------------------------------------
;|       Procedure di basso livello di interfaccia        |
;----------------------------------------------------------


;----------------------------------------------------------
;--------- Procedura che setta la modalita' video ---------
;
; Registri utilizzati:  AX, DX
;----------------------------------------------------------

SETTA_MOD_VIDEO   PROC NEAR

      MOV   AH,SET_VIDEO_MODE     ; Impostazione modalità video
      MOV   AL,MODO_TESTO         ; e pulizia lo schermo
      INT   BIOS_VIDEO

      MOV   DX,0000h              ; Sposta il cursore in (0,0)
      CALL  SPOSTA_CURSORE

    RET

SETTA_MOD_VIDEO   ENDP


;----------------------------------------------------------
;------- Procedura per stampare un numero da 0 a 9999 ------
;
; Paramentri:           AX numero da stampare
; Registri utilizzati:  AX, BL, CX
;----------------------------------------------------------

STAMPA_NUMERO   PROC NEAR

      PUSH AX
	  PUSH BX
	  PUSH CX
	  PUSH DX

      XOR DX,DX
	  MOV BX,10               ; Divido il numero x10
	  DIV BX                  ; Il resto sono le unità
	  PUSH DX                 ; Salvo nello stack

      XOR DX,DX               ; Ripeto l'operazione
	  DIV BX
	  PUSH DX

      XOR DX,DX               ; Ripeto l'operazione
	  DIV BX
	  PUSH DX

      CALL  STAMPA_CIFRA      ; Stampa le migliaia
	  POP AX
      CALL  STAMPA_CIFRA      ; Stampa le centinaia
      POP AX
      CALL  STAMPA_CIFRA      ; Stampa le decine
      POP AX
	  CALL  STAMPA_CIFRA      ; Stampa le unità

      MOV   AL,' '
      CALL  STAMPA_CAR
	  
      POP DX
	  POP CX
	  POP BX
	  POP AX
	  
    RET

STAMPA_NUMERO   ENDP


;----------------------------------------------------------
;-------- Procedura per leggere una cifra da 0 a 9 --------
;
; Ritorna:              Zero_flag = 0  premuto invio
;                       Zero_flag = 1  letta cifra
;                       AL cifra letta
; Registri utilizzati:  AH
;----------------------------------------------------------

LEGGI_CIFRA   PROC NEAR

RILEGGI:
      CALL  LEGGI_TASTO_NE

      CMP   AL,'0'            ; Controlla sia un cifra se no rilegge
      JL    RILEGGI
      CMP   AL,'9'
      JG    RILEGGI

      MOV   BL,AL  	  ; Visualizza la cifra
      CALL  STAMPA_COLORE
	  CALL  STAMPA_CAR
      MOV   AL,BL

      SUB   AL,'0'
      XOR   AH,AH             ; Setta lo Zero_flag

    RET

LEGGI_CIFRA   ENDP


;----------------------------------------------------------
;-- Procedura per stampare una cifra da 0 a 9 con blank ---
;
; Parametri:            BL = 0   blank
;                       BL <> 1  zero
;                       AL cifra
; Registri utilizzati:  
;----------------------------------------------------------

STAMPA_CIFRA   PROC NEAR

      PUSH AX
      PUSH BX
      PUSH CX
      PUSH DX

      ADD   AL,'0'            ; altrimenti stampo la cifra
      CALL  STAMPA_CAR

      POP DX
      POP CX
      POP BX
      POP AX

    RET

STAMPA_SPAZIO:
      MOV   AL,' '
      CALL  STAMPA_CAR

    RET

STAMPA_CIFRA   ENDP


;----------------------------------------------------------
;---------- Procedura per vedere se teriminare  -----------
;
; Ritorna:              Zero_flag = 0  ripeti
;                       Zero_flag = 1  esci
; Registri utilizzati:  AL, DX
;----------------------------------------------------------

TEST_FINALE   PROC NEAR

      MOV   DX,offset TERMINE    ; Stampa la richiesta
      CALL  STAMPA_STRINGA

      CALL  LETTURA_SN           ; Leggere risposta
      CMP   AL,'n'

    RET

TEST_FINALE   ENDP


;----------------------------------------------------------
;------------- Procedura per stampare stringa -------------
;
; Paramentri:           DS:DX indirizzo stringa
; Registri utilizzati:  AH, DX
;----------------------------------------------------------

STAMPA_STRINGA    PROC NEAR

      MOV   AH,PRINT_STRING
      INT   DOS

    RET

STAMPA_STRINGA    ENDP


;----------------------------------------------------------
;-- Procedura per leggere da tastiera i caratteri S o N ---
;
; Ritorna:              AL codice ascii del tasto letto
; Registri utilizzati:  AX
;----------------------------------------------------------

LETTURA_SN    PROC NEAR

NUOVA_LETTURA:
      CALL  LEGGI_TASTO_NE

      OR    AL,00100000b      ; Rende il carattere minuscolo
      CMP   AL,'n'            ; Se il tasto è 'n'
      JZ    FINE_LETTURA      ; termina la procedura
      CMP   AL,'s'            ; Se il tasto non è 's'
      JNZ   NUOVA_LETTURA     ; ripete la lettura

FINE_LETTURA:
    RET

LETTURA_SN    ENDP


;----------------------------------------------------------
;------- Procedura per leggere un tasto senza eco --------
;
; Ritorna:              AL codice ascii del tasto letto
; Registri utilizzati:  AX
;----------------------------------------------------------

LEGGI_TASTO_NE    PROC NEAR

      MOV   AH,R_KEY          ; Legge un carattere dal buffer
      INT   KEY_IO_SERVICE

    RET

LEGGI_TASTO_NE    ENDP

;----------------------------------------------------------
;---------- Procedura per stampare un carattere -----------
;
; Ritorna:              AL carattere da stampare
; Registri utilizzati:  AX
;----------------------------------------------------------

STAMPA_CAR    PROC NEAR

      MOV	AH,W_CHR_TTY  		  ; Scrive il carattere
      INT	BIOS_VIDEO

		RET

STAMPA_CAR    ENDP


;----------------------------------------------------------
;----------- Procedura per spostare il cursore ------------
;
; Ritorna:              DH	riga
;                       DL	colonna
; Registri utilizzati:  AX, BH
;----------------------------------------------------------

SPOSTA_CURSORE    PROC NEAR

      MOV	BH,PAGINA
      MOV	AH,SET_CURSOR       ; Sposta il cursore
      INT	BIOS_VIDEO

		RET

SPOSTA_CURSORE    ENDP


CSEG ENDS

  END MAIN


and the part i think is wrong is into the file. i know that my english is very simple and absolutely not perfect, but i have never had the intention to have a free code. i know perfectly that you're not my monkey code. and what you say in the first post is different to say that i don't speak english very well. i have respect for the work that you do, but i also want respect because i didn't do anything wrong.

there is the file text with the problem i think the code has

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#7 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,303
  • Joined: 28-March 11

Re: ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 09:11 AM

To the Assembly forum we go....

So this is your output?
00012,00013,00014,00015,00021,00023,00024

How would you strip off the unneeded zeros?
Was This Post Helpful? 0
  • +
  • -

#8 ellosma  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 4
  • Joined: 19-August 12

Re: ASSEMBLY - PROBLEM WITH A CODE

Posted 19 August 2012 - 09:58 AM

View PostGunnerInc, on 19 August 2012 - 09:11 AM, said:

To the Assembly forum we go....

So this is your output?
00012,00013,00014,00015,00021,00023,00024

How would you strip off the unneeded zeros?


my prof want see the 0 before the "real" number. and the first problem in the code that i posted before, is this. if i digit 10000 , the combinations should be 00001, 00010, 00100 , 01000 .. not 0001,0010.. i solve this this problem ( http://www.mediafire...51vwj64onvszln) but now if i digit 12000 , 00012 and 00021 are excluded from the list of combinations and i don't know how solve this -_-'
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1