Home > other >  A jump out of the range 2 byte! Problems, seek counsel
A jump out of the range 2 byte! Problems, seek counsel

Time:11-07

The younger brother novice assembly appreciate your guidance!
Compile time appeared jump out of the range of 2 byte
O bosses emergency
Assume cs: code


; Mov dx, 28 bh. Mov dx, 283 h
; Mov al, 10000000 b; Mov al 001101110 b
; The out dx, al; The out dx al

; Mov dx, 288 h
; Mov al, 03 h
; The out dx, al

The data segment
Keys db "zxcvbnmasdfghjqwertyu"; Low, medium or high keys
Freq db 131147165175196220247; The bass frequencies
Welc db 'Welome to the rid_device_info_keyboard Piano'

The data ends

The stack segment
Dw 128 dup (0)
Stack ends

Code segment
; Assume cs: code, ds: data
Start:


Mov ax, data
Mov ds, ax; Initialize the data area
Lea dx, welc
Mov ah, 9
Int h; According to welcome statement

Input:
Mov ah, 08 h
Int h; Obtain input
CMP al, 0 dh; To determine whether the input line breaks
Jz exit; If it is a carriage return out
Cx, mov 21
Lea di, keys
Find:
CMP al, [di]
Je note; Go to the note
Inc di
Loop find; According to the key value to find the corresponding address
JMP input
Note:
Call getfreq
The call sound; The output voice
JMP input
Getfreq proc
Mov dl, 1; Record the frequency ratio
Lea bx, keys
Sub di, bx
CMP di, 6; Bass
Jna sou
The add dl, 1
Sub di, 7
CMP di, 6; Alto
Jna sou
The add dl, 2
Sub di, 7
CMP di, 6
Jna sou; The high
Sou:
Mov ax, di
Lea bx, freq
Xlat
The mul dl
Mov bx, ax
Ret
Getfreq endp

Sound proc
Mov dx, 283 h
Mov al, 00110110 b
The out dx, al; Written to the control word
Mov dx, 12 h
Mov ax, 2870 h
Div bx. Divided by the specified frequency

The out 42 h, al
Mov al, ah
The out 42 h, al

Mov dx, 28 bh.
Mov al, 10000000 b;
The or al, 00000011 b
The out dx, al; Open the speaker

Call delaytime

Mov dx, 288 h
Mov al, 03 h
And al, 11111100 b
The out dx, al; Close the speaker
Ret
Sound endp

Delaytime proc
Mov ah, 00 h
Int 1 ah
Mov si, dx
Delay:
Mov ah, 00 h
Int 1 ah
Sub dx, si
CMP dx, 3
Jna delay
Ret
Delaytime endp

Exit:
Mov ax, 4 c00h
Int 21 h
Code ends

End the start; Set entry point and stop the assembler

CodePudding user response:

Simple practice, it is a high version of the compiler, the second is the exit, and the back of the two sentences to getfreq procedure definition, in front of the adjustment of other conditional logic, is responsible for some a little, and not necessarily what occasions are feasible,
Suggest using high version assembler, produce near range of conditional transfer instruction,
  • Related