Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

assembly language in TASM

Status
Not open for further replies.

DoraSzasz

Junior Member level 1
Joined
May 17, 2009
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,459
hello,all!

I wrote a program in assembly language and I used TASM. I have to
connect a BCD decoder /7seg on a parallel port in order to display data (read a nr from the keybd and display it on the 7 segment decoder). I don't have the circuit for BCD desplay, and I want to put some messages in val1, val2, val3 to appear on the cmd window, like:"Now,the value of 1 is displayed on BCD display!"

I've tried for the va1, but it doesn't works. I attached here the code.

Thanks!
 

DoraSzasz said:
I've tried for the va1, but it doesn't works. I attached here the code.

Hi DoraSzasz,

any ASM code not appear in your post. Can you re-attached the TASM codes

regards
bassa
 

Hi,

Here your program (I display contents of your file here again)

COMMENT * Problema 1: sa se afiseze taste pana se apasa ESC *
;

stiva SEGMENT PARA STACK 'STACK'
dw 256 dup(?)
stiva ENDS

data SEGMENT PARA PUBLIC 'DATA'
text0 DB 'S-a afisat valoarea 0 pe BCD Display',0
text1 DB 'S-a afisat valoarea 1 pe BCD Display',0
text2 DB 'S-a afisat valoarea 2 pe BCD Display',0
text3 DB 'S-a afisat valoarea 3 pe BCD Display',0
text4 DB 'S-a afisat valoarea 4 pe BCD Display',0
text5 DB 'S-a afisat valoarea 5 pe BCD Display',0
text6 DB 'S-a afisat valoarea 6 pe BCD Display',0
text7 DB 'S-a afisat valoarea 7 pe BCD Display',0
text8 DB 'S-a afisat valoarea 8 pe BCD Display',0
text9 DB 'S-a afisat valoarea 9 pe BCD Display',0
data ENDS

; ~~~~~~~~~~~~~~~~~~~
; | Segment de cod |
; ~~~~~~~~~~~~~~~~~~~

CODE SEGMENT PARA PUBLIC 'CODE'
MAIN PROC FAR
ASSUME CS:CODE,DS:DATA,SS:STIVA,ES:NOTHING
push ds
xor ax,ax
push ax ;init. pt. return
mov ax,DATA
mov ds,ax

stai:
mov ah, 1
int 16h
jz stai
; DE AICI IN COLO SE POT CITI caractere

mov ah,0
int 16h
cmp al, 1Bh
jz stop
cmp al,0Dh
jz linie

; in AL – avem caracterul citit
cmp al, 1bh
jz stop
compara:
cmp AL,00h
JE val0
cmp AL,01h
JE val1
cmp AL,02h
JE val2
cmp AL,03h
JE val3
cmp AL,04h
JE val4
cmp AL,05h
JE val5
cmp AL,06h
JE val6
cmp AL,07h
JE val7
cmp AL,08h
JE val8
cmp AL,09h
JE val9

val0:
mov AL,0FBh
jmp stai

val1 proc near
mov AL,0Bh
mov si,offset text1

iar: mov ah,2
int 10h
lodsb
cmp al,0
jz endtext
mov ah,9
int 10h
inc dl
cmp dl,80
jnz iar
endtext:
inc dh
inc dh
cmp dh,25
jmp stai
val1 ENDP

val2: mov AL,0B7h
jmp stai

val3: mov AL,09Fh
jmp stai

val4: mov AL,04Fh
jmp stai

val5: mov AL,0DDh
jmp stai

val6: mov AL,0FDh
jmp stai

val7: mov AL,08Bh
jmp stai

val8: mov AL,0FFh
jmp stai

val9: mov AL,0DFh
jmp stai

afisare:
mov ah, 0Eh
int 10h
jmp stai

linie: mov ah,0Eh
int 10h
mov al,0Ah
mov ah,0Eh
int 10h
jmp stai

stop: ret
ENDS
END MAIN

I think better way to debug your code, is part by part analysis

1. check the entered (pressed) key board character and display it in the screen

sample code here
.model small
.stack 10h
.code

begin:
mov ah,6 ;Select dos function 06h
mov dl,0ffh ;
int 21h ;Dos interrupt
je begin ;Loop until key pressed

mov ah,6 ;Select dos function 06h
mov dl,al ;Display entered key
int 21h ;Dos interrupt

mov cl,al ;Load Reg AL to Reg CL
xor cl,13 ;To Check entered key as Carriage Return
jcxz oput ;If key equal then Exit the Program
jmp begin ;If not equal jump begin

oput:

.exit
end begin

2. Once this step success then check your message display routine (something you called display val1) and send to the characters to LPT port (parallel port)

check this and state your comments

regards
bassa
 

Thank you!

My code displays a caracter from the keyboard,too. Actually from this part I began....I put here the code to display a caracter from KB, and in order to see my idea, I commented the parts with my displaying on BCD idea.

In order to send the correct hexadecimal number to BCD display, I think that I don't need to display the read caracter from KB, but, to give its correct hexadecimal value to display on BCD display. I attached here my BCD display.

So, when I read value 1h from KB, in AL register is stored, and I wanted to give its correct number in hexadecimal, in order to display it on the screen. So, val1 do this change and put in AL register,0Bh, which is 00001011. And if you make the analogy with my picture of BCD, you can see that this is the correct value for displaying 1 on BCD display.

Because I don't have a BCD display, I want to find a way to show that each step was done, and I think that is ok to put a message,like: "The X nr was displayed on BCD". This step makes me problems.

I don't understand what do you said with parallel port. How can I send the registers to parallel port?

I attached here:

1. code with commented lines for given to AL a different value (this code makes the reading from KB-like your code,but is bigger). I translate the romanian words, to understand better

COMMENT * Problema 1: sa se afiseze taste pana se apasa ESC *
;

stiva SEGMENT PARA STACK 'STACK'
dw 256 dup(?)
stiva ENDS

data SEGMENT PARA PUBLIC 'DATA'
text0 DB '0 value is displayed on BCD',0
text1 DB '1 value is displayed on BCD',0
text2 DB '2 value is displayed on BCD',0
text3 DB '3 value is displayed on BCD',0
text4 DB '4 value is displayed on BCD',0
text5 DB '5 value is displayed on BCD',0
text6 DB '6 value is displayed on BCD',0
text7 DB '7 value is displayed on BCD',0
text8 DB '8 value is displayed on BCD',0
text9 DB '9 value is displayed on BCD',0
data ENDS

; ~~~~~~~~~~~~~~~~~~~
; | Segment de cod |
; ~~~~~~~~~~~~~~~~~~~

CODE SEGMENT PARA PUBLIC 'CODE'
MAIN PROC FAR
ASSUME CS:CODE,DS:DATA,SS:STIVA,ES:NOTHING
push ds
xor ax,ax
push ax ;init. pt. return
mov ax,DATA
mov ds,ax

waitpls:
mov ah, 1
int 16h
jz waitpls
; from now on,the caracters can be read

mov ah,0
int 16h
cmp al, 1Bh
jz stop
cmp al,0Dh
jz line

; in AL – we have the read caracter
cmp al, 1bh
jz stop
;compare:
;cmp AL,00h
;JE val0
;cmp AL,01h
;JE val1
;cmp AL,02h
;JE val2
;cmp AL,03h
;JE val3
;cmp AL,04h
;JE val4
;cmp AL,05h
;JE val5
;cmp AL,06h
;JE val6
;cmp AL,07h
;JE val7
;cmp AL,08h
;JE val8
;cmp AL,09h
;JE val9

;val0:
;mov AL,0FBh
;jmp waitpls

;val1:
;mov AL,0Bh
;jmp waitpls

;val2: mov AL,0B7h
;jmp waitpls

;val3: mov AL,09Fh
;jmp waitpls

;val4: mov AL,04Fh
;jmp waitpls

;val5: mov AL,0DDh
;jmp waitpls

;val6: mov AL,0FDh
;jmp waitpls

;val7: mov AL,08Bh
;jmp waitpls

;val8: mov AL,0FFh
;jmp waitpls

;val9: mov AL,0DFh
;jmp waitpls

write:
mov ah, 0Eh
int 10h
jmp waitpls

line: mov ah,0Eh
int 10h
mov al,0Ah
mov ah,0Eh
int 10h
jmp waitpls

stop: ret
ENDS
END MAIN

2. This is a problem that write on the screen something

TITLE poli
PAGE 60,132
COMMENT * jhghjghgjhg *
;
STIVA SEGMENT PARA STACK 'STACK'
DW 256 DUP(?)
STIVA ENDS
;
DATA SEGMENT PARA PUBLIC 'DATA'
text DB '1 value is displayed on BCD',0
DATA ENDS
;
; Segment de cod
; --------------
;
CODE SEGMENT PARA PUBLIC 'CODE'
MAIN PROC FAR
ASSUME CS:CODE,DS:DATA,SS:STIVA,ES:NOTHING

push es
xor ax,ax
push ax
;
mov ax,DATA
mov ds,ax
;
mov bh,0
mov bl,00011100b
call linie
ret
MAIN endp
;
; Proceduri
;
linie proc near
mov cx,1
mov dx,0h
linie_iar:
mov si,offset text
iar:
mov ah,2
int 10h
lodsb
cmp al,0
jz endtext
mov ah,9
int 10h
inc dl
cmp dl,80
jnz iar
endtext:
inc dh
inc dh
cmp dh,25

ret
linie ENDP

CODE ENDS

END MAIN

I don't know how to write my code in order to display my message after pressing one key from keyboard. For example, if a press 1, to the screen will appear:"1 value is displayed on BCD"

If you have any ideas, please tell me.

Thank you a lot
 

Hi,

as I understand you need to display text1 when you pressed key 1 in your keyboard

I wrote sample code and check this (sorry, little bit difficulty to understand your code)

.model small ;Model of the Program
.stack 100h ;Stack size for the data stores

.data ;Data Segment for the Messages

text0 DB 13,10,"0 value is displayed on BCD"
text1 DB 13,10,"1 value is displayed on BCD"
text2 DB 13,10,"2 value is displayed on BCD"

.code

msgx macro msg ;Macro Definition for the Display Message
mov dx,offset msg
mov ah,09h
int 21h
endm

begin:
mov dx,@data ;Move data to the Data segment
mov ds,dx


start:
mov ah,1 ;Load 1 to Acc.high for read key
int 21h ;Call DOS Interrupt 21h
mov cx,ax ;Store the acc for later use

xor al,13 ;check carrige return pressed
je goexit ;if carrige return pressed then exit

mov ax,cx

xor al,1 ;To Check entered key as 1
je go_1 ;If key equal to 1 then go to go_1 (display text1)

mov ax,cx

xor al,2 ;To Check entered key as 2
je go_1 ;If key equal to 2 then go to go_2 (display text2)


go_1:
msgx text1 ;Call Macro msgx to display text1
jmp start ;WHILE DO Char <> CR Above Process

go_2:
msgx text2 ;Call Macro msgx to display text2
jmp start ;WHILE DO Char <> CR Above Process

goexit:
.exit

end begin

if you connect real hardware to parallel port then you can send KB value to that hardware unit via parallel port

regards
bassa
 

    DoraSzasz

    Points: 2
    Helpful Answer Positive Rating
Hello!
Thank you for code!

I observed that there are some errors. When I pressed key 1, it displays both messages: '1 value is displayed' and '2 value is displayed' and then gives me an error.

Can you correct these errors?

best regards!


Dora
 

I solved my problem
THANK YOU A LOT!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top