Foro de Assembler

Bueno bros me atrevi a crear este tema, por dos razones; la primera es que a diferencia de lo que muchos piensan el assembler no es un lenguaje muerto y la segunda que para muchas personas (Programadores o no) se constituye en un dolor de cabesa.

La idea fundamental es crear un espacio de colaboracion entre aqueellos que dominan en el lenguaje y aquellos que quieren aprenderlo.

Ojala no moleste a nadie y este tema le sirva a muchos.
hola. que tal
tengo un problema con lenguaje ensamblador al momento de encender y apagar unos leds. de verdad me urge saber que es lo que pasa por que es muy extrano.

te comento: mi problema es que hicen un programa donde enciendo y apago leds tanto de RA's como RB's. El programa esta disenado para que funcione de la siguiente manera: enciende un led despues enciende el siguiente, y el siguiente y asi sucesivamente hasta el ultimo LED despues apaga todo y comienza de nuevo. y funciona solo con los RB's, lo que hace con los RA's es diferente, al momento que enciende RA0, le sigue RA1, pero cuando enciende RA1 se apaga RA0 y asi con todos los RA's. enciende uno pero se apaga el anterior.
yo hice el programa para que queden encendidos hasta el final pero solo lo hacen los RB's y no se por que pasa eso.

ayudenme porfavor, mi empleo depende de eso.
 
PODRIAN MANDAR SUS RESPUESTAS A: ledmaq@hotmail.es . MUCHAS GRACIAS

PODRIAN MANDAR SUS RESPUESTAS A: ledmaq@hotmail.es o a adeck666@hotmail.com . MUCHAS GRACIAS




hola. que tal
tengo un problema con lenguaje ensamblador al momento de encender y apagar unos leds. de verdad me urge saber que es lo que pasa por que es muy extrano.

te comento: mi problema es que hicen un programa donde enciendo y apago leds tanto de RA's como RB's. El programa esta disenado para que funcione de la siguiente manera: enciende un led despues enciende el siguiente, y el siguiente y asi sucesivamente hasta el ultimo LED despues apaga todo y comienza de nuevo. y funciona solo con los RB's, lo que hace con los RA's es diferente, al momento que enciende RA0, le sigue RA1, pero cuando enciende RA1 se apaga RA0 y asi con todos los RA's. enciende uno pero se apaga el anterior.
yo hice el programa para que queden encendidos hasta el final pero solo lo hacen los RB's y no se por que pasa eso.

ayudenme porfavor, mi empleo depende de eso.
 
Ayuda!

Hola a todos, les voy a comentar mi problema.

Necesito hacer un sistema para el control de consolas de videojuegos. Y ya tengo hecha la parte electronica, pero se me complica muchisimo la parte del PIC, porque realmente no tengo mucha idea sobre assembler. Tengo como punto de partida este codigo que esta hecho para un cuarto oscuro:

Código:
;-------------------------------------------------------------------------;
;                             Darkroom Timer                              ;
;               April '99  Stan Ockers (ockers@anl.gov)                   ;
;                  Circuit diagram in CNTDN.PCX                           ;
;                Further description in CNTDN.TXT                         ;
;                                                                         ;
;     Modified March 2002 by Chris Deceuninck (turbokeu@turbokeu.com)     ;
;                    Circuit diagrams in *.JPG                            ;
;                Further description in CNTDN3.TXT                        ;
;                                                                         ;
;     Counts down from 0-99 min and 0-59 sec giving an alarm at 00:00     ;
;     Initial counts are held in data EEPROM settable with one button.    ;
;                                                                         ;
; RBO-RB3 to bases of PNP transistors to drive common anode of displays.  ;
; RA0-RA3 to 1,2,4,8 BCD inputs of CD4543 7-segment latch and driver.     ;
; RB7 goes to START pushbutton to start countdown and silence alarm.      ;
; RB6 goes to SET pushbutton to successively set the digits.              ;
; RA4 goes to SEL pushbutton to select from 15 starting counts.           ;
; RB4 goes to buzzer.                                                     ;
; RB5 goes to relay.                                                      ;
;-------------------------------------------------------------------------;

  LIST  P=16F84A
  #INCLUDE "p16f84a.inc"

 __CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _HS_OSC

;-------------------------------------------------------------------------;
;    Here we define our own personal registers and give them names        ;
;-------------------------------------------------------------------------;

SEC         EQU H'0C'    ; this register holds the value of seconds
SEC10        EQU H'0D'    ; holds value of 10's of seconds
MIN        EQU H'0E'    ; holds value of minutes
MIN10        EQU H'0F'    ; holds value of 10's of minutes
DIGCTR        EQU H'10'    ; 8 bit counter, only 2 lowest bits actually used
DIGIT        EQU H'11'    ; hold digit number to access table
INTCNT        EQU H'12'    ; counts # interrupts to determine when 1 sec up
FUDGE        EQU H'13'    ; allows slight adjustment every 7 interrupts
RUNFLG        EQU H'14'    ; bit 0 only, tells if countdown in progress 
W_TEMP        EQU H'15'    ; temporarily holds value of W
STATUS_TEMP    EQU H'16'    ; temporarily holds value of STATUS
SECNT        EQU H'17'    ; used in counting 50, 20msec delays for 1 sec
CNTMSEC        EQU H'18'    ; used in timing of milliseconds
ALARM        EQU H'19'    ; bit 0 only, used as flag for when to alarm
OFFSET        EQU H'1A'    ; hold offset of address in EEPROM
TEMP        EQU H'1B'    ; temporarily holds value of W

;-------------------------------------------------------------------------;
;    Here we give names to some numbers to make their use more clear      ;
;-------------------------------------------------------------------------;

    #DEFINE   START_PB    D'7'
    #DEFINE   SET_PB    D'6'
    #DEFINE   SELECT_PB    D'4'
    #DEFINE   BUZZER    D'4'
    #DEFINE   RELAY        D'5'

;-------------------------------------------------------------------------;
;          We set the start of code to originate a location zero          ;
;-------------------------------------------------------------------------;

    ORG H'0000'
    GOTO MAIN        ; jump to the main routine
    ORG H'0004'
    GOTO INTERRUPT        ; jump to the interrupt routine

;-------------------------------------------------------------------------;
;    This table is used to get a bit pattern that will turn on a digit    ;
;-------------------------------------------------------------------------;

BITPAT      ADDWF PCL,F        ; get bit pattern for PNP transistors
            RETLW H'0E'        ; a low, (0), turns the transistor on  
            RETLW H'0D'                  
            RETLW H'0B'                  
            RETLW H'07'                  

;-------------------------------------------------------------------------;
;             Initialization routine sets up ports and timer              ;
;-------------------------------------------------------------------------;

INIT        MOVLW H'C0'            ; PB6 & PB7 inputs, all others outputs
            BSF STATUS,RP0        ; 
            MOVWF TRISB            ; 
            MOVLW H'10'            ; RA4 input, others outputs
            MOVWF TRISA            ; 
            MOVLW H'03'            ; prescaler on TMR0 and 1:16
            MOVWF OPTION_REG        ; write to OPTION register
            BCF STATUS,RP0        ; 
            MOVLW H'A0'            ; GIE & T0IE set T0IF cleared
            MOVWF INTCON        ; write to INTCON register
            MOVLW D'244'        ; initialize INTCNT
            MOVWF INTCNT        ; 
            MOVLW H'06'            ; initialize FUDGE
            MOVWF FUDGE            ; 
            CLRF OFFSET            ; initialize OFFSET
            CLRF PORTB            ; initialize PORTB
            CLRF RUNFLG            ; initialize RUNFLG
            CLRF ALARM            ; initialize ALARM
            RETURN            ; 

;-------------------------------------------------------------------------;
;   This is the interrupt routine that is jumped to when TMR0 overflows   ;
;                           (every 4.096 msec)                            ;
;-------------------------------------------------------------------------;

INTERRUPT   MOVWF W_TEMP        ; save W
            SWAPF STATUS,W        ; save status
            MOVWF STATUS_TEMP        ; without changing flags
            CLRWDT            ; Clear Watchdog timer
            INCF DIGCTR,F        ; next digit #
            MOVF DIGCTR,W        ; get it into W
            ANDLW H'03'            ; mask off 2 lowest bits
            MOVWF DIGIT            ; save it for later
            ADDLW H'0C'            ; point at register to display
            MOVWF FSR            ; use as pointer
            MOVF INDF,W            ; get value of reg pointed to into W
            MOVWF PORTA            ; output to CD4543
            MOVF PORTB,W        ; read PORTB bits
            ANDLW B'00110000'        ; mask bit 4 & 5
            MOVWF TEMP            ; save it for later
            MOVF DIGIT,W        ; recall digit #
            CALL BITPAT            ; get bit pattern
            XORWF TEMP,W        ; exclusive OR with TEMP
            MOVWF PORTB            ; select transistor
            DECFSZ INTCNT,F        ; finished 1 sec?
            GOTO RESTORE        ; not yet, return and enable inter.
            CALL EVERYSEC        ; go to every second routine
            MOVLW D'244'        ; reset INTCNT to normal value
            MOVWF INTCNT        ; 
            DECFSZ FUDGE,F        ; time for fudge?
            GOTO RESTORE        ; not yet, continue on
            MOVLW H'06'            ; reset FUDGE to 6
            MOVWF FUDGE            ; 
            INCF INTCNT,F        ; INTCNT to 245
RESTORE     SWAPF STATUS_TEMP,W        ; get original status back
            MOVWF STATUS        ; into status register
            SWAPF STATUS_TEMP,F        ; old no flags trick again
            SWAPF STATUS_TEMP,W        ; to restore W
            BCF INTCON,T0IF        ; clear the TMR0 interrupt flag
            RETFIE            ; finished

;-------------------------------------------------------------------------;
;       This routine is called by the interrupt routine every second      ;
;-------------------------------------------------------------------------;

EVERYSEC    BTFSS RUNFLG,0        ; return if runflg not set
            RETURN            ; 
            DECF SEC,F            ; decrement seconds digit
            INCFSZ SEC,W        ; test for underflow
            GOTO CKZERO            ; 
            MOVLW H'09'            ; reset SEC to 9
            MOVWF SEC            ; 
            DECF SEC10,F        ; decrement SEC10
            INCFSZ SEC10,W        ; check underflow
            GOTO CKZERO            ; 
            MOVLW H'05'            ; reset SEC10 to 5
            MOVWF SEC10            ; 
            DECF MIN,F            ; decrement MIN
            INCFSZ MIN,W        ; check underflow
            GOTO CKZERO            ; 
            MOVLW H'09'            ; reset MIN to 9
            MOVWF MIN            ; 
            DECF MIN10,F        ; 
CKZERO      MOVF SEC,F            ; Test SEC for zero
            BTFSS STATUS,Z        ; 
            RETURN            ; 
            MOVF SEC10,F        ; check SEC10 for zero
            BTFSS STATUS,Z        ; 
            RETURN            ; 
            MOVF MIN,F            ; check MIN for zero
            BTFSS STATUS,Z        ; 
            RETURN            ; 
            MOVF MIN10,F        ; check MIN10 for zero
            BTFSS STATUS,Z        ; 
            RETURN            ; 
            CLRF RUNFLG            ; stop the countdown
            BSF ALARM,0            ; set the alarm flag
            RETURN            ; 

;-------------------------------------------------------------------------;
;               This routine reads a byte from data EEPROM                ;
;-------------------------------------------------------------------------;

READEE      MOVWF EEADR            ; set up eeprom address from W
            BSF STATUS,RP0        ; change to page 1
            BSF EECON1,RD        ; set the read bit
            BCF STATUS,RP0        ; back to page 0
            MOVF EEDATA,W        ; return value in W
            RETURN            ; 

;-------------------------------------------------------------------------;
;         This routine fills the display registers from data EEPROM       ;
;-------------------------------------------------------------------------;

GETEE       MOVLW H'01'            ; EEprom location 1 +
            ADDWF OFFSET,W        ; offset from start 
            CALL READEE            ; into W
            MOVWF SEC            ; into SEC register
            MOVLW H'02'            ; location 2 +
            ADDWF OFFSET,W        ; offset from start 
            CALL READEE            ; into W
            MOVWF SEC10            ; into SEC10 register
            MOVLW H'03'            ; location 3 +
            ADDWF OFFSET,W        ; offset from start 
            CALL READEE            ; into W
            MOVWF MIN            ; into MIN register
            MOVLW H'04'            ; location 4 +
            ADDWF OFFSET,W        ; offset from start 
            CALL READEE            ; into W
            MOVWF MIN10            ; into MIN10 register
            RETURN            ; 

;-------------------------------------------------------------------------;
;              This routine writes a byte to data EEPROM                  ;
;-------------------------------------------------------------------------;

WRITEEE     BSF STATUS,RP0        ; set up EEADR and EEDATA first
            CLRF EECON1            ; 
            BSF EECON1,WREN        ; enable write
            MOVLW H'55'            ; magic sequence
            MOVWF EECON2        ; 
            MOVLW H'AA'            ; 
            MOVWF EECON2        ; 
            BSF EECON1,WR        ; 
EELOOP      BTFSC EECON1,WR        ; wait for WR to go low
            GOTO EELOOP            ; not yet
            BSF EECON1,WREN        ; 
            BCF EECON1,EEIF        ; clear the interrupt flag
            BCF STATUS,RP0        ; return to page 0
            RETURN            ; 

;-------------------------------------------------------------------------;
;         This routine puts display registers into data EEPROM            ;
;-------------------------------------------------------------------------;

PUTEE       MOVF SEC,W            ; put digit registers into EEprom
            MOVWF EEDATA        ; 
            MOVLW H'01'            ; EEPROM location 1 +  
            ADDWF OFFSET,W        ; offset from start 
            MOVWF EEADR            ; 
            CALL WRITEEE        ; 
            MOVF SEC10,W        ; 
            MOVWF EEDATA        ; 
            MOVLW H'02'            ; EEPROM location 2 +  
            ADDWF OFFSET,W        ; offset from start 
            MOVWF EEADR            ; 
            CALL WRITEEE        ; 
            MOVF MIN,W            ; 
            MOVWF EEDATA        ; 
            MOVLW H'03'            ; EEPROM location 3 +  
            ADDWF OFFSET,W        ; offset from start 
            MOVWF EEADR            ; 
            CALL WRITEEE        ; 
            MOVF MIN10,W        ; 
            MOVWF EEDATA        ; 
            MOVLW H'04'            ; EEPROM location 4 +  
            ADDWF OFFSET,W        ; offset from start 
            MOVWF EEADR            ; 
            CALL WRITEEE        ; 
            RETURN            ; 

;-------------------------------------------------------------------------;
;           This is the main routine, the program starts here             ;
;-------------------------------------------------------------------------;

MAIN        CALL INIT             ; set up ports etc.

;-------------------------------------------------------------------------;
;           We will return to this point when alarm is shut off.          ;
;-------------------------------------------------------------------------;

EE2D        CALL BEEP            ; sound buzzer
            CALL GETEE            ; put eeprom in display regs.
            BCF PORTB,RELAY        ; relay off
            BCF PORTB,BUZZER        ; buzzer off
            BCF RUNFLG,0        ; clear run flag so no countdown
            BCF ALARM,0            ; clear alarm flag
            CALL WAITSTARTUP        ; wait till no switches pressed
            CALL WAITSETUP        ; 
            CALL WAITSELECT        ; 

;-------------------------------------------------------------------------;
;      This loop checks for either pushbutton and acts accordingly        ;
;-------------------------------------------------------------------------;

KEYCHKLOOP  BTFSS PORTB,START_PB    ; check for start pressed
            GOTO STARTCNT        ; yes, start count
            BTFSS PORTB,SET_PB        ; check for set pressed
            GOTO SETDISP        ; yes, set display
            BTFSS PORTA,SELECT_PB    ; check select pushbutton pressed
            GOTO SETSELECT        ; yes, select starting count
            GOTO KEYCHKLOOP        ; loop to catch key press

;-------------------------------------------------------------------------;
;    If start key has been pressed then start countdown process,          ;
;    I initially released this code with only the setting of the          ;
;    run flag included.  If you think about it you must also reset        ;
;    TMR0 to zero.  TMR0 is free running and could have any value         ;
;    0-255 when the button in pressed. Also INTCNT has to be              ;
;    initialized because the previous count could have been cancelled.    ;
;-------------------------------------------------------------------------;

STARTCNT    CALL BEEP            ; sound buzzer
            CALL WAITSTARTUP        ; wait for release of start key
            MOVLW D'244'        ; reset INTCNT
            MOVWF INTCNT        ; 
            CLRF TMR0            ; and clear timer 0
            BSF RUNFLG,0        ; start the countdown
            BSF PORTB,RELAY        ; turn relay on

;-------------------------------------------------------------------------;
;       Once started just loop looking for cancel or reaching 00:00       ;
;-------------------------------------------------------------------------;

MAINLOOP    BTFSS PORTB,START_PB    ; countdown in progress, check start
            GOTO EE2D            ; start over again if pressed
            BTFSC ALARM,0        ; reached 00:00 yet?
            GOTO SOUNDALARM        ; yes, turn alarm on
            GOTO MAINLOOP        ; no start switch, continue looping

;-------------------------------------------------------------------------;
;      This code sounds the alarm and waits on start to be pressed        ;
;-------------------------------------------------------------------------;

SOUNDALARM  BSF PORTB,BUZZER        ; buzzer on - For some unknown 
        BSF PORTB,BUZZER        ; reason I need to set it twice...
            BCF PORTB,RELAY        ; relay off
WAIT        MOVLW 4            ; delay 4 milliseconds
            CALL NMSEC            ; 
            BTFSC PORTB,START_PB    ; start button pressed?
            GOTO WAIT            ; not yet
            CALL DLY20            ; debounce just to make sure
            BTFSC PORTB,START_PB    ; second look
            GOTO WAIT            ; not yet
            CALL WAITSTARTUP        ; now wait for the switch up
            GOTO EE2D            ; start all over again

;-------------------------------------------------------------------------;
;                             Keyboard Beep                               ;
;-------------------------------------------------------------------------;

BEEP        BSF PORTB,BUZZER        ; buzzer on
            MOVLW 50            ; delay 50 milliseconds
            CALL NMSEC            ; 
            BCF PORTB,BUZZER        ; buzzer off
            RETURN            ; 

;-------------------------------------------------------------------------;
;                    Wait for release of start button                     ;
;-------------------------------------------------------------------------;

WAITSTARTUP BTFSS PORTB,START_PB    ; wait for release
            GOTO WAITSTARTUP        ; not released yet
            CALL DLY20            ; debounce release 
            BTFSS PORTB,START_PB    ; 2nd check, make sure released
            GOTO WAITSTARTUP        ; keep checking
            RETURN            ; 

;-------------------------------------------------------------------------;
;                    Wait for release of set button                       ;
;-------------------------------------------------------------------------;

WAITSETUP   BTFSS PORTB,SET_PB        ; wait for release
            GOTO WAITSETUP        ; not yet
            CALL DLY20            ; debounce release 
            BTFSS PORTB,SET_PB        ; 2nd check, make sure released
            GOTO WAITSETUP        ; keep checking
            RETURN            ; 

;-------------------------------------------------------------------------;
;                    Wait for release of select button                    ;
;-------------------------------------------------------------------------;

WAITSELECT  BTFSS PORTA,SELECT_PB    ; wait for release
            GOTO WAITSELECT        ; not yet
            CALL DLY20            ; debounce release 
            BTFSS PORTA,SELECT_PB    ; 2nd check, make sure released
            GOTO WAITSELECT        ; keep checking
            RETURN            ; 

;-------------------------------------------------------------------------;
;       Routine that follows sets the countdown time digit by digit       ;
;-------------------------------------------------------------------------;

SETDISP     CALL BEEP            ; sound buzzer
            CALL WAITSETUP        ; wait for set key to be released
            MOVLW H'0A'            ; put A's in digits, (no display)
            MOVWF MIN10            ; 10's of minutes
            MOVWF MIN            ; minutes
            MOVWF SEC10            ; 10's of seconds
            MOVWF SEC            ; seconds
STARTMIN10  CLRF MIN10            ; 0 now in MIN10
MOREMIN10   MOVLW H'32'            ; 50 delays of 20msec
            MOVWF SECNT            ; into counting register
WAIT1       CALL DLY20            ; 20msec delay
            BTFSS PORTB,SET_PB        ; set key pressed?
            GOTO MINSET            ; yes MIN10 now set
            DECFSZ SECNT,F        ; finished 1 sec delay?
            GOTO WAIT1            ; continue wait
            INCF MIN10,F        ; every second increment 10's MIN
            MOVLW H'0A'            ; reached 10?
            SUBWF MIN10,W        ; 
            BTFSC STATUS,Z        ; Z set if reached 10
            GOTO STARTMIN10        ; start again with 0
            GOTO MOREMIN10        ; set up another 1 sec delay
MINSET      CALL BEEP            ; sound buzzer
            CALL WAITSETUP        ; wait for release of set key
STARTMIN    CLRF MIN            ; 0 into MIN
MOREMIN     MOVLW H'32'            ; 50 delays of 20msec
            MOVWF SECNT            ; into counting register
WAIT2       CALL DLY20            ; 20msec delay
            BTFSS PORTB,SET_PB        ; set pressed?
            GOTO SETSEC10        ; yes, finished with MIN
            DECFSZ SECNT,F        ; finished 1 sec delay?
            GOTO WAIT2            ; continue wait
            INCF MIN,F            ; every second increment MIN
            MOVLW H'0A'            ; reached 10?
            SUBWF MIN,W            ; 
            BTFSC STATUS,Z        ; Z set if reached 10
            GOTO STARTMIN        ; put zero in if Z set
            GOTO MOREMIN        ; set up another 1 sec delay
SETSEC10    CALL BEEP            ; sound buzzer
            CALL WAITSETUP        ; wait release
STARTSEC10  CLRF SEC10            ; 0 into SEC10
MORESEC10   MOVLW H'32'            ; 50 delays of 20msec
            MOVWF SECNT            ; into counting register
WAIT3       CALL DLY20            ; 20msec delay
            BTFSS PORTB,SET_PB        ; set pressed?
            GOTO SETSEC            ; yes quit incrementing
            DECFSZ SECNT,F        ; finished 1 sec delay?
            GOTO WAIT3            ; continue wait
            INCF SEC10,F        ; every second increment 10's SEC
            MOVLW H'06'            ; reached 6?
            SUBWF SEC10,W        ; 
            BTFSC STATUS,Z        ; Z set if reached 6
            GOTO STARTSEC10        ; put zero in if Z set
            GOTO MORESEC10        ; set up another 1 sec delay
SETSEC      CALL BEEP            ; sound buzzer
            CALL WAITSETUP        ; wait for release
STARTSEC    CLRF SEC            ; 0 into SEC
MORESEC     MOVLW H'32'            ; 50 delays of 20msec
            MOVWF SECNT            ; into counting register
WAIT4       CALL DLY20            ; 20msec delay
            BTFSS PORTB,SET_PB        ; set button pressed?
            GOTO FINSET            ; yes finished setting digits
            DECFSZ SECNT,F        ; finished 1 sec delay?
            GOTO WAIT4            ; continue wait
            INCF SEC,F            ; every second increment SEC
            MOVLW H'0A'            ; reached 10?
            SUBWF SEC,W            ; 
            BTFSC STATUS,Z        ; Z set if reached 10
            GOTO STARTSEC        ; put zero in if Z set
            GOTO MORESEC        ; set up another 1 sec delay
FINSET      CALL BEEP            ; sound buzzer
            BCF INTCON,GIE        ; disable interrupts
            CALL PUTEE            ; put new digits into EEPROM
            BSF INTCON,GIE        ; re-enable interrupts
            CALL WAITSETUP        ; make sure set switch up
            GOTO KEYCHKLOOP        ; start checking buttons again

;-------------------------------------------------------------------------;
;          Selects starting count by changing EEPROM location 0           ;
;-------------------------------------------------------------------------;

SETSELECT   CALL BEEP            ; sound buzzer
            MOVLW D'4'            ; offset up 4
            ADDWF OFFSET,F        ; next offset position
            MOVLW D'60'            ; reached 16th yet?
            SUBWF OFFSET,W        ; will give zero if yes
            BTFSC STATUS,Z        ; skip if not 64
            CLRF OFFSET            ; reset position to zero
            MOVLW 0            ; EEPROM location
            MOVWF EEADR            ; set up address
            MOVF OFFSET,W        ; offset # into W
            MOVWF EEDATA        ; set up data
            BCF INTCON,GIE        ; clear GIE, disable interrupts
            CALL WRITEEE        ; save # in location 0
            BSF INTCON,GIE        ; re-enable interrupts
            CALL GETEE            ; get new start count into display
            CALL WAITSELECT        ; make sure select switch is up
            GOTO KEYCHKLOOP        ; start checking buttons again

;-------------------------------------------------------------------------;
;  The following are various delay routines based on instruction length.  ;  
;  The instruction length is assumed to be 1 microsecond (4Mhz crystal).  ;
;-------------------------------------------------------------------------;

DLY20       MOVLW 10            ; delay for 20 milliseconds
        ;*** N millisecond delay routine ***
NMSEC       MOVWF CNTMSEC        ; delay for N (in W) milliseconds
MSECLOOP    MOVLW D'248'        ; load takes 1 microsec
            CALL MICRO4            ; by itself CALL takes ...
                    ; 2 + 247 X 4 + 3 + 2 = 995
            NOP                ; 1 more microsec 
            DECFSZ CNTMSEC,F        ; 1 when skip not taken, else 2
            GOTO MSECLOOP        ; 2 here: total 1000 per msecloop
            RETURN            ; final time through takes 999 to here
                    ; overhead in and out ignored

                ;***  1 millisecond delay routine ***
ONEMSEC     MOVLW D'249'        ; 1 microsec for load W
                    ; loops below take 248 X 4 + 3 = 995
MICRO4      ADDLW H'FF'            ; subtract 1 from 'W'
            BTFSS STATUS,Z        ; skip when you reach zero
            GOTO MICRO4            ; loops takes 4 microsec, 3 for last
            RETURN            ; takes 2 microsec
                    ; call + load  W + loops + return =
                    ; 2 + 1 + 995 + 2 = 1000 microsec

;-------------------------------------------------------------------------;
;    Here we set up the initial values of the digits in data EEPROM       ;
;-------------------------------------------------------------------------;
    ORG H'2100'

          DE  1, 0, 0, 0    ; 1st starting #
          DE  2, 0, 0, 0    ; 2nd starting #
          DE  3, 0, 0, 0    ; 3rd starting #
          DE  4, 0, 0, 0    ; 4th starting #
          DE  5, 0, 0, 0    ; 5th starting #
          DE  6, 0, 0, 0    ; 6th starting #
          DE  7, 0, 0, 0    ; 7th starting #
          DE  8, 0, 0, 0    ; 8th starting #
          DE  9, 0, 0, 0    ; 9th starting #
          DE  0, 1, 0, 0    ; 10th starting #
          DE  1, 1, 0, 0    ; 11th starting #
          DE  2, 1, 0, 0    ; 12th starting #
          DE  3, 1, 0, 0    ; 13th starting #
          DE  4, 1, 0, 0    ; 14th starting #
          DE  5, 1, 0, 0    ; 15th starting #

    END

Lo que necesito es modificar ese codigo para que haga lo siguiente:

Con un primer pulso (primer ficha insertada) comience un contador de 6min descendiente, y que luego de eso, cualquier pulso posterior (otra ficha insertada) sume 6min al tiempo restante.

Ej:

1min restante + 1ficha insertada = 7min
4min restante + 2ficha insertada = 16min

Estaria REALMENTE agradecido si alguien me pudiese dar una solucion. Desde ya muchas gracias. Atentamente Lucas Escudero.
 
hola q tal??...Saludos!!!!!!!!!....tengo un problemita, les muestro una parte d mi codigo, mi problema es
el siguiente: tengo un boton(VERIFICAR) y un editText(edit01)..al presionar el boton VERIFICAR lo q
hago es agarrar el texto d edit01,por
ejemplo 100, mi problema es como puedo hacer para q el decimal 100(no ASCII) pueda mover a cont2, y q
el ciclo q tengo despues, se repita 100 veces....(el cilclo manda por el puerto paralelo una secuencia
de numeros binarios...para el movimiento de un motor paso a paso...en eso no tengo problema)...
por favor les rogaria si me pueden ayudar....gracias!!!!!!!

.if eax==BTN_Verificar
invoke GetDlgItemInt,hWin,edit01,0,TRUE

mov cont2,??????
p8:mov dx,378h
mov al,80h
invoke Out32,dx,al
invoke Sleep,sleept
.
.
.
mov dx,378h
mov al,90h
invoke Out32,dx,al
invoke Sleep,sleept
dec cont2
jnz p8
mov dx,378h
mov al,00H
invoke Out32,dx,al
 
Que tal como va el foro....bros algunop de ustedes ha tratado de realizar un barrido de memoria con assembler, io he probado en linux con nasm, y al tratar de ejecut<ar el programa el so me lo para aun cuando le doy propiedades de administrador...creo que es un medio de auto proteccion...bueno como sea si alguien ha podido agradeceria el dato si no cuando lo logre os lo posteo... a proposito ya tengo pc asi que pronto recuperare mi hilo de trabajo...gracias a todos los que han mantenido vivo este foro en mis meses de ausencia...
 
Hola a todos!

De entrada, mis disculpas por la nula cooperacion en el ultimo tiempo, pero ya saben, la vida tiene muchas vueltas, y no siempre se puede hacer lo que se quiere, pero en fin, les contare que realmente no he podido practica algo en asm, pero las ganas no me faltan, pero al menos quisiera mantener discuciones y asi al menos no perder las teorias, asi que permitanme compartir comentarios, ...mas que sea.

Leyendo a popeyo, les apunto que en youtube existe ejemplos de programcion en asm tanto para 16 como para 32bits para familiariazarse con el tema.

Para Ignacio (sino es demasiado tarde), te recomiendo que postees tu codigo, para trabajar sobre una base, tambien el uso de proteus, y por ultimo revisa la comuntacion de bancos adecuadamente via el registro STATUS y sus bit, utilizando RP0 y RP1 o sus iquivalentes.

Sairus, que tal! , hey, estan trabajando con 16 o 32, el limite es 64Kb y 4Gb respectivamente, al menos en Win, ahora recuerdo haber hecho muestreos de memoria en 16bits sin problemas en mis antiguos programas, e intendo en 32bits pero nada, creo que se debe a la proteccion que mantiene windows, es algo digno de investigar.

Una acotacion personal, en general no es facil la compresion de codigos asm ajenos, sobre todo para nuestro nivel y experiencia, creo que seria mejor tratar temas de codigos especificos desarrollando el programa por partes, con los demas, la satisfacion esta en la solucion y el aprendisaje en el desarrollo, eso.

Ya, espero no descomponer el foro, ire revisando otros temas y volver a participar al menos comentando.

Saludos!!!

Atte.
kzk
 
Hola
Leyendo cosas por hay comparto este dato
"JWasm, compilador para linux de masm y otros"

http://www.japheth.de/JWasm.html
http://sourceforge.net/project/showfiles.php?group_id=255677

Como no soy usuario de Linux, les doy la fuente

MASM32-RadASM, http://groups.google.es/group/MASM32-RadASM/browse_thread/thread/161475c6abb0c639, listero Grillex.

Atte.
Kzk

Bienveenido viejo kzk...la verdade es que ultimamente hemos andado como ocupados todos....bueno me alegra ver que aun contamos con tu baliosa ayuda bro....

En cueanto al barrido de memoria que mensione se trata de eliminar o manular todos los registros de la memoria ram...lo he logrado con un loop e pop que saca todos los registros de la memoria...lo malo es que tengo que correrlo como root...y conbinarlo con la init 4 para que funcione...eso en linux en widows aun no puedo lograrlo....Paz y suerte.
 
sairus black dijo:
En cueanto al barrido de memoria que mensione se trata de eliminar o manular todos los registros de la memoria ram...lo he logrado con un loop e pop que saca todos los registros de la memoria...lo malo es que tengo que correrlo como root...y conbinarlo con la init 4 para que funcione...eso en linux en widows aun no puedo lograrlo....Paz y suerte.

Hey Sairus, yo no soy iletrado en ésto pero la verdad es que no te entiendo porque como que revuelves los términos. Cómo eliminas "todos los registros de la memoria RAM"? Te refieres a los registros-registros? Debe ser, porque usas loope pop. Pero esos registros no están en ninguna RAM, y tampoco se pueden eliminar.... :| Qué misterio hay aquí.

De todas formas, por lo que alcanzo a deducir, en Windows, tal vez debas investigar cómo ejecutar código en el Ring 0.
 
UN SALUDO PARA TODOS LOS DEL FORO DE ANTE MANO GRACIAS

LES QUIERO PEDIR UN FAVOR SI PUEDEN AYUDARME A RESOLVER UN PROBLEMA KE TENGO CON UN CODIGO QUE ME PUSIERON DE ASSEMBLER PERO COMO NO MANEJO EL TEMA X ESO PIDU SU AYUDA

EL PROBLEMAS ES EL SGTE

Diseñar un programa en assembler que haga lo siguiente:
1. Que permita ingresar dos números por teclado y realice con ellos la operación indicada. Ej: 39+40=78
10*50=500
2. Que muestre en la pantalla la operación realizada con el nombre, la hora y la fecha.
Ej: Operación realizada por Juan a las 18:33 el miércoles 2009-05-31
 
UN SALUDO PARA TODOS LOS DEL FORO DE ANTE MANO GRACIAS

LES QUIERO PEDIR UN FAVOR SI PUEDEN AYUDARME A RESOLVER UN PROBLEMA KE TENGO CON UN CODIGO QUE ME PUSIERON DE ASSEMBLER PERO COMO NO MANEJO EL TEMA X ESO PIDU SU AYUDA

EL PROBLEMAS ES EL SGTE

Diseñar un programa en assembler que haga lo siguiente:
1. Que permita ingresar dos números por teclado y realice con ellos la operación indicada. Ej: 39+40=78
10*50=500
2. Que muestre en la pantalla la operación realizada con el nombre, la hora y la fecha.
Ej: Operación realizada por Juan a las 18:33 el miércoles 2009-05-31

no tienes ni idea de assembler?:rolleyes:
pues t recomiendo q leas por aquí mas a menudo.
y pidiendo q t hagan la tarea menos q vas a aprender.:muerto:

aqui un ejemplo.
http://www.mis-algoritmos.com/ejemplos/asm-15.html


utilizar Google is tx:bandido:
 
2. Que muestre en la pantalla la operación realizada con el nombre, la hora y la fecha.
Ej: Operación realizada por Juan a las 18:33 el miércoles 2009-05-31


INT 21h / AH=2Ch - get system time;
return: CH = hour. CL = minute. DH = second. DL = 1/100 seconds.

INT 21h / AH=2Ah - get system date;
return: CX = year (1980-2099). DH = month. DL = day. AL = day of week (00h=Sunday)


Estas interrupciones te entregan esos datos, pero son de DOS, para sistemas actuales debes utilizar alguna API.

Igual, la idea es ayudar a desarrollar mas que dar soluciones directas, comenta al menos, algun trabajo inicial que tengas.

Atte.
Kzk


 
Hola!

¿cómo se haría lo siguiente en lenguaje ensamblador?:

Implementar una función que sea invocada desde el main. En el main se le pedirá al usuario que teclee dos valores iniciales: valor mínimo y valor máximo. Luego la función alarma tendrá que ir pidiendo valores al usuario, ciclicamente, y mostrar un mensaje de alerta por pantalla cuando este valor no se encuentre entre los valores indicados al principio (en el main). Si se inserta el valor -100 el programa termina.

Nota: se debe implementar correctamente la llamada a procedimientos (uso de la pila, etc.)

Muchas gracias de antemano.
 
que tal amigos...alguien ha usado instruciones de assembler desde c++, es que necesito hacer unm hibrido milagroso pero no se nada de esto...por ejemplo que ensabledor usa el c++, el de su compilador o el nativo...que joda...agradesco cualquier dato.
 
hola q tal, soy nueva en esto del assembler tengo q hacer un programa para la u q haga lo siguiente:
leer dos numeros
si A>B
R=(B+A)+R
sino
R=R-(A+B)
si es igual R=100
R inicia en 100
Salida = R

tengo el siguiente codigo, funciona pero tiene errores de logica, porfa si alguien me puede ayudar:
.model small
segd segment
errorcap db 0
cantidad db 0
cantunor dw 0
cantdosr dw 0
r dw 100
cantunon db 6,0,6 dup (?)
cantdosn db 6,0,6 dup (?)
resulta db 13,10,13,10,"el resultado es: $"
resultar db 11 dup (?)
mena db "Proyecto # 1"
db 13,10
db "Nombre Apellido"
db 13,10,"15 de Junio de 2009"
db 13,10,13,10,"$"
error1 db 7,7,7,13,10,"error$"
cantunom db "dame primera cantidad: $"
;cantunom db 7,7,7,13,10,"dame primera cantidad: $"
cantdosm db 7,7,7,13,10,"dame segunda cantidad: $"
potencia dw 0001h, 000ah, 0002h, 0003h, 2710h
potenciaf dw $
segd ends
segc segment
assume ds:segd, cs:segc
start: mov ah, 0fh
int 10h
mov ah,0
int 10h
mov ax,segd
mov ds,ax
mov dx,offset mena
call imprime
mov si,offset resultar
add si,11
mov al,"$"
mov [si],al
compara proc near
capcant01: mov dx,offset cantunom
call imprime
mov ah,0ah
mov dx,offset cantunon
int 21h
mov errorcap,0
mov cantidad,0
call convnum
cmp errorcap,1
jz capcant01
mov cantunor,bx
capcant02: mov errorcap,0
mov cantidad,1
mov dx,offset cantdosm
call imprime
mov ah,0ah
mov dx,offset cantdosn
int 21h
call convnum
cmp errorcap,1
jz capcant02
mov cantdosr,bx
mov ax,cantunor
cmp ax,cantdosr
ja mayor
jb menor
je igual
mayor proc near
mayor: mov ah,01h
mov ax,cantunor
mov bx,cantdosr
add ax,bx
mov cx,r
add ax,cx
call convascii
mov dx, offset resulta
call imprime
mov dx, offset resultar
call imprime
int 21h
ret
mayor endp
menor proc near
menor: mov ah,02h
mov ax,cantunor
mov bx,cantdosr
add ax,bx
mov cx,r
sub cx,ax
mov ax,cx
call convascii
mov dx, offset resulta
call imprime
mov dx, offset resultar
call imprime
int 21h
ret
menor endp
igual proc near
igual: mov ah,03h
mov ax,cantunor
mov bx,cantdosr
mov ax,r
call convascii
mov dx, offset resulta
call imprime
mov dx, offset resultar
call imprime
int 21h
ret
igual endp
compara endp
imprime proc near
mov ah,9
int 21h
ret
imprime endp
convnum proc near
mov dx,0ah
cmp cantidad,0
jnz convnum01
mov di,offset cantunon + 1
mov cx,[di]
mov si,offset cantunon + 2
jmp convnum02
convnum01: mov di,offset cantdosn + 1
mov cx,[di]
mov si,offset cantdosn + 2
convnum02: xor ch,ch
mov di,offset potencia
dec si
add si,cx
xor bx,bx
std
convnum03: lodsb
cmp al,"0"
jb convnum04
cmp al,"9"
ja convnum04
sub al,30h
cbw
mov dx,[di]
mul dx
jc convnum05
add bx,ax
jc convnum05
add di,2
loop convnum03
jmp convnum06
convnum04:
jmp convnum06
convnum05: mov cantidad,2

convnum06: cld
ret
convnum endp
convascii proc near
push dx
push ax
mov si,offset resultar
mov cx,10
mov al,"."
convascii01: mov [si],al
inc si
loop convascii01
pop ax
pop dx
mov bx,ax
mov ax,dx
mov si,offset resultar
add si,11
mov cx,10
obtendigito: dec si
xor dx,dx
div cx
mov di,ax
mov ax,bx
div cx
mov bx,ax
mov ax,di
add dl,30h
mov [si],dl
or ax,ax
jnz obtendigito
or bx,bx
jnz obtendigito
ret
convascii endp
huboerror proc near
cmp cantidad,0
jnz huboerror02
mov dx,offset error1
call imprime
mov errorcap,1
jmp huboerror05
huboerror02:cmp cantidad,1
jnz huboerror03
mov dx,offset error1
call imprime
mov errorcap,1
jmp huboerror05
huboerror03: cmp cantidad,2
jnz huboerror04
mov dx,offset error1
call imprime
mov errorcap,1
jmp huboerror05
huboerror04: mov dx,offset error1
call imprime
mov errorcap,1
huboerror05: ret
huboerror endp
salir:
segc ends
.stack
end start


Se los agradezco de antemano
 
Última edición:
Hola farrah24

Si el error es al compilar, chequea lo siguiente :

1.- No dupliques los nombres de procedimientos y etiquetas, como en

mayor proc near
mayor: mov ah,01h

... y otros.

2.- Has coincidir cada procedimiento con sus respectivo CALL y RET

3.- No saltes a un procedimiento dando un jump, ( JA MAYOR ), sino con un CALL.

Quizas esas partes del codigo no sea necesario ser difinidos como procedimientos.

Esto a simple vista, de todas formas danos el tipo de error que te arroja, y saber si es de compilado, o ejecucion.

Atte.
Kzk
 

Los últimos mensajes

Los últimos temas