Different LED displays (Assembly)

In summary, the program creates a menu to run LED sequences using procedure calls or macros. The LED sequences include blinking, alternating, two at a time, rotate left, and rotate right. The program displays "1" for LED "ON" and "0" for LED "OFF" using delay, message output, and clear screen procedures. The code also includes functions for each LED sequence and a loop to repeat the chosen sequence. The program also allows the user to go back to the main menu or repeat the sequence.
  • #1
Mastur
41
0

Homework Statement


Create a Menu to run a program for LED sequences using procedure calls or macros as follows: [1] Blinking LED [2] Two at a time [3] Alternate [4] Rotate Right [5] Rotate Left . The program will display „1‟ for LED “ON” and „0‟ for LED “OFF”. Use delay, message output and clear screen procedures within your program. Blinking is just a subroutine. Message output is answerable by Yes or No whether to go back to the main MENU or repeat the sequence.

Homework Equations


How do I display the value in register AX (in binary form)?
How do I perform long jumps?

The Attempt at a Solution


I'm done with 1, 2 and 3 but what I did are just string declarations so that I can call them later in the code. But that will make the program really long. With that, an error will occur, saying "Relative jump out of range by x bytes." I tried long jump but it does not work (call ptr far procedure_name) How do I resolve this? Anyway, here's the code I created.
Code:
.model small
.stack 64
.data
options1 db "[A] Blinking",10,13
 db "[B] Alternating",10,13
 db "[C] 2 at a time",10,13
 db "[D] -2 at a time",10,13
 db "[E] Rotate Left",10,13
 db "[F] Rotate Right",10,13
 db "[G] Quit",10,13,'$'

nolight db "0000 0000",10,13,'$'
light db "1111 1111",10,13,'$'

alter1 db "0101 0101",10,13,'$'
alter2 db "1010 1010",10,13,'$'

twoattime1 db "0000 0011",10,13,'$'
twoattime2 db "0000 1100",10,13,'$'
twoattime3 db "0011 0000",10,13,'$'
twoattime4 db "1100 0000",10,13,'$'

.code
main proc far
mov ax,@data
mov ds,ax;-------------------------
mov ah,09h
mov dx,offset options1
int 21h

mov ah,01h
int 21h

cmp al,41h
je BLINKING

cmp al,42h
je alternate

cmp al,43h
je POS2ATTIME

cmp al,44h
je NEG2ATTIME
jne exitProgram

BLINKING:
call clearscreen
mov ax,@data
mov ds,ax
mov ah,09h
mov dx,offset nolight
int 21h
call delay
call clearscreen
mov dx,offset light
int 21h
call delay
loop BLINKING

alternate:
call clearscreen
mov ax,@data
mov ds,ax
mov ah,09h
mov dx,offset alter1
int 21h
call delay
call clearscreen
mov dx,offset alter2
int 21h
call delay
loop alternate

POS2ATTIME:
call clearscreen
mov ah,09h
mov dx,offset twoattime1
int 21h
call delay
call clearscreen
mov dx,offset twoattime2
int 21h
call delay
call clearscreen
mov dx,offset twoattime3
int 21h
call delay
call clearscreen
mov dx,offset twoattime4
int 21h
call delay
loop POS2ATTIME

NEG2ATTIME:
call clearscreen
mov ah,09h
mov dx,offset twoattime4
int 21h
call delay
call clearscreen
mov dx,offset twoattime3
int 21h
call delay
call clearscreen
mov dx,offset twoattime2
int 21h
call delay
call clearscreen
mov dx,offset twoattime1
int 21h
call delay
loop NEG2ATTIME

;------------------------
exitProgram:
mov ah,4ch
int 21h
main endp

clearscreen proc
push ax
mov ax,0600h
mov bh,07
mov cx,0000
mov dx,184fh
int 10h
mov ah,02h
mov bh,00
mov dx,0000h
int 10h
pop ax
ret
clearscreen endp

delay proc
push ax
mov cx,0fffh
delay2:
push cx
mov cx,0ffffh
delay3:
nop
nop
nop
nop
nop
loop delay3
pop cx
loop delay2
pop ax
ret
delay endp
end main
 
Physics news on Phys.org
  • #2
Mastur said:
Code:
        cmp     al,44h
        je      NEG2ATTIME
        jne     exitProgram

That last jne can be a jmp:

Code:
        cmp     al,44h
        je      NEG2ATTIME
        jmp     exitProgram

Also after doing the loop for "blinking", the processor is going to drop into the code for "alternate", you probably want the code to go to exitProgram after each of those loops.
 
Last edited:
  • #3
Our professor said that its fine if the program can be executed only once, as long as all the routines are working.

By the way, the problem remains the same.
 
  • #4
Mastur said:
Our professor said that its fine if the program can be executed only once, as long as all the routines are working.
That isn't the issue, the problem is that if blinking is chosen, then the code will do all the other patterns as well.

Mastur said:
By the way, the problem remains the same.
Try using nearby jump points for the short conditional jumps. For the other problem, add jumps to exitProgram after each loop:

Code:
; ...
cmp al,41h
je BLINKING0
cmp al,42h
je alternate0
cmp al,43h
je POS2ATTIME0
cmp al,44h
je NEG2ATTIME0
jmp exitProgram

BLINKING0:
jmp BLINKING

alternate0:
jmp alternate

POS2ATTIME0:
jmp POS2ATTIME

NEG2ATTIME0:
jmp NEG2ATTIME

BLINKING:
; ...
loop BLINKING

jmp exitProgram ; jump to exitProgram
                ;instead of falling into alternate

alternate:
; ...
 
  • #5
OK, OK, sorry I misinterpreted what you've said. The only display is a black screen with my desired input and nothing at all. (Or that's not what you're pointing out?)

Anyway, I was able to resolve the problem already (The relative jump problem). Next thing to do is to display the message output (Menu) even if I already chosen the LED display. How do I do that?
 
Last edited:
  • #6
Mastur said:
The only display is a black screen with my desired input and nothing at all.
I see a clearscreen function, but I don't see a function to display something on the screen.
 
  • #7
I tried calling the displaymenu function (from my new code) inside the BLINKING loop but it stops displaying the menu, unless I choose another display. Has it something to do with the int 01h function?

Code:
.model small
.stack 64
.data
options1 db "[A] Blinking",10,13
 db "[B] Alternating",10,13
 db "[C] 2 at a time",10,13
 db "[D] -2 at a time",10,13
 db "[E] Rotate Left",10,13
 db "[F] Rotate Right",10,13
 db "[Other Keys] Quit",10,13,'$'

nolight db "0000 0000",10,13,'$'
light db "1111 1111",10,13,'$'

alter1 db "0101 0101",10,13,'$'
alter2 db "1010 1010",10,13,'$'

twoattime1 db "0000 0011",10,13,'$'
twoattime2 db "0000 1100",10,13,'$'
twoattime3 db "0011 0000",10,13,'$'
twoattime4 db "1100 0000",10,13,'$'

rotate1 db "0000 0001",10,13,'$'
rotate2 db "0000 0010",10,13,'$'
rotate3 db "0000 0100",10,13,'$'
rotate4 db "0000 1000",10,13,'$'
rotate5 db "0001 0000",10,13,'$'
rotate6 db "0010 0000",10,13,'$'
rotate7 db "0100 0000",10,13,'$'
rotate8 db "1000 0000",10,13,'$'

.code
main proc far
mov ax,@data
mov ds,ax;-------------------------
call displaymenu
;------------------------
exitProgram:
mov ah,4ch
int 21h
main endp

displaymenu proc
disp:
mov ah,09h
mov dx,offset options1
int 21h

mov ah,01h
int 21h

cmp al,41h
je BLINKING1

cmp al,42h
je ALTERNATE1

cmp al,43h
je POS2ATTIME1

cmp al,44h
je NEG2ATTIME1

cmp al,45h
je ROTL1

cmp al,46h
je ROTR1

jmp exitProgram

BLINKING1: call BLINK
ALTERNATE1: call ALTER
POS2ATTIME1: call POS2
NEG2ATTIME1: call NEG2
ROTL1: call ROTATELEFT
ROTR1: call ROTATERIGHT
loop disp
displaymenu endp

clearscreen proc
push ax
mov ax,0600h
mov bh,07
mov cx,0000
mov dx,184fh
int 10h
mov ah,02h
mov bh,00
mov dx,0000h
int 10h
pop ax
ret
clearscreen endp

delay proc
push ax
mov cx,0fffh
delay2:
push cx
mov cx,0ffffh
delay3:
nop
nop
nop
nop
nop
loop delay3
pop cx
loop delay2
pop ax
ret
delay endp

BLINK proc
BLINKING:
call clearscreen
call displaymenu
mov ax,@data
mov ds,ax
mov ah,09h
mov dx,offset nolight
int 21h
call delay
call clearscreen
call displaymenu
mov dx,offset light
int 21h
call delay
loop BLINKING
BLINK endp

ALTER proc
ALTERNATE:
call clearscreen
mov ax,@data
mov ds,ax
mov ah,09h
mov dx,offset alter1
int 21h
call delay
call clearscreen
mov dx,offset alter2
int 21h
call delay
loop ALTERNATE
ALTER endp

POS2 proc
POS2ATTIME:
call clearscreen
mov ah,09h
mov dx,offset twoattime1
int 21h
call delay
call clearscreen
mov dx,offset twoattime2
int 21h
call delay
call clearscreen
mov dx,offset twoattime3
int 21h
call delay
call clearscreen
mov dx,offset twoattime4
int 21h
call delay
loop POS2ATTIME
POS2 endp

NEG2 proc
NEG2ATTIME:
call clearscreen
mov ah,09h
mov dx,offset twoattime4
int 21h
call delay
call clearscreen
mov dx,offset twoattime3
int 21h
call delay
call clearscreen
mov dx,offset twoattime2
int 21h
call delay
call clearscreen
mov dx,offset twoattime1
int 21h
call delay
loop NEG2ATTIME
NEG2 endp

ROTATELEFT proc
ROTL:
call clearscreen
mov ah,09h
mov dx,offset rotate8
int 21h
call delay
call clearscreen
mov dx,offset rotate7
int 21h
call delay
call clearscreen
mov dx,offset rotate6
int 21h
call delay
call clearscreen
mov dx,offset rotate5
int 21h
call delay
call clearscreen
mov dx,offset rotate4
int 21h
call delay
call clearscreen
mov dx,offset rotate3
int 21h
call delay
call clearscreen
mov dx,offset rotate2
int 21h
call delay
call clearscreen
mov dx,offset rotate1
int 21h
call delay
loop ROTL
ROTATELEFT endp

ROTATERIGHT proc
ROTR:
call clearscreen
mov ah,09h
mov dx,offset rotate1
int 21h
call delay
call clearscreen
mov dx,offset rotate2
int 21h
call delay
call clearscreen
mov dx,offset rotate3
int 21h
call delay
call clearscreen
mov dx,offset rotate4
int 21h
call delay
call clearscreen
mov dx,offset rotate5
int 21h
call delay
call clearscreen
mov dx,offset rotate6
int 21h
call delay
call clearscreen
mov dx,offset rotate7
int 21h
call delay
call clearscreen
mov dx,offset rotate8
int 21h
call delay
loop ROTR
ROTATERIGHT endp
end main

I'm sorry if it sounds like I'm asking for too much. Its just that I really do not understand everything taught to us unlike in other programming languages (high level).
 
Last edited:
  • #8
You need to find a reference for BIOS and MSDOS INT function descriptions. You can start with this wiki article:

http://en.wikipedia.org/wiki/BIOS_interrupt_call

The INT 10 (hex) are calls to the BIOS video driver. The INT 21 (hex) are calls to MSDOS. Normally AH contains the main parameter for the function to be performed. This will be explained in the links from the Wiki article above.

You keep referring to LED, but normally a PC doesn't have a LED display. Is there some special hardware on the test system that has LEDs?
 
Last edited:
  • #9
I guess we're not having the same thought, or I am completely lost to what you are saying. I am sorry. >.<

Well, yes, normally a PC does not have a LED display. The LED display I am referring is the string values I have declared in the .data, where 1 is an indicator that the LED is on and 0 otherwise.

I am referring to the equivalent syntax in TASM for the Console.KeyPress in C#.

Lets say I ran the program. Of course the menu from [A] - [G] will be displayed. And as I press Shift+A, the console will still be displaying menu and the alternating string values of 0000 0000 and 1111 1111. If I pressed again Shift+B, the menu will still retain, but the 0000 0000 and 1111 1111 displays will be replaced by 0101 0101 and 1010 1010.

I tried checking the link you gave. As I read through that article, its either those has nothing to do with this or I just really do not understand what's the article all about. :\

I also tried google'd about this so-called "subroutine" included in the instruction given to us. Unfortunately, I also do not understand those. :\
 
  • #10
For the INT 10 (video) functions, try looking at page 41 and 42 of this pdf file that was included as a link in the wiki article:

http://www.esapcsolutions.com/ecom/drawings/PhoenixBIOS4_rev6UserMan.pdf
 

What are LED displays?

LED displays, or Light Emitting Diode displays, are flat panel displays that use light emitting diodes as the primary source of illumination. They are commonly used in electronic devices such as televisions, computer monitors, and outdoor billboards.

What are the advantages of LED displays?

LED displays offer several advantages over traditional display technologies, including lower energy consumption, longer lifespan, higher brightness and contrast, and a wider color range. They are also more durable and have a faster response time.

How are LED displays assembled?

LED displays are typically assembled using surface mount technology, where the LEDs are placed on a printed circuit board and soldered in place. The board is then connected to a driver circuit and a power source. Some displays may also use a matrix of small LED modules that are connected together to create a larger display.

What are the different types of LED displays?

There are several types of LED displays, including LED video walls, LED matrix displays, and LED scoreboards. LED video walls are large displays made up of multiple LED panels, while LED matrix displays use a grid of LEDs to create images and text. LED scoreboards are used for displaying scores and information in sports stadiums and arenas.

How do I choose the right LED display for my needs?

When choosing an LED display, factors to consider include the display size, resolution, brightness, viewing distance, and intended use. It is also important to consider the quality and brand of the LEDs and the overall construction of the display. Consulting with a professional or doing research on different models can help in making an informed decision.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
20
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
20
Views
9K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
7
Views
6K
  • Programming and Computer Science
Replies
4
Views
4K
Back
Top