Hardwarenahe_Programmierung/src/asm/a2.asm

75 lines
1.1 KiB
NASM
Raw Normal View History

2018-10-18 12:38:02 +02:00
org 100h
cpu 8086
2018-10-24 18:07:52 +02:00
;0=00111111=3F
;1=00000110=6
;2=01011011=5B
;3=01001111=4F
;4=01100110=66
;5=01101101=6D
;6=01111101=7D
;7=00000111=7
;8=01111111=7F
;9=01101111=6F
;A=01110111=77
;B=11111111=FF
;C=00111001=39
;D=10111111=BF
;E=01111001=79
;F=01110001=71
2018-10-25 11:26:51 +02:00
INPUT equ 0h
LED equ 0h
SEGM equ 90h
2018-10-24 18:07:52 +02:00
2018-10-25 11:26:51 +02:00
; 0 1 2 3 4 5 6 7 8 9 A B C D E F
segtext db 0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x6F, 0x77, 0xFF, 0x39, 0xBF, 0x79, 0x71
2018-10-24 18:07:52 +02:00
2018-10-18 12:38:02 +02:00
2018-10-23 15:03:01 +02:00
jmp WDH
2018-10-25 11:26:51 +02:00
WDH: in ax, INPUT
2018-11-01 11:17:40 +01:00
mov bx, ax
2018-10-25 11:26:51 +02:00
and ax, 00001111b;get second nibble
2018-11-01 11:17:40 +01:00
;out LED, ax;debug, output to leds
2018-10-25 11:26:51 +02:00
push ax;write result to stack
2018-11-01 11:17:40 +01:00
mov ax, bx
2018-10-31 19:03:54 +01:00
mov cl, 0x4
2018-11-01 11:17:40 +01:00
shr ax, cl;shift right 4 times
2018-10-25 11:26:51 +02:00
2018-11-01 11:17:40 +01:00
;out LED, ax;debug, output to leds
2018-10-25 11:26:51 +02:00
pop bx;get from stack
sub ax, bx
out LED, ax;output to led
2018-10-18 12:38:02 +02:00
2018-11-01 11:17:40 +01:00
;right seven segment display
push ax
mov bx, segtext
and ax, 0000000000001111b
add bx, ax
mov al, [bx]
2018-10-25 11:26:51 +02:00
out SEGM, al;output to seven segment display
2018-11-01 11:17:40 +01:00
;left seven segment display
pop ax;get from stack
mov cl, 0x4
shr ax, cl
mov bx, segtext
add bx, ax
mov al, [bx]
out SEGM + 0x2, al
2018-10-18 12:38:02 +02:00
jmp WDH
2018-11-01 11:17:40 +01:00