answersLogoWhite

0


Best Answer

SJMP is short jump. In this 2-byte instruction the first byte is opcode and second byte is relative address of target location. This can save some byte of memory in many applications where memory space is in short supply where as LJMP (Long Jump) is 3-byte instruction in which 1st byte is opcode and 2nd and 3rd byte represent the 16- bit address of target location.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the advantage of using sjmp over ljmp?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a code using MOVC instruction?

clr a movc a,@a+dptr jz exit acall lcd_senddata inc dptr sjmp LCD_sendstring


Ps2 interfacing keyboard by micro controller with assembly language solutions?

$mod52 ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; PORT DECLERATION ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% KEYB_CLOCK EQU P2.7 KEYB_DATA EQU P2.6 KB_LSHIFT EQU 12H KB_RSHIFT EQU 59H KB_CTRL EQU 14H KB_ALT EQU 11H KB_CAPS EQU 58H KB_SCROLL EQU 7EH KB_NUML EQU 77H KB_TAB EQU 0DH KB_REL EQU 0F0H KB_EXT EQU 0E0H KB_PAUSE EQU 0E1H CAPS EQU 01H NUML EQU 02H SCROLL EQU 04H SHIFT EQU 08H ACK EQU 10H CTRL EQU 20H ALT EQU 40H RELEASE EQU 80H PAUSED EQU 40H EXTENDED EQU 80H DSEG ; This is internal data memory ORG 20H ; Bit adressable memory FLAGS1: DS 1 RECEIVED BIT FLAGS1.0 AM BIT FLAGS1.1 MAS BIT FLAGS1.2 KEYBRD BIT FLAGS1.3 AMS BIT FLAGS1.4 CAPPS_ON: DS 1 CAAPS BIT CAPPS_ON KB_OK: DS 1 KB_DATA: DS 1 KB_STATS: DS 1 KB_SCAN: DS 1 KB_TEMP: DS 1 ; For the da*n pause key KB_COUNT: DS 1 NAMES: DS 16 COUNTT: DS 1 STACK: DS 1 CSEG ; Code begins here ; ---------==========----------==========---------=========--------- ; Main routine. Program execution starts here. ; ---------==========----------==========---------=========--------- ORG 00H ; Reset AJMP MAIN ORG 23H JMP SERIAL ; ---------==========----------==========---------=========--------- MAIN: MOV SP,#STACK MOV TMOD,#20H ;Enable Timer 1 from Baud rate Generation MOV TH1,#0FDH MOV SCON,#50H ;Enable serial port for 9600Baud rate SETB ES SETB EA ;Enable serial port interrupt SETB TR1 CALL InitKeyb ;Inizialize Keyboard MOV a, KB_OK JZ KBNotOK LOOPS: CALL Check_Keyb ;Check for any keypress JNC LOOPS MOV A,KB_DATA ;get data MOV SBUF,A AJMP LOOPS ;---------==========----------==========---------=========--------- ; SERIAL INTERRUPT ROUTINE ;---------==========----------==========---------=========--------- SERIAL: JB TI,TRANS CLR RI RETI TRANS: CLR TI RETI ;********************************************************** KBNotOK: AJMP $ ;Keyboard Error ;--------------------- ; Keyboard Routines: ;--------------------- ;************************************* ; WaitKB: Wait for keypress ;************************************* WaitKB: call Check_Keyb jnc WaitKB ret ;************************************* ; InitKeyb: c=1 if ACK OK ;************************************* CheckACK: mov a, KB_STATS mov c, acc.4 clr acc.4 mov KB_STATS, a ret ;************************************* ; InitKeyb: ;************************************* InitKeyb: mov KB_TEMP, #0 mov KB_OK, #0 mov r1, #0FFH call Write_Keyb call Check_Keyb call CheckACK jnc InitKeyb mov r1, #0F4H ; Enable call Write_Keyb call Check_Keyb call CheckACK jnc KeybErr mov r1, #0F3H ; Set Typematic call Write_Keyb call Check_Keyb call CheckACK jnc KeybErr mov r1, #00H ; Typematic = 250 ms / 30 cps call Write_Keyb call Check_Keyb call CheckACK jnc KeybErr mov KB_OK, #1 mov KB_STATS, #2 ; Num Lock ON ;************************************* ; Keyb_Leds: Set KB_STATS as leds ;************************************* Keyb_Leds: mov r1, #0EDH ; Set Leds call Write_Keyb call Check_Keyb call CheckACK jnc KeybErr mov r1, KB_STATS call Write_Keyb call Check_Keyb call CheckACK KeybErr: ret ;************************************* ; Zero2One: Wait for 0 to 1 on kb ; clock line, read the kb data line ; and shift right the bit to acc.7 ;************************************* Zero2One: jnb KEYB_CLOCK, $ jb KEYB_CLOCK, $ mov c, KEYB_DATA rrc a ret ;************************************* ; Check_Keyb: Check to see if any key ; are pressed or release, returns ; ASCII codes on KB_DATA, or 1 for ; special keys, 2 for same special ; with shift. Return also the scan ; code on KB_SCAN. ; Special Keys are basicaly all non ; printable keys. See the table below ; all 1 and 2 returned are special keys ;************************************* Check_Keyb: setb KEYB_DATA setb KEYB_CLOCK ; CLOCK & DATA high = Idle Pos mov r0, #50 CheckAgain: jnb KEYB_CLOCK, KeyHit djnz r0, CheckAgain ; check r0 times sjmp KeyEnd KeyHit: jnb KEYB_DATA, KeyHit2 ; Start bit must be 0 KeyEnd: clr KEYB_CLOCK ; disable keyb clr c ; c=0 = no keypress ret KeyHit2: mov r0, #8 ; 8 bits clr a KeyHit3: call Zero2One djnz r0, KeyHit3 mov r1, a clr a call Zero2One ; Parity bit call Zero2One ; Stop bit ; acc.7 = stop, acc.6 = parity clr KEYB_CLOCK mov a, KB_TEMP jz NoIgnore dec KB_TEMP ; Igonre pause scans sjmp ChkKbEndNC NoIgnore: mov KB_SCAN, r1 cjne r1, #0FAH, NoKbACK orl KB_STATS, #ACK sjmp ChkKbEndNC NoKbACK: cjne r1, #KB_PAUSE, NoKbPause mov KB_TEMP, #7 ; Ignore next 7 scans mov a, KB_OK cpl acc.6 mov KB_OK, a sjmp ChkKbEndNC NoKbPause: cjne r1, #KB_EXT, NoKbExt orl KB_OK, #EXTENDED sjmp ChkKbEndNC NoKbExt: cjne r1, #KB_REL, NoRelease orl KB_STATS, #RELEASE sjmp ChkKbEndNC NoRelease: ; Test Num lock, if pressed toggle led cjne r1, #KB_NUML, NoNumLock mov a, KB_STATS jnb acc.7, ChkKbEndNC cpl acc.1 clr acc.7 mov KB_STATS, a call Keyb_Leds sjmp ChkKbEndNC NoNumLock: ; Test Caps lock, if pressed toggle led cjne r1, #KB_CAPS, NoCapsLock mov a, KB_STATS jnb acc.7, ChkKbEndNC cpl acc.2 clr acc.7 mov KB_STATS, a call Keyb_Leds sjmp ChkKbEndNC NoCapsLock: ; Test Scroll lock, if pressed toggle led cjne r1, #KB_SCROLL, NoScrollLock mov a, KB_STATS jnb acc.7, ChkKbEndNC cpl acc.0 clr acc.7 mov KB_STATS, a call Keyb_Leds ChkKbEndNC: clr c ret NoScrollLock: ; Test L & R shifts, set bit if pressed, clear on release cjne r1, #KB_LSHIFT, NoShift1 ShiftOK: mov a, KB_STATS jbc acc.7, ShiftRel setb acc.3 ; not releasing, so Set SHIFT bit sjmp ShiftEnd ShiftRel: clr acc.3 ; releasing, so Clear SHIFT bit ShiftEnd: mov KB_STATS, a sjmp ChkKbEndNC NoShift1: cjne r1, #KB_RSHIFT, NoShift sjmp ShiftOK NoShift: cjne r1, #KB_CTRL, NoCtrl mov a, KB_STATS jbc acc.7, CtrlRel setb acc.5 ; not releasing, so Set CTRL bit sjmp CtrlEnd CtrlRel: clr acc.5 ; releasing, so Clear SHIFT bit CtrlEnd: mov KB_STATS, a sjmp ChkKbEndNC NoCtrl: cjne r1, #KB_ALT, NoAlt mov a, KB_STATS jbc acc.7, AltRel setb acc.6 ; not releasing, so Set ALT bit sjmp AltEnd AltRel: clr acc.6 ; releasing, so Clear ALT bit AltEnd: mov KB_STATS, a sjmp ChkKbEndNC NoAlt: mov a, KB_STATS ; Releasing key test jnb acc.7, NoRel2 clr acc.7 ; if releasing > clear mov KB_STATS, a ; rel bit on KB_STATS clr c ; and do nothing ret NoRel2: mov a, KB_OK ; Extended key test jnb acc.7, KbChars clr acc.7 ; if Extended > clear mov KB_OK, a ; EXT bit on KB_OK clr c ; and do nothing ret KbChars:mov dptr, #KbScanCodes mov a, KB_STATS jnb acc.2, TestShift jb acc.3, KbChkOK mov a, r1 movc a, @a+dptr mov r0, a subb a, #97 jc KbChkOK mov a, r0 subb a, #123 jnc KbChkOK mov dptr, #KbScanCodes2 ; if (a to z) & Caps > table 2 sjmp KbChkOK TestShift: jnb acc.3, KbChkOK mov dptr, #KbScanCodes2 ; with shift table 2 KbChkOK: mov a, r1 movc a, @a+dptr mov KB_DATA, a setb c ret ;************************************* ; Zero2One2: Wait for high to low in ; kb clock line ;************************************* Zero2One2: jnb KEYB_CLOCK, $ jb KEYB_CLOCK, $ ret ;************************************* ; Write_Keyb: Send r1 to the kb ;************************************* Write_Keyb: mov r0, #8 ; 8 bits to receive clr KEYB_CLOCK ; break the Keyboard mov r7, #00H ; some delay (safety reasons) _WKwait:djnz r7, _WKwait clr KEYB_DATA ; request to send setb KEYB_CLOCK ; enable the Keyboard acall Zero2One2 ; Start Bit mov a, r1 ; Data Bits TxData: rrc a mov KEYB_DATA, c call Zero2One2 djnz r0, TxData mov a, r1 ; calculate parity bit mov c, psw.0 ; this is Even parity cpl c ; and Keyboard needs Odd parity mov KEYB_DATA, c ; send parity bit call Zero2One2 setb KEYB_DATA ; send stop bit call Zero2One2 call Zero2One2 mov c, KEYB_DATA ; get ACK bit clr KEYB_CLOCK ; stop the keyboard ret ;************************************* ; last 262 addr of code mem with scan codes tables ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ; last 262 addr of code mem with scan codes tables KbScanCodes: ; Keyboard Scancodes ; ?, F9, ?, F5, F4, F1, F2, F12, ?, F10, F8, F6, F4, TAB, ~ db 0, 1 , 0, 1 , 1 , 1 , 1 , 1 , 0, 1 , 1 , 1 , 1 , 1 , '~' ; ?, ?,Lalt,Lshf, ?,Lctr, Q , ! , ?, ?, ?, Z , S , A , W , @ db 0, 0, 0 , 0 , 0, 0 , 'q', '1', 0, 0, 0, 'z', 's', 'a', 'w', '2' ; ?, ?, C , X , D , E , $ , # , ?, ?, " ", V , F , T , R db 0, 0, 'c', 'x', 'd', 'e', '4', '3', 0, 0, ' ', 'v', 'f', 't', 'r' ; % , ?, ?, N , B , H , G , Y , ^ , ?, ?, ?, M , J , U , & db '5', 0, 0, 'n', 'b', 'h', 'g', 'y', '6', 0, 0, 0, 'm', 'j', 'u', '7' ; * , ?, ?, < , K , I , O , ) , ( , ?, ?, > , ? , L , : , P db '8', 0, 0, ',', 'k', 'i', 'o', '0', '9', 0, 0, '.', '/', 'l', ';', 'p' ; _ , ?, ?, ?, " , ?, { , + , ?, ?,Caps,Rshf,Entr, } , ?, | db '-', 0, 0, 0, 39 , 0, '[', '=', 0, 0, 0 , 0 , 1 , ']', 0, 92 ; ?, ?, ?, ?, ?, ?, ?, ?,BkSp, ?, ?, 1 , ?, 4 , 7 , ?, ?, ?, 0 db 0, 0, 0, 0, 0, 0, 0, 0, 1 , 0, 0, '1', 0, '4', '7', 0, 0, 0, '0' ; . , 2 , 5 , 6 , 8 , ESC,Numl, F11, + , 3 , - , * , 9 ,Scrl db '.', '2', '5', '6', '8', 1 , 0 , 1 , '+', '3', '-', '*', '9', 0 ; ?, ?, ?, ?, F7 db 0, 0, 0, 0, 1 KbScanCodes2: ; Keyboard Scancodes with shift ; ?, F9, ?, F5, F4, F1, F2, F12, ?, F10, F8, F6, F4, TAB, ~ db 0, 2 , 0, 2 , 2 , 2 , 2 , 2 , 0, 2 , 2 , 2 , 2 , 2 , '`' ; ?, ?,Lalt,Lshf, ?,Lctr, Q , ! , ?, ?, ?, Z , S , A , W , @ db 0, 0, 0 , 0 , 0, 0 , 'Q', '!', 0, 0, 0, 'Z', 'S', 'A', 'W', '@' ; ?, ?, C , X , D , E , $ , # , ?, ?, " ", V , F , T , R db 0, 0, 'C', 'X', 'D', 'E', '$', '#', 0, 0, ' ', 'V', 'F', 'T', 'R' ; % , ?, ?, N , B , H , G , Y , ^ , ?, ?, ?, M , J , U , & db '%', 0, 0, 'N', 'B', 'H', 'G', 'Y', '^', 0, 0, 0, 'M', 'J', 'U', '&' ; * , ?, ?, < , K , I , O , ) , ( , ?, ?, > , ? , L , : , P db '*', 0, 0, '<', 'K', 'I', 'O', ')', '(', 0, 0, '>', '?', 'L', ':', 'P' ; _ , ?, ?, ?, " , ?, { , + , ?, ?,Caps,Rshf,Entr, } , ?, | db '_', 0, 0, 0, '"', 0, '{', '+', 0, 0, 0 , 0 , 2 , '}', 0, '|' ; ?, ?, ?, ?, ?, ?, ?, ?,BkSp, ?, ?, 1 , ?, 4 , 7 , ?, ?, ?, 0 db 0, 0, 0, 0, 0, 0, 0, 0, 2 , 0, 0, '1', 0, '4', '7', 0, 0, 0, '0' ; . , 2 , 5 , 6 , 8 , ESC,Numl, F11, + , 3 , - , * , 9 ,Scrl db '.', '2', '5', '6', '8', 2 , 0 , 2 , '+', '3', '-', '*', '9', 0 ; ?, ?, ?, ?, F7 db 0, 0, 0, 0, 2 END


Write a program to multiply two 8 bit signed numbers using 8085 microprocessor?

s v i e t k a n u r u .t k MULTIPLICATION OF TWO 8 -- BIT NUMBERS AIM: To perform multiplication of two 8 -- bit numbers using 8051 instruction set. ALGORITHM: 1. Get the data in A -- reg.2. Get the value to be multiplied in B -- reg.3. Multiply the two data4. The higher order of the result is in B -- reg.5. The lower order of the result is in A -- reg.6. Store the results. PROGRAM: ORG 4100CLR CMOV A,#data1MOV B,#data2MUL ABMOV DPTR,#4500MOVX @DPTR,AINC DPTR MOV A,BMOVX @DPTR,AHERE: SJMP HERE


Write a program to add and subtract two 32 bit numbers in 8085 microprocessor?

;Write a program to add two 32-bit numbers stored in RAM locations. ;Let's assume that the numbers are stored at RAM location 40-43H and 50-53H respectively. ORG 0H MOV 40H, #23 MOV 41H, #15 MOV 42H, #60 MOV 43H, #70 MOV 50H, #30 MOV 51H, #40 MOV 52H, #63 MOV 53H, #77 MOV R0, #40H ;pointer of bank 0 MOV R1, #60H ;result storage bank 0 MOV R2, #4 ;counter SETB RS0 MOV R1, #50H ;pointer bank 1 CLR RS0 CLR C REPEAT: MOV A, @R0 SETB RS0 ADDC A, @R1 INC R1 CLR RS0 MOV @R1, A INC R0 INC R1 DJNZ R2, REPEAT JNC EXIT INC @R1 EXIT: NOP SJMP $ END


Write a program to add two 8 bit numbers in microprocessor 8086?

its munch, my program will add two 8-bit no. and store ina memory location MVI 20H //copies 20h to accumulator ADI 30H //adds 30h with the content of accumulator STA 3000H //store result in 3000h lpcation HLT //stop operation this operation also can be done with taking the values from memory location as LDA 2000H //loads accumulator with contents of 2000h location MOV B,A //copies the content of accumulator to register B LDA 2001H //loads acc with the content of 2001h ADD B //adds acc with content of register B STA 3000H //stores result in location 3000h HLT //stops operation and there are further many ways to perform the same dependent on many conditions such as carry etc.